Einzelnen Beitrag anzeigen

Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#4
  Alt 24. Jun 2002, 15:42
Okay, die letzte Möglichkeit war nicht perfekt. Diese Lösung ist wohl besser.
Code:
function NT_InternalGetWindowText(Wnd: HWND): String;
type
  TInternalGetWindowText = function(Wnd: HWND;lpString: PWideChar;nMaxCount: Integer): Integer; stdcall;
var
  hUserDll: THandle;
  InternalGetWindowText: TInternalGetWindowText;
  lpString: array[0..MAX_PATH] of WideChar; //Buffer for window caption
  oemStr : PChar;
begin
  Result := '';
  hUserDll := GetModuleHandle('user32.dll');
  if (hUserDll > 0) then
  begin
    @InternalGetWindowText := GetProcAddress(hUserDll, 'InternalGetWindowText');
    if Assigned(InternalGetWindowText) then
    begin
      InternalGetWindowText(Wnd, lpString, SizeOf(lpString));
      Result := String(lpString);
    end;
  end;
end;
Änderungen zu Deiner Lösung:

TInternalGetWindowText = function(Wnd: HWND;lpString: PWideChar;nMaxCount: Integer): Integer; stdcall;

lpString: array[0..MAX_PATH] of WideChar; //Buffer for window caption

Result := String(lpString);
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat