Board index » delphi » D2: Opening Folders and Executing External Programs.

D2: Opening Folders and Executing External Programs.

Hello,

          I would like to know if it is possible to Open Folders (like the
root C:\ or something) by the click of a Button, and what code should i use?

Also is it possible to execute external programs by the click of a button
and/or when the main form loads?

Any help would be greatly appreciated.

        Paul Hempshall

PS. Im using Delphi 2.

 

Re:D2: Opening Folders and Executing External Programs.


Use the ShellExecute API call to do either one.

--

Woody

Quote
Paul <eat-s...@vindaloo-fish.chicken-chow-mein.com> wrote in message

news:7763hm$ehe$1@nclient3-gui.server.ntli.net...
Quote
>Hello,

>          I would like to know if it is possible to Open Folders (like the
>root C:\ or something) by the click of a Button, and what code should i
use?

>Also is it possible to execute external programs by the click of a button
>and/or when the main form loads?

>Any help would be greatly appreciated.

>        Paul Hempshall

>PS. Im using Delphi 2.

Re:D2: Opening Folders and Executing External Programs.


Thanks,
             But how do you do that?

Sorry im a stupid begginer that doesnt know much............hehe

        Paul

Quote
Woody wrote in message <776sdj$89...@remarQ.com>...
>Use the ShellExecute API call to do either one.

>--

>Woody

Re:D2: Opening Folders and Executing External Programs.


To open a folder,
ShellExecute(Handle , 'open', PChar('c:\'), nil, nil, SW_NORMAL);

To run a program, just substitute the 'c:\' for whatever program you want to
run.
The SW_NORMAL can also be SW_MINIMIZED or SW_MAXIMIZED. You also need to
include the ShellAPI in the USES clause.

--

Woody

Quote
Paul <eat-s...@vindaloo-fish.chicken-chow-mein.com> wrote in message

news:7781b3$jm8$1@nclient3-gui.server.ntli.net...
Quote
>Thanks,
>             But how do you do that?

>Sorry im a stupid begginer that doesnt know much............hehe

>        Paul

>Woody wrote in message <776sdj$89...@remarQ.com>...
>>Use the ShellExecute API call to do either one.

>>--

>>Woody

Re:D2: Opening Folders and Executing External Programs.


You just need some standard Delphi components : DriveComboBox,
DirectoryListBox and File ListBox (in Win 3.1 tab)
They can be coupled so that choosing a drive dispays its directories, and
choosing a directory display its files.

Denis

Re:D2: Opening Folders and Executing External Programs.


Greetings.
I am Ralez.

It's not a problem.
WinExec is what I've used so far, and it works great for at least
Delphi 3, and I find it hard to believe that it doesn't for Delphi 2.

Here's how it works:
(Quite Simple)

WinExec('C:\Windows\Command.com', 1);

You can also do something like

WinExec('C:\Windows\Command.com', SW_SHOW);

I'm not sure if that second WinExec example of mine works, but the
first one certainly does. :)

but I like using the integer instead. I'm terrible with names but I
can remember every number in the world for as long as I like, so
experimenting with that integer is far more successful. ;) There are
methods to make them run minimized and maximized and all kinds of
things. This is the normal type, I've never had to use it any
differently. I can't remember what's used instead of the integer.

Now, if you wanna open directories, that's no problem. What you do is
that you open Explorer.exe with the directory as a parameter. This is
what you might as well type in the Run dialog box that's built into
Windows's Start Menu.

WinExec('Explorer C:\', 1);

This will open up the "C:\" directory. :) You'll figure it out from
here, unless you're impossibly stupid, which I seriously doubt you
being. Anyway, programs opened with WinExec are compatible with the
PATH system variable, meaning that all programs in e.g. C:\Windows and
C:\Windows\System and C:\Windows\Command are executable without a
path. "WinExec('notepad', 1);" will open up Notepad, and you don't
need to put in the entire path location of Notepad.exe, since it's in
a directory that is contained in the PATH system variable. :) You know
what this means if you've ever checked out your Autoexec.Bat.

Hope this helps.

Peace, brother.

Ralez Armon
ralez @ islandia . is

On Sat, 9 Jan 1999 00:19:27 -0600, "Woody" <woody....@ih2000.net>
wrote:

Quote
>Use the ShellExecute API call to do either one.

>--

>Woody

>Paul <eat-s...@vindaloo-fish.chicken-chow-mein.com> wrote in message
>news:7763hm$ehe$1@nclient3-gui.server.ntli.net...
>>Hello,

>>          I would like to know if it is possible to Open Folders (like the
>>root C:\ or something) by the click of a Button, and what code should i
>use?

>>Also is it possible to execute external programs by the click of a button
>>and/or when the main form loads?

>>Any help would be greatly appreciated.

>>        Paul Hempshall

>>PS. Im using Delphi 2.

Other Threads