Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Accessing DOS commands in DELPHI 3

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

 
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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

721 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