Solved

Using an exising *.exe file in my project

Posted on 1998-10-28
19
133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

751 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