Hi!
Delphi-Quelltext
26: 27: 28: 29: 30:
| { ... } function InitHandleFunction(InitOnce: Pointer; Parameter: Pointer; var Context: Pointer): Boolean; stdcall; begin Context := TInitializeOnce(Parameter).DoInstantiate; Result := True; end; |
Was genau bringt Result := True hier, außer den Compiler zu besänftigen, da die Funktion einen Rückgabewert erwartet?
Die Original-Funktion sieht, wenn ich das richtig recherchiert habe, so aus:
C#-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
| BOOL CALLBACK InitHandleFunction ( PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext) {
HANDLE hEvent;
hEvent = CreateEvent(NULL, TRUE, TRUE, NULL);
if (NULL == hEvent) { return FALSE; } else { *lpContext = hEvent; return TRUE; } } |
Hier wird die Hilfsvariable hEvent zunächst auf NULL überprüft; je nach Ergebnis wird Context deren Wert anschließend zugewiesen.
Sollte es daher nicht in etwa wie folgt lauten:
Delphi-Quelltext
1: 2: 3: 4: 5:
| function InitHandleFunction(InitOnce: Pointer; Parameter: Pointer; var Context: Pointer): Boolean; stdcall; begin Context := TInitializeOnce(Parameter).DoInstantiate; Result := Context <> nil; end; |
Beste Grüße,
Marc