The information in this article applies to:
SUMMARYSfolder.exe is a self-extracting compressed file that contains a sample project demonstrating how to find the directory path of a special folder, such as the Programs folder. You can use this sample to find the directory path of these special folders so that your program can search for or load files into these folders. The project uses Windows API functions to access the special folders. MORE INFORMATIONThe following files are available for download from the Microsoft
Download Center. Click the file names below to download the files: Sfolder.exeFor more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. When you run the self-extracting executable file, the following files are expanded into the Special Folders Path Sample Project directory:
How to Run the SampleAfter expanding all the files, open the project file in the Visual Basic Integrated Development Environment (IDE). You need to make a reference to the ITMalloc.tlb type library and add the Microsoft Windows Common Controls 5.0 ActiveX component to the project.
How the Sample WorksEach special folder has a unique identification number that can only be accessed by a pointer to this number. This pointer is called a PIDL. Some of these folders map to a directory in your computer while others, such as CSIDL_DRIVES that is equivalent to the My Computer icon, do not have a directory. The list of special folders are shown in the code section of the sample project.To get the a pointer to the PIDL of any special folder, use the SHGetSpecialFolderLocation function. This function fills the SHELLEXECUTEINFO user defined type with information about the special folder. However, when you call the SHGetSpecialFolderLocation function, the calling application is responsible for freeing this pointer. You can free the pointer by using the Free method of the IMalloc operating system object through the SHGetMalloc function. Visual Basic can only access the Free method if the method is exposed through a type library. The ITMalloc.tlb type library to expose the Free method is included with the self-extracting file. Once you have the PIDL of a special folder, you can get the directory path of this folder through the SHGetPathFromIDList function. This function fills a string buffer with the directory path of a special folder if the folder exists on the system. The function fails if you pass a special folder without a directory, such as My Computer. REFERENCES
For more information about working with special folders, please see the
following:
"Walking Through Folders Topic", Chapter 11, "Stir Fry in Hardcore Visual Basic", Second Edition by Bruce McKinney, Microsoft Press. Additional query words: kbWin32 kbAPI kbVBp500 kbVBp600 kbsample kbVBp kbvs97 kbvs97sp3
Keywords : kbfile |
Last Reviewed: December 14, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |