Disk In Drive
Q: How to check if there’s a Disk in a Drive? A: [code lang=”delphi”]function DiskInDrive(Drive: Char): Boolean; var ErrorMode: word; begin { make…
Can EXE delete itself?
Q: how to let EXE delete itself while running? >I want to delete exe file while is opened. My friend did that in…
Check if File matches Wildcards
Q: > i would like to make a function that return if the file is in that wildcards > > e.g. > wildcards(‘c:\*.txt’,’c:\test.txt’)…
Choose a Directory
the following code will bring up the standard “Browse for folders” dialog with the full directory tree available: [code lang=”delphi”]uses FileCtrl; procedure TForm1.Button1Click(Sender:…
Deltree
[code lang=”delphi”]procedure DelTree(StartDir: string); var Search : TSearchRec; begin if Startdir[Length(Startdir)] ‘\’ then startdir := startdir + ‘\’; if FindFirst(startdir + ‘*.*’, faAnyFile,…
FileTime 2 DateTime
[code lang=”delphi”]function GetModifiedDate(FileName: string): TDateTime; var SearchRec: TSearchRec; ModifiedTime: TFileTime; SystemTime: TSystemTime; begin Result := 0; If FindFirst(FileName, faAnyFile, SearchRec) = 0 then…
Get Short Pathname
[code lang=”delphi”]FName : String; SetLength(FName, MAX_PATH+1); GetShortPathName(PChar(SaveDialog1.Filename), PChar(FName), MAX_PATH); SetLength(FName, StrLen(PChar(FName))); [/code] [tags]Delphi, File[/tags]
GetShortFileName
[code lang=”delphi”]Function GetShortFileName(Const FileName : String) : String; var aTmp: array[0..255] of char; begin if GetShortPathName(PChar(FileName),aTmp,Sizeof(aTmp)-1)=0 then Result:= FileName else Result:=StrPas(aTmp); end;[/code] [tags]Delphi,…
Setting File Attributes (german)
Dateiattribute setzen (aus der D3 Onlinehilfe) Delphi ermöglicht es Ihnen, die Attribute jeder beliebigen Datei zu jedem beliebigen Zeitpunkt zu setzen. Um die…