Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Accessing DOS commands in DELPHI 3

Posted on 1998-09-13
11
Medium Priority
?
524 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
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 80 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

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!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

916 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