Solved

Lunch exe program

Posted on 2004-09-20
2
1,074 Views
Last Modified: 2013-11-20
Can anyone help me to write C++ code to lunch exe program from SAMBA server?
0
Comment
Question by:tthawee
2 Comments
 

Accepted Solution

by:
l3st4rd earned 50 total points
ID: 12107956
what u mean: "lunch exe program from SAMBA server" ? the program resides on a connected network drive?
if so you only need to call CreateProcess(...).

CString pathName;
pathName = YourProgramPath;
STARTUPINFO startup;   //structure containing information on how to start the program
PROCESS_INFORMATION procinfo;   //this will receive information on the newly created process

::ZeroMemory(&startup, sizeof(startup));  //clear startup structure

startup.cb = sizeof(startup);   //size of this structure
startup.dwFlags = STARTF_USESHOWWINDOW;    //use wShowWindow flag
startup.wShowWindow = SW_SHOW;    //show the window in normal state
pathName = "\"" + pathName + "\"";     //include the pathname into quotation marks to deal with spaces in pathnames

LPSTR cmd = ClientCmd.GetBuffer(ClientCmd.GetLength() + 1);
if (CreateProcess(NULL, //name of application already contained in lpCommandLine parameter
                         cmd,   //lpCommandLine = full / relative path of program + parameters
                         NULL,  // }
                         NULL,  // } no security attributes for thread as well as process
                     false,  //the new process should not inherit any handles from the calling process
                         0,       //we specify no creation flags
                         NULL,  //new process runs in same environment as calling process
                         NULL,  //the current drive+directory of the new process will be the same like the one of the calling process
                         &startup,  //our startup information
                         &procinfo)   //this will receive information on the new process
                         == 0) {   //return value 0 means error:
// add an error handler here if execution failed
}

have a look for CreateProcess function in MSDN for more info.

daniel.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
string initialization in java 11 115
FizzBuzz challenge 9 82
Not needed 13 119
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question