在使用ShellExecute来启动一个新程序并要给程序传递参数时,直接写参数,发现执行时,总是出现ERROR_FILE_NOT_FOUND, 很让人疑惑。后来,就按照MSDN中的ShellExecute的API说明,使用char型或TCHAR型参数,在ShellExecute就可以正常启动程序了。而使用CString类作为参数传递,也不能正常启动程序。
MSDN 中ShellExecute的原型:
HINSTANCE ShellExecute(
HWND hwnd,
LPCTSTR lpOperation,
LPCTSTR lpFile,
LPCTSTR lpParameters,
LPCTSTR lpDirectory,
INT nShowCmd
);
在MSDN中,有一篇文章说ShellExecute的,http://support.microsoft.com/?kbid=837633,“Errors in Windows XP applications that start by using the ShellExecute() ”.