Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CreateProcess - Unhandled exception??

Status
Not open for further replies.

pilgie

Technical User
May 2, 2006
16
GB
Hi all,

When running the following I recieve an unhandled exception error - I am running against the Unicode character set, could this be causing the error?

SECURITY_ATTRIBUTES sa = { sizeof(SECURITY_ATTRIBUTES) };
sa.bInheritHandle = TRUE;
sa.lpSecurityDescriptor = NULL;

HANDLE hStdoutRd, hStdoutWr, hStdinRd, hStdinWr;

CreatePipe (&hStdoutRd, &hStdoutWr, &sa, 0);
SetHandleInformation(hStdoutRd, HANDLE_FLAG_INHERIT, 0);
CreatePipe (&hStdinRd, &hStdinWr, &sa, 0);
SetHandleInformation(hStdinWr, HANDLE_FLAG_INHERIT, 0);

STARTUPINFO si = { sizeof(STARTUPINFO) };
PROCESS_INFORMATION pi;
si.dwFlags = STARTF_USESTDHANDLES;
si.hStdOutput = hStdoutWr;
si.hStdInput = hStdinRd;

if(!CreateProcess (NULL, (LPWSTR)"c:\php\php-cgi.exe", NULL, NULL, TRUE,CREATE_UNICODE_ENVIRONMENT | NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))
{
printf( "CreateProcess failed (%d)\n", GetLastError() );
}
I recieve an unhandled exception:

Unhandled exception at 0x00479986 in WebserverTest.exe: 0xC0000005: Access violation reading location 0x00000274.

Any ideas as to what this could be?

Help appreciated - cheers people!
 
> (LPWSTR)"c:\php\php-cgi.exe"
Well simply casting the string to make the compiler shut up about something isn't the way to go.

1. If you're using UNICODE, then use the TEXT macros (and other things) which are designed to smooth the portability between ASCII and UNICODE.
2. You forgot to double up all your \\ in the pathname.
3. Please use [code][/code] tags when posting code.

Eg.
Code:
if ( !CreateProcess (NULL, TEXT("c:\\php\\php-cgi.exe"), NULL, NULL, TRUE,CREATE_UNICODE_ENVIRONMENT | NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi))


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top