Results 1 to 6 of 6

Thread: Starting external application

  1. #1

    Thread Starter
    Member imj75's Avatar
    Join Date
    Aug 2000
    Location
    South Africa,Pretoria
    Posts
    51

    Post Starting external application

    How do I start an external windows app from VC++? It is a third party app, and not one of the standard win apps like notepad, calculator etc.

  2. #2
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    If you have the file name, you can use either ShellExecute or CreateProcess (the first is easier, the second more powerful)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  3. #3

    Thread Starter
    Member imj75's Avatar
    Join Date
    Aug 2000
    Location
    South Africa,Pretoria
    Posts
    51

    CreateProcess

    I'm using the following code, and get error: Parameter 7 cannot be converted from 'const int' to 'void *'

    if (CreateProcess (
    NULL, //1
    "c:\\Program Files\\Explosive Experts\\RL26DatabaseOptimiser.exe",//*sPath,
    NULL, //3
    NULL, //4
    FALSE,CREATE_NEW_PROCESS_GROUP, //5
    NORMAL_PRIORITY_CLASS, //6
    NULL,//7
    NULL, //8
    NULL))//9

    Any idea what I can do?
    for (int i = 0;i < y3k; i++)
    {
    MakeMeSmarter (andMoreTolerant);
    }

  4. #4

    Thread Starter
    Member imj75's Avatar
    Join Date
    Aug 2000
    Location
    South Africa,Pretoria
    Posts
    51

    CreateProcess not working??

    OK I figured the error out, but now the code compiles, but the "RL26DataBaseOptimiser" is'nt started.

    MSDN isn't helping, so could any member with more C++ experience than me (arguably 99% ) please give me ahand?

    [code]
    if (CreateProcess (
    "RL26DatabaseOptimiser.exe",//NULL, //1
    "c:\\Program Files\\Explosive Experts\\RL26DatabaseOptimiser.exe",//*sPath,
    NULL, //3
    NULL, //4
    FALSE,//5
    DETACHED_PROCESS,//CREATE_NEW_PROCESS_GROUP, //6
    NULL,//NORMAL_PRIORITY_CLASS, // 7
    NULL,//8
    NULL, //9
    NULL))//10
    {
    //close this app
    for (int i = 0;i < y3k; i++)
    {
    MakeMeSmarter (andMoreTolerant);
    }

  5. #5

    Thread Starter
    Member imj75's Avatar
    Join Date
    Aug 2000
    Location
    South Africa,Pretoria
    Posts
    51

    CreateProcess

    OK, how do I use the structs? I'm new to C++ so IV tried the following without success
    Code:
    iResult = MessageBox(NULL,"Tester must be closed for Database optimising.  Do you want shut Tester down now?",
    					  "Close Tester?",MB_YESNO | MB_ICONQUESTION );
    
    	typedef struct _STARTUPINFO { // si 
        DWORD   cb; 
        LPTSTR  lpReserved; 
        LPTSTR  lpDesktop; 
        LPTSTR  lpTitle; 
        DWORD   dwX; 
        DWORD   dwY; 
        DWORD   dwXSize; 
        DWORD   dwYSize; 
        DWORD   dwXCountChars; 
        DWORD   dwYCountChars; 
        DWORD   dwFillAttribute; 
        DWORD   dwFlags; 
        WORD    wShowWindow; 
        WORD    cbReserved2; 
        LPBYTE  lpReserved2; 
        HANDLE  hStdInput; 
        HANDLE  hStdOutput; 
        HANDLE  hStdError; 
    } STARTUPINFO, *LPSTARTUPINFO; 
     //STARTUPINFO lpStartInfo;
    
    	switch (iResult)
    	{
    		case IDYES: // The Yes button?
    			if (CreateProcess (
    					"c:\\Program Files\\Explosive Experts\\RL26DatabaseOptimiser.exe",//"RL26DatabaseOptimiser.exe",//NULL, //1
    	NULL,//2
    	NULL, //3
    	NULL, //4
    	FALSE,//5
    	DETACHED_PROCESS,//CREATE_NEW_PROCESS_GROUP, //6
    	NULL,//NORMAL_PRIORITY_CLASS,  // 7
    	"c:\\Program Files\\Explosive Experts",//NULL,//8
    	GetStartupInfo(LPSTARTUPINFO&),//NULL, //9
    	NULL))//10
    for (int i = 0;i < y3k; i++)
    {
    MakeMeSmarter (andMoreTolerant);
    }

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Go to the tutorials (top of page) and read some basic C++ tutorial. You seem to need it.
    You only need to define the struct once, and in case of STARTUPINFO it is already defined in windows.h (actually winnt.h or wincore.h or something like that). Once a struct us defined, you can create an object like this:
    STARTUPINFO si;
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width