Obtener la carpeta de instalación de Windows

4727 vistas

Según la versión, Windows se instala (de forma por defecto) en la carpera C:\WINDOWS o bien en la carpeta C:\WINNT. Para encontrar esta carpeta podemos usar la función GetWindowsDirectory.



delphi
  1. function WindowsDirectory: String;
  2. const
  3.   dwLength = MAX_PATH + 1;
  4. var
  5.   WindowsDir: PChar;
  6. begin
  7.   GetMem(WindowsDir, dwLength);
  8.   try
  9.     GetWindowsDirectory(WindowsDir, dwLength);
  10.     Result := String(WindowsDir);
  11.   finally
  12.     FreeMem(WindowsDir, dwLength);
  13.   end;
  14. end;