PathGetArgs是一種編譯語言函式,刪除文本中第一個空格前的所有文本.若沒有空格返回空文本。
簡介,語法,參數,返回值,備註,示例,
簡介
刪除文本中第一個空格前的所有文本.若沒有空格返回空文本.
Finds the command line arguments within a given path.
語法
PTSTR PathGetArgs(
_In_ PTSTR pszPath
)
);
參數
pszPath 路徑文本
Pointer to a null-terminated string of maximum length MAX_PATH that contains the path to be searched.
返回值
成功返回刪除後的文本,失敗返回空文本.
Returns a pointer to a null-terminated string that contains the arguments portion of the path if successful.
If there are no arguments in the path, the function returns a pointer to the end of the input string.
If the function is given a NULL argument it returns NULL.
備註
這個函式不能用於通用命令路徑模板(從用戶或註冊表),而是應該僅用於模板,應用程式知道是形成良好的。
This function should not be used on generic command path templates (from users or the registry), but rather should be used only on templates that the application knows to be well formed.
示例
#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"
void main( void )
{
// Path_1 to search for file arguments (2 arguments):
char buffer_1[ ] = "test.exe temp.txt sample.doc";
char *lpStr1;
lpStr1 = buffer_1;
// Path_2 to search for file arguments (3 arguments):
char buffer_2[ ] = "test.exe 1 2 3";
char *lpStr2;
lpStr2 = buffer_2;
// Path_3 to search for file arguments (3 arguments):
char buffer_3[ ] = "test.exe sample All 15";
char *lpStr3;
lpStr3 = buffer_3;
// Path_4 to search for file arguments (no arguments):
char buffer_4[ ] = "test.exe";
char *lpStr4;
lpStr4 = buffer_4;
cout << "The path passed to the function was : " << lpStr1 <<
"\nThe arg(s)found in path 1 were : " << PathGetArgs(lpStr1) << endl;
cout << "\nThe path passed to the function was : " << lpStr2 <<
"\nThe arg(s)found in path 2 were : " << PathGetArgs(lpStr2) << endl;
cout << "\nThe path passed to the function was : " << lpStr3 <<
"\nThe arg(s)found in path 3 were : " << PathGetArgs(lpStr3) << endl;
cout << "\nThe path passed to the function was : " << lpStr4 <<
"\nThe arg(s)found in path 4 were : " << PathGetArgs(lpStr4) << endl;
}
OUTPUT:
===========
The path passed to the function was : test.exe temp.txt sample.doc
The arg(s)found in path 1 were : temp.txt sample.doc
The path passed to the function was : test.exe 1 2 3
The arg(s)found in path 2 were : 1 2 3
The path passed to the function was : test.exe sample All 15
The arg(s)found in path 3 were : sample All 15
The path passed to the function was : test.exe
The arg(s)found in path 4 were :
===========