Example Code

Get Windows Folder Paths

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

    Operating System

  • Windows

Code and Documents

Attachment

Description

Overview

 

This VI calls a Windows API function to retrieve the path of Windows System Folders that may vary with different installations of the operating system.

 

Description

 

This VI calls the SHGetFolderPathA() function in shell32.dll to get the absolute path to special Windows folders such as the Desktop folder, My Documents folder, Program Files folder, Windows System folder, and other system and virtual folders.

 

folder paths BD.png

 

This code was written by Jason Dunham of ShotSpotter, Inc. and based on older VIs by John E. Wilson and Noel Adorno previously found on zone.ni.com.

 

Here is a list of the folders this program can give you access to:

 

ADMINTOOLS

ALTSTARTUP

APPDATA

BITBUCKET

CDBURN_AREA

COMMON_ADMINTOOLS

COMMON_ALTSTARTUP

COMMON_APPDATA

COMMON_DESKTOPDIRECTORY

COMMON_DOCUMENTS

COMMON_FAVORITES

COMMON_MUSIC

COMMON_PICTURES

COMMON_PROGRAMS

COMMON_STARTMENU

COMMON_STARTUP

COMMON_TEMPLATES

COMMON_VIDEO

COMPUTERSNEARME

CONNECTIONS

CONTROLS

COOKIES

DESKTOP

DESKTOPDIRECTORY

DRIVES

FAVORITES

FONTS

HISTORY

INTERNET

INTERNET_CACHE

LOCAL_APPDATA

MYDOCUMENTS

MYMUSIC

MYPICTURES

MYVIDEO

NETHOOD

NETWORK

PERSONAL

PHOTOALBUMS

PLAYLISTS

PRINTERS

PRINTHOOD

PROFILE

PROGRAM_FILES

PROGRAM_FILES_COMMON

PROGRAMS

RECENT

RESOURCES

SAMPLE_MUSIC

SAMPLE_PLAYLISTS

SAMPLE_PICTURES

SAMPLE_VIDEOS

SENDTO

STARTMENU

STARTUP

SYSTEM

TEMPLATES

WINDOWS

 

 

Steps to Implement or Execute Code

 

folder paths FP.png

  1. Choose the Folder Role.
  2. Choose either the current or default path.
  3. Choose whether or not the folder should be created if not found.
  4. Run the VI.
  5. Observe the path and description of the chosen folder.

 

 

Requirements

This VI is supported on Windows 2000, XP, and Vista.

 

Software

LabVIEW 8.2.1 or later

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

John Passiak

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.