Shgetspecialfolderpath is a useful API

Source: Internet
Author: User

Shgetspecialfolderpath is a useful API

Petabytes are used to retrieve the system folder. There are many APIs, such as getsystemdirectorya. You can get the System32 system folder.
And getwindowsdirectorya to get the Windows folder. Here we will introduce a useful API-
Shgetspecialfolderpath. In addition to the folders listed above, this API can get more system folders.

Usage:

Declare API: function ulong shgetspecialfolderpath (long hwndowner, ref
String lpszpath, int nfolder, Boolean fcreate) Library "shell32.dll"
Alias for "shgetspecialfolderpatha"
Function long getasktopwindow () Library 'user32. dll'

Hwndowner: Use the getasktopwindow API to obtain a window handle.

Lpszpath: returned path

Nfolder: ID code

Fcreate: true: Create a folder if it does not exist; false: do not create a folder

The relationship between lpszpath and nfolder:

 

Nfolder Lpszpath
0 C:/Documents and Settings/current user/desktop
2 C:/Documents and Settings/current user/Start Menu/Program
5 C:/Documents and Settings/current user/My Documents ents
6 C:/Documents and Settings/current user/favorites
7 C:/Documents and Settings/current user/Start Menu/Program/start
8 C:/Documents and Settings/current user/recent
9 C:/Documents and Settings/current user/sendto
11 C:/Documents and Settings/current user/Start Menu
13 C:/Documents and Settings/current user/My Documents/my music
14 C:/Documents and Settings/current user/My Documents/my videos
16 C:/Documents and Settings/current user/desktop
19 C:/Documents and Settings/current user/nethood
20 C:/Windows/Fonts
21 C:/Documents and Settings/current user/templates
22 C:/Documents and Settings/all users/Start Menu
23 C:/Documents and Settings/all users/Start Menu/Program
24 C:/Documents and Settings/all users/Start Menu/Program/start
25 C:/Documents and Settings/all users/desktop
26 C:/Documents and Settings/current user/Application Data
27 C:/Documents and Settings/current user/printhood
28 C:/Documents and Settings/current user/Local Settings/Application Data
31 C:/Documents and Settings/all users/favorites
32 C:/Documents and Settings/current user/Local Settings/Temporary Internet Files
33 C:/Documents and Settings/current user/cookies
34 C:/Documents and Settings/current user/Local Settings/History
35 C:/Documents and Settings/all users/Application Data
36 C:/Windows
37 C:/Windows/system32
38 C:/Program Files
39 C:/Documents and Settings/current user/My Documents documents/my pictures
40 C:/Documents and Settings/current user
43 C:/program files/common files
45 C:/Documents and Settings/all users/templates
46 C:/Documents and Settings/all users/Documents ents
47 C:/Documents and Settings/all users/Start Menu/programs/management tools
48 C:/Documents and Settings/current user/Start Menu/Program/management tool
53 C:/Documents and Settings/all users/Documents ents/my music
54 C:/Documents ents and settings/all users/Documents ents/my pictures
55 C:/Documents ents and settings/all users/Documents ents/my videos
56 C:/Windows/Resources
59 C:/Documents and Settings/current user/Local Settings/Application Data/Microsoft/CD Burning

Function Syntax:

// ================================================ ====================================
// Function: u_fun: uf_directory_get ()
//--------------------------------------------------------------------
// Description: obtains the system folder.
//--------------------------------------------------------------------
// Parameters:
// Value integer ai_folder
//--------------------------------------------------------------------
// Return value: String
//--------------------------------------------------------------------
// Modification history:
//
// ================================================ ====================================
String RET
Long ll_null
Ret = space (0, 255)
Shgetspecialfolderpath (getasktopwindow (), RET, ai_folder, false)
Return ret

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.