Dark_King
asked on
ShellExecute
Need help with this.
I use ShellExecute to start a .bat file and want to pass variable to it.
Variables is given from dos when I start the program.
It look like this.
ShellExecute(I, 'open', 'c:\command.com', PChar('/c s:\public\homch2.bat '+ ParamStr(1) + ParamStr(2)), nil, sw_hide);
In the bat file it look like this.
renobj %1 %2
Is it the wrong way or wath ????
I use ShellExecute to start a .bat file and want to pass variable to it.
Variables is given from dos when I start the program.
It look like this.
ShellExecute(I, 'open', 'c:\command.com', PChar('/c s:\public\homch2.bat '+ ParamStr(1) + ParamStr(2)), nil, sw_hide);
In the bat file it look like this.
renobj %1 %2
Is it the wrong way or wath ????
Or with '' instead of nil
ShellExecute(I, 'open', PChar('s:\public\homch2.ba t '+ ParamStr(1) + ParamStr(2)), , '' , '', sw_hide);
ShellExecute(I, 'open', PChar('s:\public\homch2.ba
ASKER
[Error] chechd.dpr(35): Expression expected but ',' found
Some thing is wrong here in your examples Epsylon
Some thing is wrong here in your examples Epsylon
ASKER
And a thing it while give me incompatible types 'Integer' and 'PChar'
hi eps :-)
try this
ShellExecute(I, 'open', PChar('s:\public\homch2.ba t '+ ParamStr(1) + ' ' + ParamStr(2)), '' , '', sw_hide);
ShellExecute(I, 'open', PChar('s:\public\homch2.ba
ASKER
I found this, how do I use the lpParameters in my example.
HINSTANCE ShellExecute(
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);
lpFile
Pointer to a null-terminated string that specifies the file to open or print or the folder to open or explore. The function can open an executable file or a document file. The function can print a document file.
lpParameters
If lpFile specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies parameters to be passed to the application.
If lpFile specifies a document file, lpParameters should be NULL.
HINSTANCE ShellExecute(
HWND hwnd, // handle to parent window
LPCTSTR lpOperation, // pointer to string that specifies operation to perform
LPCTSTR lpFile, // pointer to filename or folder name string
LPCTSTR lpParameters, // pointer to string that specifies executable-file parameters
LPCTSTR lpDirectory, // pointer to string that specifies default directory
INT nShowCmd // whether file is shown when opened
);
lpFile
Pointer to a null-terminated string that specifies the file to open or print or the folder to open or explore. The function can open an executable file or a document file. The function can print a document file.
lpParameters
If lpFile specifies an executable file, lpParameters is a pointer to a null-terminated string that specifies parameters to be passed to the application.
If lpFile specifies a document file, lpParameters should be NULL.
Hi meikl (o:
Dark King, also make sure that you use double quotes ("), when command and/or parameters contain spaces.
ShellExecute(I, 'open', PChar('"s:\public\homch2.b at" "'+ ParamStr(1)+'" "'+ParamStr(2))+'"', '' , '', sw_hide);
In most cases I leave lpParameters and lpDirectory empty (='').
Dark King, also make sure that you use double quotes ("), when command and/or parameters contain spaces.
ShellExecute(I, 'open', PChar('"s:\public\homch2.b
In most cases I leave lpParameters and lpDirectory empty (='').
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If that doesnt work then try:
ShellExecute(I, 'Open', PChar('s:\public\homch2.ba t'), PChar(ParamStr(1) + ParamStr(2)), '', SW_HIDE);
ShellExecute(I, 'Open', PChar('s:\public\homch2.ba
ASKER
I try all of your examples and it was close "EPS" but one work right a way and earn the point.
ShellExecute(I, 'open', PChar('s:\public\homch2.ba
nil, sw_hide);