hta prcess launch faling [英] hta prcess launch faling
问题描述
这是我的代码
This is my code
STARTUPINFO info={sizeof(info)};
PROCESS_INFORMATION processInfo;
if (CreateProcess(L"c:\\Windows\\System32\\mshta.exe", L"c:\\1.hta", NULL, NULL, TRUE, 0, NULL, NULL, &info, &processInfo))
{
::WaitForSingleObject(processInfo.hProcess, INFINITE);
CloseHandle(processInfo.hProcess);
CloseHandle(processInfo.hThread);
}
1.hta是我的流程。
使用上面的代码我尝试启动但是只在mshta.exe中启动它。
如果我使用cmd线运行
1.hta is my process.
using above code i try to launch but its launchin mshta.exe alone.
if i run using cmd line
c:\\Windows\\System32\\mshta.exe c:\\1.hta
工作正常。
任何人都可以帮我这个..?
Its working.
can any one help me on this..?
推荐答案
你打电话给CreateProcess
传递Unicode字符串。根据您的Unicode项目设置,将调用CreateProcessA
或CreateProcessW
,您应该使用<$ c传递字符串参数$ c> _T()宏而不是使用Unicode字符串的L
前缀。
因为您使用L
前缀,我假设您的项目是Unicode。那么第二个参数必须不是常量字符串。请参阅 CreateProcess [ ^ ]在MSDN中:
You are callingCreateProcess
passing Unicode strings. Depending on your Unicode project settings,CreateProcessA
orCreateProcessW
will be called and you should pass string parameters using the_T()
macro rather than using theL
prefix for Unicode strings.
Because you use theL
prefix, I assume that your project is Unicode. Then the second parameter must be not a constant string. See CreateProcess[^] in the MSDN:
此函数的Unicode版本CreateProcessW可以修改此字符串的内容。因此,此参数不能是只读内存的指针(例如const变量或文字字符串)。如果此参数是常量字符串,则该函数可能会导致访问冲突。
The Unicode version of this function, CreateProcessW, can modify the contents of this string. Therefore, this parameter cannot be a pointer to read-only memory (such as a const variable or a literal string). If this parameter is a constant string, the function may cause an access violation.
您还应初始化 STARTUPINFO
和 PROCESS_INFORMATION
结构在调用 CreateProcess
之前:
You should also initialise the STARTUPINFO
and PROCESS_INFORMATION
structures before calling CreateProcess
:
::ZeroMemory(&info, sizeof(info));
::ZeroMemory(&processInfo, sizeof(processInfo));
info.cb = sizeof(info);
// Add optional info here
//info.dwFlags = STARTF_USESHOWWINDOW; // wShowWindow contains show state
//info.wShowWindow = SW_SHOW; // show the program
这篇关于hta prcess launch faling的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!