mikeTmike
asked on
Finding program Drive
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry the function is:
function GetDriveName(Path: string): string;
begin
GetDriveName:= Copy(Path, 1, 2) + '\';
end;
I write it with Delphi :-)
Motaz
function GetDriveName(Path: string): string;
begin
GetDriveName:= Copy(Path, 1, 2) + '\';
end;
I write it with Delphi :-)
Motaz
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.