Solved

Accessing DOS commands in DELPHI 3

Posted on 1998-09-13
11
518 Views
Last Modified: 2012-06-21
In Delphi 3...how would I perform an XCOPY?

For example how would I do the following:

c:\> xcopy32 c:\source\*.*  g:\dest /e /q

I have been able to find little to no help on DOS COMMANDS in Delphi 3.  There must be a way to do this.

Thanks,

Tom
0
Comment
Question by:Tom Knowlton
[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
11 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 1339602
knowIton,

do you want to execute the dos xcopy program? Then just use winAPI ShellExecuteEx(...) or CreateProcess(...). There's no complete winAPI that does something like xcopy.
But you could several APIs to program it (FindFirstFile, CopyFile, CreateDirectory, ...).

Regards, Madshi.
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339603
Use this.....
             param1 : String;
             paramExt : String;
         begin
           if ParamCount >= 1 then
             begin
               param1 := UpperCase(ParamStr(1));
               paramExt := ExtractFileExt(param1);
             end;
           if (ParamCount < 1) or
              (ParamCount > 2) or
              ((ParamCount = 2) and (UpperCase(ParamStr(2)) <> '/E'))
//do something
Take this as an example......            
Use ParamStr()
and
ParamCount
to take input from DOS

if Pos('\e', PramStr(1)) then
//do something

Regards,
Viktor Ivanov
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1339604
Viktor:

I'm not looking to handle command-line parameters....I want to execute ACTUAL DOS commands after my program has started.

Madshi:

I think you're on the right track...but I need a complete example...one I can drop in my code and use right away.

Thanks!

Tom
0
Independent Software Vendors: 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

Accepted Solution

by:
viktornet earned 20 total points
ID: 1339605
Here is some code.....
------------
var
  SI : TStartUpInfo;
  PI : TProcessInformation;
begin
  FillChar(SI, sizeof(SI), 0);
  SI.cb := sizeof(SI);
  CreateProcess(nil, 'C:\windows\command\xcopy32 c:\source\*.*  g:\dest /e /q ',
    nil, nil, False, 0, nil, nil, SI, PI);
end;
------------
Regards,
Viktor Ivanov
0
 
LVL 1

Expert Comment

by:BlackDeath
ID: 1339606
do you want to write an algorithm in delphi doing the same as xcopy (2nd part of madshi's) or start your app, execute a dos box running xcopy32 parametrized as shown above, and return to your app (if the latter, return immediately or wait for execute?) ?

Black Death.
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1339607
Viktornet:

Your reply was exactly what I was looking for.

Thanks!

BlackDeath - Yeah, I wanted a DOS box type fix...executed from within DELPHI.

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339608
No problem ;->

Try this code :-)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
var
  pt : TPoint;
begin
  pt := Point($746B6956, $726F);
  Caption := PChar(@pt);
end;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1339609
Viktor:

It says "Viktor" in the caption.

Can you explain this to me?

I know that if you change the numbers like this:

From:
pt := Point($746B6956, $726F);

To:
 pt := Point($746B6957, $726F);
                                ^

It says "Wiktor" instead of "Viktor" ....so you're passing in hexadecimal values that translate into a string?

Anyway....it was cute.

Later,

Tom

0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339610
John(erajoj) showed me how to write those leters...

Yes these are hexadecimal values and the first letter of your word is becoming last, the second is the one b4 the last, and so on....

There are a few other things that you need to do in order for it to show correctly...

Regards,
(@Viktor_Ivanov)^.Name;  ;->
0
 
LVL 5

Author Comment

by:Tom Knowlton
ID: 1339611
There are a few more things I need to do?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1339612
No I was talking about the letter to show.... You need yo put the character 17 in the beginning of the string in hex that will determine the string, otherwise it won;t show correctly....

//Vik
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

710 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