Use ShellExecute
Main Topics
Browse All TopicsI am using BC452 and wrote some code that should start GNUPlot with a plot file. I give the full path for the program and the full path for the plot file. When I start to run this the first time GNUPlot does not start. After I execute a FileOpenSelectBox to choose a plot file it works fine. It seems like it needs some directory information that is not initialy there. How can I get this to work?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Obviously I tried this one already, but I get the same problem using ShellExecute(). The path names are definitely correct, since it works once the OpenSelectBox was called once. Otehr tahn this it would be nice if I could see a working ShellExecute() sample. The one in the online help is not quite understandable.
Business Accounts
Answer for Membership
by: amauPosted on 1999-11-22 at 21:00:45ID: 2227286
here the code I use for the select box and the aplication to run.
tePlt() READONLY|O FN_OVERWRI TEPROMPT| t Files (*.plt)|*.plt|All Files (*.*)|*.*|"); );
tion()->Ma inWindow, FileData).Execute();
nuplot.exe ";
2)) ow(), msgBoxText.c_str(), msgBoxTitle.c_str(), MB_OK);
rofTemp() Window(),
nuplot.exe data\\TempSimu.plt";
2)) ow(), msgBoxText.c_str(), msgBoxTitle.c_str(), MB_OK);
//
// Execute *.plt files
//
void TFEMWorkMDIClient::CmExecu
{
FileData.Flags = OFN_FILEMUSTEXIST|OFN_HIDE
OFN_SHAREAWARE;
FileData.SetFilter("GNUPlo
FileData.InitialDir = (char *)Settings.DataPath.c_str(
int but = TFileOpenDialog(GetApplica
if(but==IDOK)
{
string cmdLine;
string msgBoxTitle;
string msgBoxText;
// cmdLine = "C:\\Progra~1\\Gnuplot\\WG
cmdLine = Settings.PlotPath + Settings.PlotApp;
cmdLine += " "; // separator
cmdLine += FileData.FileName;
int result = WinExec(cmdLine.c_str(), SW_SHOWNORMAL);
if((result>=0)&&(result<=3
{
switch (result)
{
case 0: msgBoxTitle = "ERROR: Out of memory"; break;
case 2: msgBoxTitle = "ERROR: File not found"; break;
case 3: msgBoxTitle = "ERROR: Path not found"; break;
default: msgBoxTitle = "ERROR: Error in WinExec"; break;
}
msgBoxText = "Command line:\n";
msgBoxText += cmdLine;
::MessageBox(GetActiveWind
}
}
}
//
// Run the GNU Plot for Profile
//
void TFEMWorkMDIClient::CmAnimP
{
int but=::MessageBox(GetActive
"Animate Temperature Profile?",
"Run GNUPlot", MB_OKCANCEL);
if(but==IDOK)
{
string cmdLine;
string msgBoxTitle;
string msgBoxText;
// cmdLine = "C:\\Progra~1\\Gnuplot\\WG
cmdLine = Settings.PlotPath + Settings.PlotApp;
cmdLine += " "; // separator
cmdLine += Settings.MeshPltPath + "TempSimu.plt";
int result = WinExec(cmdLine.c_str(), SW_SHOWNORMAL);
if((result>=0)&&(result<=3
{
switch (result)
{
case 0: msgBoxTitle = "ERROR: Out of memory"; break;
case 2: msgBoxTitle = "ERROR: File not found"; break;
case 3: msgBoxTitle = "ERROR: Path not found"; break;
default: msgBoxTitle = "ERROR: Error in WinExec"; break;
}
msgBoxText = "Command line:\n";
msgBoxText += cmdLine;
::MessageBox(GetActiveWind
}
}
}