複製鏈接
請複製以下鏈接發送給好友

SetCurrentDirectory

鎖定
SetCurrentDirectory切換當前進程的當前工作目錄。
中文名
SetCurrentDirectory
簡    介
切換當前進程的當前工作目錄
VC函數原型
BOOL WINAPI SetCurrent
參數説明
lpPathName

SetCurrentDirectory目錄

切換當前進程的當前工作目錄。

SetCurrentDirectoryVC函數原型

BOOL WINAPI SetCurrentDirectory( __in LPCTSTR lpPathName);

SetCurrentDirectory參數説明

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.

SetCurrentDirectoryR V

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.

SetCurrentDirectoryRemark

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

SetCurrentDirectoryVB聲明

Declare Function SetCurrentDirectory Lib "kernel32" Alias "SetCurrentDirectoryA" (ByVal lpPathName As String) As Long

SetCurrentDirectory説明

設置當前目錄

SetCurrentDirectory返回值

Long,非零表示成功,零表示失敗。會設置GetLastError

SetCurrentDirectory參數表

參數 類型及説明
lpPathName String,新目錄的路徑

SetCurrentDirectoryExample

CString g_strDirect = "\\vcpp32\\ex34a\\WebSite";
SetCurrentDirectory(g_strDirect);