سؤال

I'm a newbie in c++ and trying to use debug apis, but i can't even start. Because i couldn't run any exe by CreateProcess api. It doesn't give any compile error, but does return false. Do you have any suggestions?

LPCWSTR appName = LPCWSTR("C:\\TEST.EXE");
LPSTARTUPINFO sInfo = LPSTARTUPINFO();
LPPROCESS_INFORMATION pInfo = LPPROCESS_INFORMATION();

if (CreateProcess(appName,NULL,NULL,NULL,FALSE,CREATE_SUSPENDED,NULL,NULL,sInfo,pInfo))
{
    printf("done!");
}
else
{
    printf("error!");
}
هل كانت مفيدة؟

المحلول

sInfo and pInfo are not pointing to valid memory (and error code 87 means The parameter is incorrect.). Change to:

STARTUPINFO sInfo = { sizeof(sInfo };
TCHAR desktop[] = TEXT("winsta0\\default");
sInfo.lpDesktop = desktop;
PROCESS_INFORMATION pInfo;

and pass the addresses of the objects to CreateProcess() (i.e. &sInfo, &pInfo).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top