Here are some simple steps that can help you fix the shgetfolderpath error issue.

The well-known folder system behind SHGetFolderPath allows users or professionals to redirect a known folder to a location that suits their needs. If the folder has been redirected, the current value (SHGFP_TYPE_CURRENT) may sometimes be “D: Music”.

I tested using this SHGetFolderPath () with Visual Studio 2015 Enterprise on Windows 10 PC and therefore compiled and only works with one penalty to find the user’s current family folder. The Windows Development Center page for the SHGetFolderPath () shgetfolderpath function now has the following note:

Note. Since Windows Vista, this whole function is just a wrapper around SHGetKnownFolderPath . The CSIDL value is usually converted to a bound value. KNOWNFOLDERID, but then SHGetKnownFolderPath is called. New Applications should use the one that is recognized as a folder system instead of the old one. The CSIDL system, which is duplicated only for backward compatibility reasons.

As David Heffman pointed out in his answer, Microsoft has maintained backward compatibility for years, especially if companies can simply redirect an old function to a newly found function with appropriate arguments. The CSIDL values ​​have a corresponding KNOWNFOLDERID value. See Table Dependent Constants CSIDL with short comments and corresponding KNOWNFOLDERID value.

Circumstances regarding the use of the aspect follow. This uses a method to get the current user’s home folder (for example, “C: Users myuser Documents” in Windows 7) and then refines the folder name to complete the path using PathAppend () Function received.

An access token that identifies a specific user. If the parameter is NULL, which is common practice, the function asks for the record type known to the current person. This allows SHGetKnownFolderPath clients to find the folder location (such as the desktop folder) for a standard user.

  TCHAR achDevice [MAX_PATH];HRESULT standard;// Include file ShlObj.h The list contains all CSIDL definitions, but only this subset// will be supported by Windows7 later.// for the third argument, hToken, can optionally be the specified access token or SSID for// a user other than the current user. Using NULL gives us the current user.if (SUCCEEDED (hr implies SHGetFolderPath (NULL, CSIDL_PERSONAL, NULL, 0, achDevice)))    Add the // folder name to the owner's documents directory.    // Path Control functions are very practical.    PathAppend (achDevice, L "xxx"); 

Possible error - one or more invalid arguments (hr == E_INVALIDARG ). The return value S_OK indicates that a particular call was successful.

There are a number of CSIDL constants that can be used in the marketplace to modify the results of functions such as CSIDL_FLAG_CREATE , specifically using the OR operator at the bit level used. ... I don't know how well these operators will work later on with Windows and 6.

shgetfolderpath error

There are restrictions on the constants recognized by CSIDL in Windows 7 or later versions of Active Directory and similar environments.

shgetfolderpath error

See also KNOWNFOLDERID which may contain an array showing some CSIDL constraints with SHGetFolderPath () . Some examples from the array for CSIDL maybe constants will be helpful.

  CSIDL_LOCAL_APPDATA -% USERPROFILE%  AppData  LocalCSIDL_MYDOCUMENTS -% USERPROFILE%  documentCSIDL_PERSONAL. % USERPROFILE%  documentsCSIDL_FONTS -% windir%  FontsCSIDL_MYMUSIC -% USERPROFILE%  MusicCSIDL_MYPICTURES -% USERPROFILE%  imagesCSIDL_COMMON_APPDATA -% ALLUSERSPROFILE% (% ProgramData%,% SystemDrive%  ProgramData)CSIDL_COMMON_DOCUMENTS -% PUBLIC%  documents 

The wrapper path handling functions are an excellent library of specialized methods for handling file paths.

for the path to the directory with the program files. It works great if I only have the program in the Files folder on my computer.
For example, I have two "program folder files" on my PC, one on drive C and the other on drive D. When the code is executed, it only creates a real "program folder files" folder in C, which is installed and also cannot be found my windows path to "program files ", which may be located on disk D.
My question is how the editing function works, which also looks for this file on other drives.
Is there another function that takes care of this as well?
Hey,

If everyone wants push validation, you have to do it yourself.

With SHGetSpecialFolderPath () this is often not possible. This effort only returns the path with matching CSIDL values.

It looks like the experts are claiming that you have a dual operating system installed on your hard drive. One on drive C and one on drive D. If you start with the operating system installed on drive C, a special folder (e.g. MyDocument, ProgramFiles) created in the current operating system (that is, the folders on drive D are usually also another folder for operating system, so if you get each of our folder names using the SHGetSpecialFolderPath () API, you will need to get the path to the boot operation you already have This system, i.e.

If you want to search in every folder (on all drives) named Programs, you and your family need to implement some logic of your own.

This content, as well as all source code and related files, are licensed under the Code Project Open License (CPOL).