|
-
September 6th, 2001, 04:01 AM
#1
running exe
I am wanting to run various different executable files when items are clicked in a list box control. How do I run an external exe file from within an application?
Regards
Tom
-
September 6th, 2001, 04:43 AM
#2
Re: running exe
You can use the Shell command
' start notepad
Shell "c:\windows\notepad.exe"
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
September 6th, 2001, 04:57 AM
#3
Re: running exe
Shell is alright unless you want to know when the program has finished.
You could try the following which will wait for the process to finish before continuing. Apologies for the source being in C++ but it should be easy to convert to VB.
int CALLBACK ExecCmd(char cCmdLine[])
{// Execute a command and wait for it to finish (Create a modal thread)
//
// Local variables
//
// si : Startup information
// pi : Process information
STARTUPINFO si;
PROCESS_INFORMATION pi;
// Zero startupinfo structure
ZeroMemory(&si, sizeof(STARTUPINFO));
// Initialise startupinfo structure
si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USEPOSITION | STARTF_USESIZE;
// Create process (i.e. run the required command)
CreateProcess(NULL, cCmdLine, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
// Wait for process to end
WaitForSingleObject(pi.hProcess, INFINITE);
// Close process handle
CloseHandle(pi.hProcess);
return TRUE;
}
Hope this helps
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|