Solved

Using an exising *.exe file in my project

Posted on 1998-10-28
19
128 Views
Last Modified: 2012-05-04
How to use arj.exe in the project. Or how to use MS Dos prompt in project.

In general How to use dos executables in delphi projects
0
Comment
Question by:K_David
  • 8
  • 6
  • 4
  • +1
19 Comments
 

Author Comment

by:K_David
ID: 1344833
Thanx for yours answers
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344834
try this: ( drop a button in the form )

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ShellApi, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(0,'open','arj.exe','a ArjFile.arj','c:\',SW_SHOWNORMAL);
end;

end.

0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344835
How to use it in a program:

include     SHELLAPI       in the USES clause;
then:

ShellApi(Handle,operation,File name,parameters,directory to work in,show mode);

Handle: I don't know, but with 0 it works
operation: OPEN and PRINT
    use OPEN to execute a program and PRINT to print a file, such as Readme.Txt
Parameters: paramaters..
Direc.. : the location where the program is
Show Mode: there are some ( Look at Delphi Help )
 ( no make the Ms-Dos box not visible, use SW_HIDE )


hope it helps.

bryan =)

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344836
You could also use CreateProcess() which is easier when working with MS-DOS... Also you could use WinExec() which is not the best choice

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344837
??
CreateProcess ???
WinExec ???

How do I use them ?

bryan

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344838
Read some Delphi help.... If you can't figure it out by yourself, I'll write some examples for you..

Cheers,
Viktor
0
 

Author Comment

by:K_David
ID: 1344839
Thank you Bryan7 - i've allready figuret out by myself.
Here a piece of advise for u:
for hwhandle - u set it to 0 - instead u should use following:SW_SHOWNORMAL

thanx
0
 

Accepted Solution

by:
smartass earned 20 total points
ID: 1344840
to use DOS execute files in project:
include a batch file and simply type the file name in the Batchfile editor
then you you put this line under a tbutton
ShellExecute(0,'open',my.bat','nil','c:\',SW_SHOWNORMAL);
dont forget to add the SHELLAPI in the USES claus
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344841
smartass: did u read all the comments ?

k_david: ??? SW_SHOWNORMAL is not the hwhandle..

bryan

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:K_David
ID: 1344842
i'd like more Bryan7 answer!!
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344843
?? if you liked more my answer... why did you accept smartass answer ?

bryan

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344844
bryan deserved the points.
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344845
well, I don't care about the points.
it's only that I don't understand why he/she choosed the other one.

bryan

ps: viktor: what's the hwHandle for ? I mean, the place where i put 0

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344846
It's for the handle.... When you use ShellExecute() the hwHandle is usually set to 0...

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344847
but, what can I use it for ?

bryan

0
 

Author Comment

by:K_David
ID: 1344848
To bryan7: I'm new to this kind of html quesioning...
so i'm sorry  - i really mean it, when i rejected an answer - i had allredy figure it out; but here u hafta accept one answer (i shoul accept yours - ) but i didn't know that back then

I'll avt more reasonable in  the future (if this had any meaning...)

About handle - the first handle (i put value SW_SHOWNORMAL). I think it controlls your Main Form - window from where are u calling dos exe programm.

Sorry about the points Bryan7 (Give other a chance)

Bye - K.David

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344849
K.David...

You don't use SW_NORMAL to control the main form and all that crap... SW_NORMAL is not a handle it's simply a windows defined constant that is used when showing windows.... e.g.

ShowWindow(TheHandle, SW_NORMAL);

SW_NORMAL is the same as SW_SHOWNORMAL

Cheers,
Viktor
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1344850
K.David: don't worry about the points. My goal here is to get and give help.
( though I get more than I give.. =)   )

Glad to help you and hope to get some advice from you too, I'm also new at delphi.

bryan =)

viktor: what can I use the hwhandle for ?

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1344851
Already told you... Take a look at the Win32.hlp file and see the paraemeters... You just set it to 0 and everything would be fine... 0 is the handle of the Desktop usually..

Cheers,
Viktor
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now