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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using ShellExecute(.....

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
Hey all!!

I am using the ShellExecute command......
Why doesn't using "notepad.exe fil.txt" work??

//-------- Sample code
#include <shellapi.h>

ExecuteFile(&quot;notepad.exe fil.txt&quot;,&quot; &quot;, &quot;C:\\[Full_Path]&quot;, SW_SHOWMINIMIZED);


int __fastcall ExecuteFile(const AnsiString FileName,
const AnsiString Params,
const AnsiString DefaultDir,
int ShowCmd)
{

char zFileName[79], zParams[79], zDir[79];
return (int) ShellExecute(Application->MainForm->Handle,
NULL,
strcpy(zFileName,
FileName.c_str()),
strcpy(zParams,
Params.c_str()),
strcpy(zDir,
DefaultDir.c_str()),
ShowCmd);
}

Martin G Broman
mgb_svea@hotmail.com

DWS - Alpha Whitin Dead Wolf Society
 
Have you tried some of the obvious(?) tests? Can you get ShellExecute to work if you put literals in instead of variables? Are the variables (zFileName, ZParams, etc.) correct?

James P. Cottingham
 
I have been unable to find any solution....
When I enter only 'notepad.exe' it will launch it, when I enter 'fil.txt' it will open that file in the program associated with .txt files, which for me is &quot;UltraEdit 32&quot;!!
It doesn't matter whether I user Variables or not...

It's all so strange..
Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
 
Bizarre. Obviously there is something we are missing. If I get a change I'll see what I can find, meanwhile, don't give up.
James P. Cottingham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top