?
Solved

Finding program Drive

Posted on 1999-12-28
3
Medium Priority
?
289 Views
Last Modified: 2010-04-16
Lets say when i compile the program it is CDI.exe, now with in this program I want a function wich i can execute.

if the program is at "C:\mydir\CDI.exe" I want this function to return "C:\" and if it is at "D:\mydir\CDI.exe" it is to return "D:\"

I want the function to return what drive the executable is on.
0
Comment
Question by:mikeTmike
  • 2
3 Comments
 
LVL 50

Expert Comment

by:dbrunton
ID: 2311567
var
 which_drive : integer
 mydrive : string;

begin
  which_drive := 0;
  getdrive(whcih_drive, mydrive);
  writelnl('The drive is , mydrive);
end.

OR if you are using DOS 3.0 or higher

Writeln(ParamStr(0));

Note that I have submitted this as an answer.  Feel free to unlock the question if it is not suitable.
0
 
LVL 7

Accepted Solution

by:
Motaz earned 60 total points
ID: 2311928
You can write your own function like this:

function GetDriveName(Path: string): string;
begin
  Result:= Copy(Path, 1, 2) + '\';
end;

and you can call it as:

Writeln(GetDriveName(ParamStr(0));

Motaz

www.geocities.com/motaz1
0
 
LVL 7

Expert Comment

by:Motaz
ID: 2314181
Sorry the function is:
function GetDriveName(Path: string): string;
begin
  GetDriveName:= Copy(Path, 1, 2) + '\';
end;

I write it with Delphi :-)

Motaz
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying 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

You have missed a phone call. The number looks like it belongs to the bunch of numbers which your company uses. How to find out who has just called you?
In-App Messaging has revolutionized the way we look at marketing. It has also changed the way we use Apps. If In-App Messaging is used well then you will find that it can drive a lot of traffic to specific areas of your site. It also helps to improv…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Watch the video to learn how one can deal with PST file corruption issue with an outstanding Kernel for Outlook PST Repair Tool easily. Using this tool, non-technical users can swiftly perform the repair process to restore their essential data witho…

607 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