Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to use shellexecute?

Status
Not open for further replies.

kaya17

Programmer
Feb 9, 2004
78
SG
i have a funtion as below:

void CCommandDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
AfxMessageBox(m_ipstart);
AfxMessageBox(m_ipend);
CString parameter;
parameter = "ipscan" + m_ipstart + " " + m_ipend + "text8.txt";

ShellExecute (NULL, "Open", "C:\WINDOWS\Desktop\Ipscan.exe", parameter, "C:\WINDOWS\Desktop", SW_MAXIMIZE);
CDialog::OnOK();
}

the command to launch my application is:
ipscan 192.33.15.2 192.33.15.6 text8.txt

i run the program in windows2000, but the application is not launched, who can help me to figure it out? thanks a lot!!!!

regards
kaya
 
*************************************************************
try to do it like this:
Code:
ShellExecute (NULL, "Open", "C:/WINDOWS/Desktop/Ipscan.exe", 
	parameter, "C:/WINDOWS/Desktop",  SW_MAXIMIZE);
 
May be, you forget: backslash in C/C++ string literals is an escape character. You must write it twice: "C:\\Windows...", not "C:\Win...".
 
YEAH!!!!!!!!!!
THANKS A LOT!
the "/" works!!!!:)
 
Better is to use CreateProcess insetad of ShellExecute

Ion Filipski
1c.bmp
 
Why is it considered better to use CreateProcess instead of ShellExecute?
 
ShellExecute returns a value what is not a true hinstance of a process. So you can not use it to wait until termination or to close that process. Moreover, it is a simulation of anything what you can do with doubleckick on windows explorer or type in cmd line. Would be very interesting, how will you use results of execution... For example the process terminated with error.. Let's imaginate, you create an install programm and to install you should call the installer of other program and after that install yours. The instalation of first one failed... How will you handle this situation? Or you know what if instalation is more than 10 sec(for example) the instalation hangs up and you should abort instalation... You will be able only to use CreateProcess where.

Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top