Einzelnen Beitrag anzeigen

Benutzerbild von KodeZwerg
KodeZwerg

Registriert seit: 1. Feb 2018
3.690 Beiträge
 
Delphi 11 Alexandria
 
#14

AW: Unicode und WideChar API-Funktionen

  Alt 12. Apr 2023, 15:28
Mir wurde soeben eine bessere Variante gezeigt ohne das die RTL "angegriffen" wird und ich hoffe die ist okay für Deine Zwecke @Dalai
Delphi-Quellcode:
unit Unit1;
// basis settings um es unicode fähig zu machen
{$mode objfpc}
{$modeswitch unicodestrings}

interface

uses
  Windows , // ganz regulär integrieren
  Classes , SysUtils , Forms , Controls , Graphics , Dialogs;

// unicode hack teil 1/2
{$define read_interface}
{$undef read_implementation}
{$i C:\FreePascal\fpcsrc\rtl\win\wininc\unidef.inc}

type

  { TForm1 }

  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
  public
  end;

var
  Form1: TForm1;

implementation

// unicode hack teil 2/2
{$undef read_interface}
{$define read_implementation}
{$i C:\FreePascal\fpcsrc\rtl\win\wininc\unidef.inc}

{$R *.lfm}

{ TForm1 }

procedure TForm1.FormCreate(Sender: TObject);
var
  lpApplicationName: PChar; // (PWideChar/LPCWSTR)
  lpBinaryType: LPDWORD;
begin
  GetBinaryType(lpApplicationName, lpBinaryType);
  // zeigt nun auf function GetBinaryType(lpApplicationName:LPCWSTR; lpBinaryType:LPDWORD):WINBOOL; external 'kernel32' name 'GetBinaryTypeW';
end;

end.
Gruß vom KodeZwerg
  Mit Zitat antworten Zitat