Join 306,819 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,718 people online right now. Registration is fast and FREE... Join Now!
hello I am new in c++ I have problem with CreateProcess when I use it in my project an exception stop my program exception: ------------------------------------ Unhandled exception at 0x7c825352 in test.exe: 0xC0000005: Access violation writing location 0x00403658. -------------------------------------
and then print in output window(in visual C++ IDE): --------------------------------------------------- 'test.exe': Loaded 'D:\WINDOWS\system32\ntdll.dll', No symbols loaded. 'test.exe': Loaded 'D:\WINDOWS\system32\kernel32.dll', No symbols loaded. 'test.exe': Loaded 'D:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.42_x-ww_f75eb16c\msvcr80d.dll', No symbols loaded. 'test.exe': Loaded 'D:\WINDOWS\system32\msvcrt.dll', No symbols loaded. ---------------------------------------------------- any one can help me! thanks
thanX for your helps but I cant fix that this statement (CreateProcess)is very complex
say you have a program tracert.cpp - build it
CODE
#include <iostream.h> #include <string.h>
//----------------------------------------------------------------------------// // function main with parameters // // argc - number of elements in array argv // // argv - an array of pointers to strings // int main(int argc, char *argv[]) { cout << "\ntracert - number of parameters in command line is " << argc; for (int index = 0; index < argc; index++) { cout << "\n parameter " << index << " is " << argv[index]; } cout << endl; return 0; }
and you run
CODE
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <windows.h> #pragma comment (lib, "Ws2_32.lib" ) #pragma comment (lib, "Kernel32.lib" ) int main( VOID ) { STARTUPINFO si; PROCESS_INFORMATION pi; int spi=sizeof(pi); int ssi= sizeof(si); ZeroMemory( &si, sizeof(si) ); si.cb=sizeof(STARTUPINFO); //sizeof(si); ZeroMemory( &pi, sizeof(pi) ); int b=0; printf( "\nCalling CreateProcess \n" ); // Start the child process. b=CreateProcess("tracert.exe ", "-d www.yahoo.com" , // Command line. NULL, // Process handle not inheritable. NULL, // Thread handle not inheritable. 0, // Set handle inheritance to FALSE. NORMAL_PRIORITY_CLASS, // No creation flags. NULL, // Use parent's environment block. NULL, // Use parent's starting directory. &si, // Pointer to STARTUPINFO structure. &pi ); if( b==0) // Pointer to PROCESS_INFORMATION structure.
yes I did it!(copy-paste) I think this code have a problem in pointers. I am java programmer and in java we have pointers like in c++ thanX for your helps