您的位置:首页 > 其它

关于msdn中CreateProcess函数说明的注释

2012-11-20 17:43 344 查看
msdn中CreateProcess函数关于lpApplicationName参数的说明里面有这么一段话

The string can specify the full path and file name of the module to execute or it can specify a partial name. In the case of a partial name, the function uses the current drive and current directory to complete the specification. The function will not use the
search path. If the file name does not contain an extension, .exe is assumed. Therefore, if the file name extension is .com, this parameter must include the .com extension. [1]

但是实际测试表明并不会有默认的.exe的扩展名的

#include <windows.h>

int main()
{
STARTUPINFO si = { 0 };
si.cb = sizeof(STARTUPINFO);
PROCESS_INFORMATION pi = { 0 };
CreateProcess(L"D:\\a.exe",NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);	// 成功
//CreateProcess(L"D:\\a",NULL,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);	// 不成功

CloseHandle(pi.hProcess);
return 0;
}


[1]ms-help://MS.MSDNQTR.v90.en/dllproc/base/createprocess.htm

[2]测试环境:windows xp sp2 + vs2008 sp1
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: