1

源程序下载

获取当前程序的目录
function GetCurrentPath :string;
begin
Result:=ExtractFilePath(Application.Exename);
end;
得到光驱
Function GetCDROM :String;
Var
drv :DWORD;
mask :BYTE;
drive :String;
begin
mask :=$80;
drv :=GetLogicalDrives;
Repeat
if (drv and mask)<>0 then Break;
mask :=mask shr 1;
Until False;
Repeat
drv :=Trunc(log2(mask))+65;
drive :=Chr(drv)+':';
if GetDriveType(PChar(drive))=5 then Break;
mask :=mask shr 1;
until (mask=1);
Result :=drive;
end;
得到windows目录
function GetWindowsDir: String;
var
ac: array [1..20] of Char;
pc: PChar;
begin
pc := @ac;
GetWindowsDirectory(pc, 20);
Result := pc;
end;
得到System目录
function GetSystemDir: String;
var
ac: array [1..20] of Char;
pc: PChar;
begin
pc := @ac;
GetTempPath(20, pc);
Result := pc;
end;
得到windows临时路径
function GetTempDir: String;
var
ac: array [1..20] of Char;
pc: PChar;
begin
pc := @ac;
GetSystemDirectory(pc, 20);
Result := pc;
end;
察看文件是否存在
FileExists(FileName:String):Boolean;
改变文件扩展名
ChangeFileExt(FileName:String);
得到文件的扩展名
ExtractFileExt(FileName:String):String;
源程序下载