Delphi-PRAXiS
Seite 3 von 3     123   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Die Delphi-IDE (https://www.delphipraxis.net/62-die-delphi-ide/)
-   -   Standort Comand Line Compiler (DCC32.exe) ermitteln (https://www.delphipraxis.net/188453-standort-comand-line-compiler-dcc32-exe-ermitteln.html)

HolgerX 6. Mär 2016 08:18

AW: Standort Comand Line Compiler (DCC32.exe) ermitteln
 
Hmm..

Da ich überwiegend 32bit Tools erstelle habe ich immer die Probleme auf einem 64bit Windows Systemeinstellungen auslesen zu können.

Deshalb habe ich mir hier ein Hilfskonstrukt zusammengebastelt:

Delphi-Quellcode:
const
  KEY_WOW64_64KEY = $0100;
  KEY_WOW64_32KEY = $0200;


function IsWow64A: Boolean;
type
  TIsWow64Process = function( // Type of IsWow64Process API fn
    Handle: Windows.THandle; var Res: Windows.BOOL ): Windows.BOOL; stdcall;
var
  IsWow64Result: Windows.BOOL; // Result from IsWow64Process
  IsWow64Process: TIsWow64Process; // IsWow64Process fn reference
begin
  // Try to load required function from kernel32
  IsWow64Process := Windows.GetProcAddress(Windows.GetModuleHandle('kernel32'), 'IsWow64Process');

  if Assigned(IsWow64Process) then begin
    // Function is implemented: call it
    if not IsWow64Process(Windows.GetCurrentProcess, IsWow64Result) then
      raise Exception.Create('IsWow64: bad process handle');

    Result := IsWow64Result; // Return result of function
  end else
    // Function not implemented: can't be running on Wow64
    Result := False;
end;







  if IsWow64A then
    Reg := TRegistry.Create(KEY_READ or KEY_WOW64_64KEY)
  else
    Reg := TRegistry.Create(KEY_READ);
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon', False) then begin
      try
..
      finally
        Reg.CloseKey;
      end;
    end;
  finally
    Reg.Free;
  end;
Wenn ich als 32bit Prozess unter 64bit OS aus der Registry lesen/schreiben will und zwar aus dem NICHT Wow64.. dann brauche ich KEY_WOW64_64KEY.

Umgekehrt kann ein 64bit Programm die Konfigurationen aus einem wow64-Zweig auslesen, indem explizit KEY_WOW64_32KEY angegeben wird.


Alle Zeitangaben in WEZ +1. Es ist jetzt 23:17 Uhr.
Seite 3 von 3     123   

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