How can I run explorer.exe through C ++?

I am trying to programmatically launch explorer.exe, but I was out of luck.

This is my code:

cout << pName << "died, lets restart it." << endl;
STARTUPINFO startupInfo = {0};
startupInfo.cb = sizeof(startupInfo);

PROCESS_INFORMATION processInformation;

if(CreateProcess(pName, NULL, NULL, NULL, false, NORMAL_PRIORITY_CLASS, NULL, NULL, &startupInfo, &processInformation) == 0){
    cout << "Error starting " << pName << ": " << GetLastError() << endl;
}

and pName - explorer.exe

Can someone tell me what I'm doing wrong? I get the error code '2', whichERROR_FILE_NOT_FOUND

+5
source share
3 answers

The first parameter is the name of the application; the second is the command line. Try specifying "explorer.exe" as the second parameter.

See the MSDN article :

lpApplicationName [in, optional]

. Windows . - (, MS-DOS OS/2), .

. , . . ; .

+4

, " ShellExecuteEx" . , , . "explore" , Windows .

+3

, Windows Explorer. 64- Windows 7/8 ShellExecute , .

, , stdlib.h:

system("start explorer");

, AutoRestartShell, , .

0

All Articles