我需要能够分裂的命令的可执行文件路径和参数。
I need to be able to to split the executable path and arguments in a command.
Windows处理易如下:
Windows handles the following easily:
的notepad.exe C:\ TESTFILE.TXT
"notepad.exe C:\testfile.txt"
记事本C:\ testfolder \ versioninfo.txt
"notepad c:\testfolder\versioninfo.txt"
C:\ WINDOWS \ NOTEPAD.EXEC:\ test文件夹\ versioninfo.txt
"C:\Windows\notepad.exe" "C:\test folder\versioninfo.txt"
RUNDLLC:\的Windows \ somelibrary.dll
rundll "C\Windows\somelibrary.dll"
任何人有一张code解析这些字符串?
Anyone has a piece of code to parse such strings?
感谢。
我用这样的事情在过去的:
I've used something like this in the past:
char* lpCmdLine = ...;
char* lpArgs = lpCmdLine;
// skip leading spaces
while(isspace(*lpArgs))
lpArgs++;
if(*lpArgs == '\"')
{
// executable is quoted; skip to first space after matching quote
lpArgs++;
int quotes = 1;
while(*lpArgs)
{
if(isspace(*lpArgs) && !quotes)
break;
if(*lpArgs == '\"')
quotes = !quotes;
}
}
else
{
// executable is not quoted; skip to first space
while(*lpArgs && !isspace(*lpArgs))
lpArgs++;
}
// TODO: skip any spaces before the first arg
上一篇:[机器人 - 奇巧]获取/选择从Android的图像内置库的应用程序编程奇巧、机器人、应用程序、图像
下一篇:PhoneGap的Android的LocalFileSystem没有定义定义、Andr、PhoneGap、LocalFileSystem