Autor Beitrag
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Di 18.02.03 10:27 
In manchen Fällen benötigt man das Windows- und/oder das Systemverzeichnis. Mit den folgenden Funktionen bekommt man diese Verzeichnisse als String zurück:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
function GetWinDir: String
const 
  UNLEN = MAX_PATH; 
var 
  Size: DWORD; 
begin 
  Size := UNLEN + 1
  SetLength (Result, Size); 
  if GetWindowsDirectory (PChar (Result), Size) <> 0 then 
    SetLength (Result, StrLen (PChar (Result)))
  else 
    Result := ''
end

function GetSysDir: String
const 
  UNLEN = MAX_PATH; 
var 
  Size: DWORD; 
begin 
  Size := UNLEN + 1
  SetLength (Result, Size); 
  if GetSystemDirectory (PChar (Result), Size) <> 0 then 
    SetLength (Result, StrLen (PChar (Result)))
  else 
    Result := ''
end;

Beispiel:
ausblenden Delphi-Quelltext
1:
2:
ListBox1.Items.Add ('Windowsverzeichnis: ' + GetWinDir);
ListBox1.Items.Add ('Systemverzeichnis: ' + GetSysDir);


- Sourcecode von Luckie
- Hinweise von einsTeIn.NET und Motzi eingebaut.