PathStripToRoot

PathStripToRoot是刪除掉除根路徑外所有的路徑文本的意思。

簡述,語法,參數,返回值,示例,

簡述

刪除掉除根路徑外所有的路徑文本,簡稱 刪除到根路徑.(Removes all parts of the path except for the root information.)

語法

BOOL PathStripToRoot(
_Inout_ LPTSTR szRoot
);

參數

szRoot
解釋:路徑文本;一個指針,指向一個空結束的字元串,長度MAX_PATH,它包含要轉換的路徑。這個函式成功返回時,這個字元串只包含根從該路徑的信息。
A pointer to a null-terminated string of length MAX_PATH that contains the path to be converted. When this function returns successfully, this string contains only the root information taken from that path.

返回值

類型:BOOL
成功返回真,失敗返回假 (Returns TRUE if a valid drive letter was found in the path, or FALSE otherwise.)

示例

#include <windows.h> #include <iostream.h>
#include "Shlwapi.h"
void main( void )
{ // Path to convert.
char buffer_1[ ] = "C:\\path1\\path2";
char *lpStr1;
lpStr1 = buffer_1;
// Print the path before the root is stripped.
cout << "The contents of the path before is : " << lpStr1 << endl;
// Print the return value from the function.
cout << "The return from \"PathStripToRoot\" is : "
<< PathStripToRoot(lpStr1) << endl;
// Print the path after the root is stripped.
cout << "The contents of the path after is : " << lpStr1 << endl;
}
OUTPUT:
==================
The contents of the path before is : C:\path1\path2
The return from "PathStripToRoot" is : 1
The contents of the path after is : C:\

相關詞條

熱門詞條

聯絡我們