网站首页  词典首页

请输入您要查询的函数:

 

术语 shgetfolderpath
释义 SHGetFolderPath
语法:
HRESULT SHGetFolderPath( HWND hwndOwner,
int nFolder,
HANDLE hToken,
DWORD dwFlags,
LPTSTR pszPath
);
SHGetFolderPath函数
已过时。获取CSIDL值所确定的文件夹路径。
注意:由于Windows Vista中,这项功能只不过是SHGetKnownFolderPath包装。该CSIDL值被转换到其关联KNOWNFOLDERID然后SHGetKnownFolderPath被调用。新的应用程序应该使用已知的文件夹系统,而不是旧的CSIDL系统,该系统只支持向后兼容。
参数
hwndOwner
[in]保留。
nFolder
[in]阿CSIDL值标识该文件夹的路径是要检索。唯一真正有效的文件夹。如果一个指定的虚拟文件夹,这个功能失败。您可以强制相结合CSIDL_FLAG_CREATE该文件夹的的CSIDL文件夹的创建。
hToken
[in]一个访问令牌可以用来表示一个特定的用户。
Microsoft Windows 2000和更早版本:始终设置此参数为NULL。
Windows XP和更高版本:此参数通常设置为NULL,但您可能需要指定一个非空值hToken对这些文件夹可以有多个用户,但属于单个用户处理。这一类型的最常用的文件夹中的文件。
调用进程负责正确模拟时hToken是非空。调用进程必须有特定的用户,包括TOKEN_QUERY和TOKEN_IMPERSONATE适当的安全权限,以及用户的注册表配置单元当前必须安装。见的访问控制问题的进一步讨论访问控制。
分配的hToken参数值为-1表示默认用户。这使得客户的的SHGetFolderPath找到文件夹位置(如桌面文件夹)的默认用户。默认用户的用户配置文件复制时,任何新创建的用户帐户,并包括我的文档等特殊文件夹和桌面。任何项目添加到Default User文件夹也会出现在任何新的用户帐户。
dwFlags
[in]的标志指定要返回的路径。此值的情况下使用的KNOWNFOLDERID(或的CSIDL关联的文件夹)可以移动,重命名,重定向,跨语言或漫步由用户或管理员。
已知的文件夹系统,基础的SHGetFolderPath允许用户或管理员已知文件夹重定向到一个位置,适合他们的需要。这是通过调用IKnownFolderManager::重定向,确定了“当前”与SHGFP_TYPE_CURRENT标志相关的文件夹中的价值。
该文件夹,文件夹的位置,默认值,如果用户或管理员没有重定向到其他地方,是检索指定SHGFP_TYPE_DEFAULT标志。此值可用于实施“恢复对已知的文件夹默认”功能。
例如,默认值为FOLDERID_Music(SHGFP_TYPE_DEFAULT)(CSIDL_MYMUSIC)为“C:\\ Users \\用户名\\音乐”。如果该文件夹重定向,当前值(SHGFP_TYPE_CURRENT)可能的“D:\\音乐”。如果该文件夹并没有被重定向,那么SHGFP_TYPE_DEFAULT和SHGFP_TYPE_CURRENT检索相同的路径。
SHGFP_TYPE_CURRENT
检索文件夹的当前路径。
SHGFP_TYPE_DEFAULT
检索到此文件夹的默认路径。
pszPath
[out] 一个空指针结尾的长度MAX_PATH将接收路径字符串。如果发生错误或返回返回S_FALSE,此字符串将为空。
返回值
返回S_OK如果成功,或者一个错误值,否则,其中包括以下。
S_FALSESHGetFolderPathA只。在nFolder的CSIDL是有效的,但该文件夹不存在。请注意,故障代码为ANSI和Unicode版本此功能不同。
E_FAILSHGetFolderPathW只。在nFolder的CSIDL是有效的,但该文件夹不存在。请注意,故障代码为ANSI和Unicode版本此功能不同。
E_INVALIDARGThe在nFolder的CSIDL是无效的。
备注
此函数是一个SHGetSpecialFolderPath超集,与壳牌的早期版本中。在此之前,包括Shell32.dll中的版本5.0(仅限Microsoft Windows千禧版(Windows Me)和Windows 2000)系统,将SHGetFolderPath Shfolder.dll中获得通过,与Microsoft Internet Explorer 4.0和更高版本发行。 Shfolder.dll中始终调用当前平台的这一功能的版本。如果失败,它会尝试模拟适当的行为。 Shfolder.dll中继续是向后兼容包括在内,但现在该函数在Shell32.dll实施。
注意:在旧系统的需要可再发行Shfolder.dll中,您必须显式链接到SHFolder.lib之前,您链接到Shell32.lib。
只有一些的CSIDL值支持,包括下列内容:
CSIDL_ADMINTOOLS
CSIDL_APPDATA
CSIDL_COMMON_ADMINTOOLS
CSIDL_COMMON_APPDATA的
CSIDL_COMMON_DOCUMENTS
CSIDL_COOKIES
CSIDL_FLAG_CREATE
CSIDL_FLAG_DONT_VERIFY
CSIDL_HISTORY
CSIDL_INTERNET_CACHE
CSIDL_LOCAL_APPDATA
CSIDL_MYPICTURES
CSIDL_PERSONAL
CSIDL_PROGRAM_FILES
CSIDL_PROGRAM_FILES_COMMON
CSIDL_SYSTEM
CSIDL_WINDOWS
例如
下面的代码示例使用的SHGetFolderPath查找或创建一个文件夹,然后创建一个在它的文件。
TCHAR szPath[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_PERSONAL|CSIDL_FLAG_CREATE,
NULL,
0,
szPath)))
{
PathAppend(szPath, TEXT("New Doc.txt"));
HANDLE hFile = CreateFile(szPath, ...);
}
功能信息
最低DLL版本 shell32.dll 5.0或更新版本
自定义ImplementationNo
Headershlobj.h
import libraryshell32.lib
最低经营systemsWindows与Internet Explorer 5.0,Windows 98中使用Internet Explorer 5.0,Windows NT 4.0的带有Service Pack 4(SP4的使用Internet Explorer 5.0,Windows 98第二版(SE),Windows NT 4.0中95)
UnicodeImplemented为ANSI和Unicode版本。
参见
IKnownFolder::GetPath
==英文原文==SHGetFolderPath Function
Deprecated. Gets the path of a folder identified by a CSIDL value.
Note As of Windows Vista, this function is merely a wrapper for SHGetKnownFolderPath . The CSIDL value is translated to its associated KNOWNFOLDERID and then SHGetKnownFolderPath is called. New applications should use the known folder system rather than the older CSIDL system, which is supported only for backward compatibility.
Syntax
HRESULT SHGetFolderPath( HWND hwndOwner,
int nFolder,
HANDLE hToken,
DWORD dwFlags,
LPTSTR pszPath
);
Parameters
hwndOwner
[in] Reserved.
nFolder
[in] A CSIDL value that identifies the folder whose path is to be retrieved. Only real folders are valid. If a virtual folder is specified, this function fails. You can force creation of a folder by combining the folder's CSIDL with CSIDL_FLAG_CREATE.
hToken
[in] An access token that can be used to represent a particular user.
Microsoft Windows 2000 and earlier: Always set this parameter to NULL.
Windows XP and later: This parameter is usually set to NULL, but you might need to assign a non-NULL value to hToken for those folders that can have multiple users but are treated as belonging to a single user. The most commonly used folder of this type is Documents.
The calling process is responsible for correct impersonation when hToken is non-NULL. The calling process must have appropriate security privileges for the particular user, including TOKEN_QUERY and TOKEN_IMPERSONATE, and the user's registry hive must be currently mounted. See Access Control for further discussion of access control issues.
Assigning the hToken parameter a value of -1 indicates the Default User. This enables clients of SHGetFolderPath to find folder locations (such as the Desktop folder) for the Default User. The Default User user profile is duplicated when any new user account is created, and includes special folders such as My Documents and Desktop. Any items added to the Default User folder also appear in any new user account.
dwFlags
[in] Flags that specify the path to be returned. This value is used in cases where the folder associated with a KNOWNFOLDERID (or CSIDL) can be moved, renamed, redirected, or roamed across languages by a user or administrator.
The known folder system that underlies SHGetFolderPath allows users or administrators to redirect a known folder to a location that suits their needs. This is achieved by calling IKnownFolderManager::Redirect , which sets the "current" value of the folder associated with the SHGFP_TYPE_CURRENT flag.
The default value of the folder, which is the location of the folder if a user or administrator had not redirected it elsewhere, is retrieved by specifying the SHGFP_TYPE_DEFAULT flag. This value can be used to implement a "restore defaults" feature for a known folder.
For example, the default value (SHGFP_TYPE_DEFAULT) for FOLDERID_Music ( CSIDL_MYMUSIC ) is "C:\\Users\\user name\\Music". If the folder was redirected, the current value (SHGFP_TYPE_CURRENT) might be "D:\\Music". If the folder has not been redirected, then SHGFP_TYPE_DEFAULT and SHGFP_TYPE_CURRENT retrieve the same path.
SHGFP_TYPE_CURRENT
Retrieve the folder's current path.
SHGFP_TYPE_DEFAULT
Retreive the folder's default path.
pszPath
[out] A pointer to a null-terminated string of length MAX_PATH which will receive the path. If an error occurs or S_FALSE is returned, this string will be empty.
Return Value
Returns S_OK if successful, or an error value otherwise, including the following.
S_FALSESHGetFolderPathA only. The CSIDL in nFolder is valid, but the folder does not exist. Note that the failure code is different for the ANSI and Unicode versions of this function.
E_FAILSHGetFolderPathW only. The CSIDL in nFolder is valid, but the folder does not exist. Note that the failure code is different for the ANSI and Unicode versions of this function.
E_INVALIDARGThe CSIDL in nFolder is not valid.
Remarks
This function is a superset of SHGetSpecialFolderPath , included with earlier versions of the Shell. On systems that preceded those that include Shell32.dll version 5.0 (Microsoft Windows Millennium Edition (Windows Me) and Windows 2000), SHGetFolderPath was obtained through SHFolder.dll, distributed with Microsoft Internet Explorer 4.0 and later versions. SHFolder.dll always calls the current platform's version of this function. If that fails, it tries to simulate the appropriate behavior. SHFolder.dll continues to be included for backward compatibility, but the function is now implemented in Shell32.dll.
Note On older systems that require the redistributable SHFolder.dll, you must explicitly link to SHFolder.lib before you link to Shell32.lib.
Only some CSIDL values are supported, including the following:
CSIDL_ADMINTOOLS
CSIDL_APPDATA
CSIDL_COMMON_ADMINTOOLS
CSIDL_COMMON_APPDATA
CSIDL_COMMON_DOCUMENTS
CSIDL_COOKIES
CSIDL_FLAG_CREATE
CSIDL_FLAG_DONT_VERIFY
CSIDL_HISTORY
CSIDL_INTERNET_CACHE
CSIDL_LOCAL_APPDATA
CSIDL_MYPICTURES
CSIDL_PERSONAL
CSIDL_PROGRAM_FILES
CSIDL_PROGRAM_FILES_COMMON
CSIDL_SYSTEM
CSIDL_WINDOWS
Example
The following code example uses SHGetFolderPath to find or create a folder and then creates a file in it.
TCHAR szPath[MAX_PATH];
if(SUCCEEDED(SHGetFolderPath(NULL,
CSIDL_PERSONAL|CSIDL_FLAG_CREATE,
NULL,
0,
szPath)))
{
PathAppend(szPath, TEXT("New Doc.txt"));
HANDLE hFile = CreateFile(szPath, ...);
}
Function Information
Minimum DLL Versionshell32.dll version 5.0 or later
Custom ImplementationNo
Headershlobj.h
Import libraryshell32.lib
Minimum operating systemsWindows 95 with Internet Explorer 5.0, Windows 98 with Internet Explorer 5.0, Windows 98 Second Edition (SE), Windows NT 4.0 with Internet Explorer 5.0, Windows NT 4.0 with Service Pack 4 (SP4)
UnicodeImplemented as ANSI and Unicode versions.
See Also
IKnownFolder::GetPath
==原始网址==http://msdn.microsoft.com/en-us/library/bb762181(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:15:21