How to Get the Windows Directory
December 15th, 1999
No comments
To found out the name of the Windows directory it’s best to use the Windows API GetWindowsDirectory() function.
Here’s the Delphi implementation:
uses Windows; ... function GetWindowsDir: string; const (* The length of the directory buffer. Usually 64 or even 16 is enough** ** Must be DWORD type. *) dwLength: DWORD = 255; var pcWinDir: PChar; begin GetMem(pcWinDir, dwLength); GetWindowsDirectory(pcWinDir, dwLength); Result := string(pcWinDir); FreeMem(pcWinDir, dwLength); end;
Categories: System code, Delphi, directory, folder, function, GetWindowsDirectory, object pascal, open source, source code, System, tip, trick, windows