网站首页  词典首页

请输入您要查询的函数:

 

术语 setcurrentdirectory
释义 SetCurrentDirectory
语法:
C++
BOOL WINAPI SetCurrentDirectory(
__in LPCTSTR lpPathName
);
SetCurrentDirectory函数
为改变当前进程的当前目录。
参数
lpPathName [in]
在新的当前目录路径。此参数可以指定相对路径或完整路径。在这两种情况下,指定的目录的完整路径计算并作为当前目录中。有关更多信息,请参阅文件名,路径和命名空间。
该字符串不能超过MAX_PATH字符,包括终止空字符。面前的空字符的最后一个字符必须是一个反斜杠('\\')。如果您不指定反斜杠,这将是为您增加,因此,指定MAX_PATH为2个字符的路径,除非您包括尾部反斜杠,在这种情况下,指定MAX_PATH - 1的路径字符。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
每个进程都有一个当前目录由两部分组成:
磁盘指示符是一个驱动器号一个冒号,或服务器名称和共享名称后(\\ \\服务器\\共享名)
磁盘上的指示器目录
多线程应用程序和共享库中的代码不应该使用SetCurrentDirectory职能,并应避免使用相对路径名。当前目录国家的SetCurrentDirectory函数书面存储为每个进程中的全局变量,因此,多线程应用程序不能可靠地使用数据,没有腐败的可能从其它线程这个值,也可以读取或设置此值。这种限制也适用于GetCurrentDirectory和GetFullPathName功能。唯一的例外是当应用程序保证是在一个线程中运行,例如解析命令行中的主线程参数字符串之前产生任何额外的线程文件名。多线程应用程序中使用相对路径名或共享库的代码可以产生不可预知的结果,不支持。
实例
有关示例,请参阅更改当前目录。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinBase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode和ANSI namesSetCurrentDirectoryW(Unicode)和SetCurrentDirectoryA(ANSI)的
参见
目录管理功能
GetCurrentDirectory
GetFullPathName
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年9月3日
==英文原文==SetCurrentDirectory Function
Changes the current directory for the current process.
Syntax
C++
BOOL WINAPI SetCurrentDirectory(
__in LPCTSTR lpPathName
);
Parameters
lpPathName [in]
The path to the new current directory. This parameter may specify a relative path or a full path. In either case, the full path of the specified directory is calculated and stored as the current directory. For more information, see File Names, Paths, and Namespaces .
The string must not exceed MAX_PATH characters, including the terminating null character. The final character before the null character must be a backslash ('\\'). If you do not specify the backslash, it will be added for you; therefore, specify MAX_PATH-2 characters for the path unless you include the trailing backslash, in which case, specify MAX_PATH-1 characters for the path.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError .
Remarks
Each process has a single current directory made up of two parts:
A disk designator that is either a drive letter followed by a colon, or a server name and share name (\\\\servername\\sharename)
A directory on the disk designator
Multithreaded applications and shared library code should not use the SetCurrentDirectory function and should avoid using relative path names. The current directory state written by the SetCurrentDirectory function is stored as a global variable in each process, therefore multithreaded applications cannot reliably use this value without possible data corruption from other threads that may also be reading or setting this value. This limitation also applies to the GetCurrentDirectory and GetFullPathName functions. The exception being when the application is guaranteed to be running in a single thread, for example parsing file names from the command line argument string in the main thread prior to creating any additional threads. Using relative path names in multithreaded applications or shared library code can yield unpredictable results and is not supported.
Examples
For an example, see Changing the Current Directory .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinBase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
Unicode and ANSI namesSetCurrentDirectoryW (Unicode) and SetCurrentDirectoryA (ANSI)
See Also
Directory Management Functions
GetCurrentDirectory
GetFullPathName
Send comments about this topic to Microsoft
Build date: 9/3/2009
==原始网址==http://msdn.microsoft.com/en-us/library/aa365530(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:22:04