我收到错误代码 2,找不到文件。但是我已经尝试过完整的路径并且没有。我没有运气开始这个过程,我不知道我的错误是什么,有人可以指出吗?
这是完整的代码:
#include "stdafx.h"
#include <map>
#include <psapi.h>
#include "shlwapi.h"
#define ERROR_FILE_NOT_FOUND = 2;
void Debug(char* path[])
{
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
char* p = path[0];
char* args = path[1];
int dwProcess = CreateProcess((LPCWSTR)p, (LPWSTR)args, NULL, NULL, false, DEBUG_ONLY_THIS_PROCESS, NULL, NULL, &si, &pi);
if (!dwProcess)
{
DWORD dwLastErrorCode = GetLastError();
printf("Error: %d", dwLastErrorCode);
}
DEBUG_EVENT debug_event = {0};
DWORD dwContinueStatus = DBG_CONTINUE;
DWORD dwResume = DBG_EXCEPTION_HANDLED;
while (!WaitForDebugEvent(&debug_event, INFINITE))
{
switch(debug_event.dwDebugEventCode)
{
case EXCEPTION_DEBUG_EVENT:
{
EXCEPTION_DEBUG_INFO& exception = debug_event.u.Exception;
if (exception.ExceptionRecord.ExceptionCode == 0x0EEDFADE && exception.dwFirstChance)
dwContinueStatus = dwResume;
}
}
ContinueDebugEvent(debug_event.dwProcessId, debug_event.dwThreadId, dwContinueStatus);
}
}
int main(char* argv[])
{
char* p[2] = { "Notepad.exe", "args" };
Debug(p);
return 0;
}
任何帮助表示赞赏。