Mega Code Archive

 
Categories / Delphi / API
 

Getting the windows directory

Question: How can I determine where the Windows directory is? Answer: You can make a call to the Windows API function GetWindowsDirectory(). If you want the system directory, simply call the Windows API function GetSystemDirectory(). Example: {$IFNDEF WIN32} const MAX_PATH = 144; {$ENDIF} procedure TForm1.Button1Click(Sender: TObject); var a : Array[0..MAX_PATH] of char; begin GetWindowsDirectory(a, sizeof(a)); ShowMessage(StrPas(a)); GetSystemDirectory(a, sizeof(a)); ShowMessage(StrPas(a)); end;