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

ShellExecute not passing the parameters 1

Status
Not open for further replies.

krushpof

Programmer
Jul 4, 2003
72
CA
I call a VB exe through a service made in delphi.But i do not receive the parameters i am supposed to be transfering.When i make the call with the command prompt,the exe receive the param no problem.What could be the problem...i wonder!!!

param:='TagExe'+inttostr(cptrexe+1);
exe:=PIserver.PIModuleDB.PIModules[Plant].PIProperties['Exe'].PIProperties['Exe'+inttostr(cptrexe+1)].Value;
ShellExecute(0,'Open',Pchar(exe),Pchar(param),'',SW_SHOWNORMAL);

Thank you!
 
First off, use a 'nil' or '0' for the directory instead of an empty string.

Next, you can test your code by writing a tiny console application that simple puts up a dialog with the command arguments:
Code:
program StartupTest;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  Dialogs;

var
   Counter : Integer;
   ThisMessage : String;
begin
   for Counter := 1 to ParamCount do
       ThisMessage := ThisMessage + #13#10 + ParamStr(Counter);

   ShowMessage('Application ' + ParamStr(0) + ' called with these parameters:' + ThisMessage); 
end.

At least you will know for sure what your applications are receiveing.

Cheers
 
I will try that as soon as i can.

Thank you for your help!
 
Well, i don't seem to transfer anything.I even hardcoded a parameters to see.Nothing.Is the fact that the caller it is a services can have this kind of impact?

Thank you!
 
Looks like the problem is due to services.If i try this call with a standard exe i get the param no problems.

Thank you for your help richardchaven
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top