Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Library: Windows API / MS.NET Framework API (https://www.delphipraxis.net/20-library-windows-api-ms-net-framework-api/)
-   -   Delphi Wie finde ich die Windows Systempfade z.B : C:\Windows\temp (https://www.delphipraxis.net/7749-wie-finde-ich-die-windows-systempfade-z-b-c-%5Cwindows%5Ctemp.html)

Frank2269 20. Aug 2003 14:27


Wie finde ich die Windows Systempfade z.B : C:\Windows\temp
 
Wie finde ich die Windowssystemordner z.B:

TEMP
SYSTEM, SYSTEM32 ,Installationspfad \Windows oder \WINNT.

Mit foglenden Functionen geht das.

1.) Windows Temp auslesen

Uses Windows.pas "Normalerweise automatisch eingebunden"
Delphi-Quellcode:
Function TempPath:String;
var
  buf:Pointer;
begin
  GetMem(buf,MAX_PATH);
  GetTempPathA(MAX_PATH,buf);
  TempPath:=strpas(buf);
  FreeMem(buf,MAX_PATH);
end;
2.) Installationsordner von Windows

Uses Windowspas "Normalerweise automatisch eingebunden"
Delphi-Quellcode:
Function WinDowsDir:String;
var
  a : Array[0..MAX_PATH] of char;
  Temp:String;
begin
  GetWindowsDirectory(a, sizeof(a));

  Temp:=(StrPas(a));
  Temp:=copy(temp,length(temp),1); /// Abschließenden Slash anfügen !

   if Temp='\' then
     WinDowsDir:=((trim(StrPas(a))))
   else
     WinDowsDir:=((trim(StrPas(a))))+'\';
end;
3.) Der Windows Systemordner
Delphi-Quellcode:
Function SysDir:String;
var
  a : Array[0..MAX_PATH] of char;
  Temp:String;
begin
  GetSystemDirectory(a, sizeof(a));

  Temp:=(StrPas(a));
  Temp:=copy(temp,length(temp),1); /// Abschließenden Slash anfügen !

  if Temp='\' then
    GetSysDir:=((trim(StrPas(a))))
  else
    GetSysDir:=((trim(StrPas(a))))+'\';
end;
Gruß Frank

[edit=Luckie] Mfg, Luckie[/edit]
[edit=Matze]Code formatiert. Mfg, Matze[/edit]

Alexander 20. Aug 2003 14:31

Re: Wie finde ich die Windows Systempfade z.B : C:\Windows\t
 
Mhm hast du dir das hier schon mal angekuckt?
http://www.delphipraxis.net/internal...502&highlight=

[edit=Chakotay1308] Mfg, Chakotay1308[/edit]

Luckie 20. Aug 2003 15:32

Re: Wie finde ich die Windows Systempfade z.B : C:\Windows\t
 
Also ich hätte es j aso gemacht:
Delphi-Quellcode:
function GetSysDir: String;
const
  UNLEN = MAX_PATH;
var
  Size: DWORD;
  buffer : array[0..UNLEN] of Char;
begin
  Size := UNLEN + 1;
  if GetSystemDirectory(buffer, Size) <> 0 then
    result := String(buffer)
  else
    result := '';
end;
Und:
Delphi-Quellcode:
function GetWinDir: String;
const
  UNLEN = MAX_PATH;
var
  Size: DWORD;
  buffer : array[0..UNLEN] of Char;
begin
  Size := UNLEN + 1;
  if GetWindowsDirectory(buffer, Size) <> 0 then
    result := String(buffer)
  else
    result := '';
end;

CalganX 8. Sep 2003 16:14

Re: Wie finde ich die Windows Systempfade z.B : C:\Windows\t
 
Und ich würde es so machen: http://www.delphipraxis.net/internal...502&highlight= ;)
Allerdings fehlen da die Definitionen für CSIDL_SYSTEM und CSIDL_WINDOWS:
Code:
CSIDL_SYSTEM    $25
CSIDL_WINDOWS   $24
Chris

alcaeus 8. Sep 2003 16:38

Re: Wie finde ich die Windows Systempfade z.B : C:\Windows\t
 
Liste der Anhänge anzeigen (Anzahl: 1)
Also, es gibt da diese Unit "environ" (s. anhang), mit der man Umgebungsvariablen bequem herholen kann... Ich habe sie nicht geschrieben, Copyright beachten! Ich hoffe das war gemeint..


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:11 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz