• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Emdedding an app within Delphi application

I will like to include an .exe application to be run within my D3 application.  Please help!
0
Ogunbo
Asked:
Ogunbo
1 Solution
 
ZifNabCommented:
Hi Ogunbo,

 What do you exaclty want :

 Starting .exe from delphi program and receiving the error-codes? or ?...
 Zif.
0
 
mayhewCommented:
If you want to run another .exe from your Delphi app you might be wanting to use the Win API call CreateProcess (for 32 bit apps - the 16 bit version was WinExec).

The description is in the Win32s.hlp file.

Be sure to include windows in your uses clause.  And you can see the Pascal function declaration in \source\rtl\win\windows.pas.  (My apologies if you already know this).
0
 
kashif063098Commented:
Two  ways

1--using Winexec()
Example
fucntion AnyFunction:integer;
VAR
 appName:string;
 RESULT:integer
begin
 appName:=ApplcationPath; {C:\PKZIP.EXE}
 RESULT:=WinExec(appName,SW_SHOWNORMAL);
 IF RESULT > 31 THEN {if RESULT < 31 then there is some problem uses GetLastError                                     to find the reason}
 ShowMessage('Its ok,it should run the application' );

end;

2--Using CreateProcess() Win32 Api

function AnyFunction:integer;
begin
 CreateProcess(
                       {1}  PChar('C:\pkzip.exe'),  
                       {2}  PChar('c:\Pkzip.exe '+  'c:\z\z1.zip ' + FileToZip),
                       {3}  NIL,
                       {4}  NIL,
                       {5}  False,
                       {6}  0{CREATE_NEW_CONSOLE},
                       {7}  NIL,
                       {8}  PChar('C:\'),
                       {9}  lpStartupInfo,
                       {10} lpProcInformation) ;

end;

If you feel any difficulty in order to follow these examples ,let me know


bye


kashif
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
kashif063098Commented:
In second example use your application names and path.if CreateProcess() returns -1 uses GetLastError function to find out the reason of the failure
0
 
vladikaCommented:
Also you can use ShellExecute, ShellExecuteEx

0
 
ZifNabCommented:
Still, we don't know exactly what Ogunbo wants.
0
 
OgunboAuthor Commented:
Thank you all folks.  I will appreciate a real example of what the source should look like.  I have a database application made in D3 and I used another program to create an exe file.  Actually, this exe.file is an expert system that uses the same table as my database.  Since I couldn't program an expert system in Delphi, I am wondering if I can use the already made expert system (.exe file) in my database application.  Such that a user of the database might click a button called "expsys" for the expert system to be run.  In a way it would look like I am using D3 as an interface for the expert system.  Well, this is my problem and will appreciate what my unit should look like.  Thank you.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now