Hi everybody!

I am having some trouble running a detached process using CreateProcess function in C++.

I have been using the following function to spawn processes in c++ for years now havnig no trouble. I have used it with console applications, mfc apps, dialog based ... etc :

StartProc(char *callprogram, bool blshow)
        //callprogam = full path to executable
        //blshow = show or hide application's window
         STARTUPINFO startInfo;
         PROCESS_INFORMATION procInfo;
         DWORD       creationFlags;
         startInfo.cb = sizeof(STARTUPINFO);
         startInfo.lpReserved = NULL;
         startInfo.lpDesktop = NULL;
         startInfo.lpTitle = NULL;
         startInfo.dwFlags = STARTF_USESHOWWINDOW;
         if (blshow==true) startInfo.wShowWindow = SW_SHOW;
                 else startInfo.wShowWindow = SW_HIDE;
         startInfo.cbReserved2 = 0;
         startInfo.lpReserved2 = NULL;
        if( !CreateProcess(NULL,callprogram, NULL, NULL, TRUE, 
        creationFlags, NULL, NULL, &startInfo, &procInfo) )
            AfxMessageBox("Process create failed",MB_ICONERROR, NULL);

For the first time i have trouble executing a java application which is wrapped to an executable using jsmooth.
CreateProcess returns no errors but the java app exits immediately after creation.

The java application is a fullscreen application using Java OpenGL wrapper.

I messed around with dwFlags and creation flags but no luck...

Any advice?
Thanks in advance.

4 Years
Discussion Span
Last Post by ktsangop

Ohhh shooot...
Just figured it out! Always do, a couple of minutes after i post...

I had to change the current working directory, or else the java app cannot find the java libraries etc...

Just Added : SetCurrentDirectory("c:\mypath\etc\");
and problem solved...

Thanks and sorry for the waste of bytes..

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.