网站首页  词典首页

请输入您要查询的函数:

 

术语 shgetfolderpathandsubdir
释义 SHGetFolderPathAndSubDir
语法:
HRESULT SHGetFolderPathAndSubDir( HWND hwnd,
int csidl,
HANDLE hToken,
DWORD dwFlags,
LPCTSTR pszSubDir,
LPTSTR pszPath
);
SHGetFolderPathAndSubDir功能
获取文件夹的路径和追加用户提供的子文件夹的路径。
参数
hwnd
[in]保留。
的CSIDL
[in]阿CSIDL值标识该文件夹的路径是要检索。唯一真正有效的文件夹。如果一个指定的虚拟文件夹,这个功能失败。您可以强制相结合CSIDL_FLAG_CREATE该文件夹的的CSIDL与SHGetFolderPathAndSubDir的文件夹创建。
hToken
[in]一个访问令牌代表一个特定的用户。对于系统于Microsoft Windows 2000之前,设置这个值为NULL。对于以后的系统,通常是hToken,但并不总是设置为NULL。您可能需要指定一个值hToken对这些文件夹可以有多个用户,但属于单个用户处理。这一类型的最常用的文件夹是我的文档。
dwFlags
[in]的路径是否要返回指定的文件夹或默认路径的实际路径。此值的情况下使用的CSIDL值与相关的文件夹可能被移动或由用户重命名。
SHGFP_TYPE_CURRENT
返回文件夹的当前路径。
SHGFP_TYPE_DEFAULT
返回文件夹的默认路径。
pszSubDir
[in]一个指向子路径将追加到该文件夹的路径。这是一个空终止字符串长度MAX_PATH。如果您不是创建一个新的目录,这必须是现有的子目录或函数返回一个错误。此值可以为NULL如果没有子路径要追加。
pszPath
[内]当此函数返回时,此值指向目录的路径和附加子路径。这是一个空终止字符串长度MAX_PATH。该字符串为空当函数返回一个错误代码或结果S_FALSE。
返回值
返回S_OK如果成功,或者一个错误值,否则,其中包括以下内容:
ERROR_FILE_NOT_FOUNDThe的CSIDL在CSIDL值是有效的,但文件夹(包括追加子目录)不存在。
E_INVALIDARGThe的CSIDL在CSIDL值是无效的。
例如
下面的示例显示了如何使用SHGetFolderPathAndSubDir找到的System32子目录,然后在其中创建一个文件。
HRESULT hr;
TCHAR szPath[MAX_PATH];
...
if (SUCCEEDED (hr = SHGetFolderPathAndSubDir(NULL, // hWnd 
CSIDL_WINDOWS, // csidl
NULL, // hToken
SHGFP_TYPE_CURRENT, // dwFlags
TEXT("system32"), // pszSubDir
szPath)) // pszPath
{
 PathAppend(szPath, TEXT("New Doc.txt"));
 HANDLE hFile = CreateFile(szPath, ...);
}
功能信息
最低DLL版本 shell32.dll版本5.60或更高版本
自定义ImplementationNo
Headershlobj.h
import libraryshell32.lib
XP的最低经营systemsWindows
UnicodeImplemented为ANSI和Unicode版本。
参见
的SHGetFolderPath
==英文原文==SHGetFolderPathAndSubDir Function
Gets the path of a folder and appends a user-provided subfolder path.
Syntax
HRESULT SHGetFolderPathAndSubDir( HWND hwnd,
int csidl,
HANDLE hToken,
DWORD dwFlags,
LPCTSTR pszSubDir,
LPTSTR pszPath
);
Parameters
hwnd
[in] Reserved.
csidl
[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 with SHGetFolderPathAndSubDir by combining the folder's CSIDL with CSIDL_FLAG_CREATE.
hToken
[in] An access token that represents a particular user. For systems earlier than Microsoft Windows 2000, set this value to NULL. For later systems, hToken is usually, but not always, set to NULL. You might need to assign a 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 My Documents .
dwFlags
[in] Specifies whether the path to be returned is the actual path of the folder or the default path. This value is used in cases where the folder associated with a CSIDL value may be moved or renamed by the user.
SHGFP_TYPE_CURRENT
Return the folder's current path.
SHGFP_TYPE_DEFAULT
Return the folder's default path.
pszSubDir
[in] A pointer to the subpath to be appended to the folder's path. This is a null-terminated string of length MAX_PATH. If you are not creating a new directory, this must be an existing subdirectory or the function returns an error. This value can be NULL if no subpath is to be appended.
pszPath
[out] When this function returns, this value points to the directory path and appended subpath. This is a null-terminated string of length MAX_PATH. This string is empty when the function returns an error code or S_FALSE.
Return Value
Returns S_OK if successful, or an error value otherwise, including the following:
ERROR_FILE_NOT_FOUNDThe CSIDL value in csidl is valid, but the folder (including the appended subdirectory) does not exist.
E_INVALIDARGThe CSIDL value in csidl is not valid.
Example
The following example shows how to use SHGetFolderPathAndSubDir to locate the System32 subdirectory and then create a file within it.
HRESULT hr;
TCHAR szPath[MAX_PATH];
...
if (SUCCEEDED (hr = SHGetFolderPathAndSubDir(NULL, // hWnd 
CSIDL_WINDOWS, // csidl
NULL, // hToken
SHGFP_TYPE_CURRENT, // dwFlags
TEXT("system32"), // pszSubDir
szPath)) // pszPath
{
 PathAppend(szPath, TEXT("New Doc.txt"));
 HANDLE hFile = CreateFile(szPath, ...);
}
Function Information
Minimum DLL Versionshell32.dll version 5.60 or later
Custom ImplementationNo
Headershlobj.h
Import libraryshell32.lib
Minimum operating systemsWindows XP
UnicodeImplemented as ANSI and Unicode versions.
See Also
SHGetFolderPath
==原始网址==http://msdn.microsoft.com/en-us/library/bb762182(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:24