Einzelnen Beitrag anzeigen

venice2
(Gast)

n/a Beiträge
 
#1

Fehlerhafte String auswertung

  Alt 11. Jul 2021, 18:11
Delphi-Quellcode:
type
  PSOP64 = ^TSOP64;
  TSOP64 = record
    plugin: array[0..MAX_PATH] of AnsiChar;
  end;
Delphi-Quellcode:
var
  gCDS: COPYDATASTRUCT;
  gSOP: TSOP64;
Delphi-Quellcode:
procedure SOP_SetPlugin(Plugin: PWideChar);
begin
  if (gp.hSOPlugin <> 0) then
  begin
    FillChar(gSOP.plugin, 0, MAX_PATH);
    WideCharToMultiByte(CP_ACP, 0, Plugin, -1, gSOP.plugin, MAX_PATH, nil, nil);
    gCDS.dwData := 2;
    gCDS.cbData := SizeOf(gSOP);
    gCDS.lpData := @gSOP;
    SendMessage(gp.hSOPlugin, WM_COPYDATA, WPARAM(gP.MainHandle), LPARAM(@gCDS));
  end;
end;
gSOP.plugin ist als AnsiChar definiert und wird korrekt gefüllt.
Nach dem senden der Message ist aber in der anderen Exe der String Fehlerhaft.

Jemand eine Idee woran es liegt?
Beide Records sind gleich.

Hier sind die Daten falsch.
Delphi-Quellcode:
pSOP := @pCDS.lpData;
if (InitVisDll(pSOP.plugin)) then // <<<<< pSOP.plugin ist nicht der gleiche String
EDIT:
Ok.. Hat sich erledigt. Sorry

Die Lösung!
pSOP := @pCDS.lpData;
@ ist nicht gleich Pointer

So geht's.
pSOP := Pointer(pCDS.lpData);

Geändert von venice2 (12. Jul 2021 um 11:40 Uhr)
  Mit Zitat antworten Zitat