Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Incompatible types: 'Cardinal' and 'Pointer' bei DLL-Aufruf (https://www.delphipraxis.net/120254-incompatible-types-cardinal-pointer-bei-dll-aufruf.html)

Hedge 8. Sep 2008 00:22


Incompatible types: 'Cardinal' and 'Pointer' bei DLL-Aufruf
 
Möchte die Funktion einer DLL benutzen. Der Author hat diese folgendermaßen dokumentiert:

Zitat:

DWORD SetCallback(IN DWORD lpProc);
--- lpProc: pointer to the callback function:
--- VOID WINAPI keyProc(INT pressedKeys);
---
--- In VB: SetCallback(AddressOf(Keys_Pressed))
--- Public Sub Keys_Pressed(Keys as Long) .....


If the functions succeed, the return value is nonzero.
If the functions fails, the return value is zero. To get extended error information, call GetLastError.

I attached it and hope u can find use with it.

The values.txt showes, what to check for at the callback.
Any questions, just ask!
Im var-Bereich meines Forms habe ich deklariert:

Delphi-Quellcode:
function SetCallback (lpProc: DWORD ) : dword;stdcall;
  external 'lglight.dll';
mit anderen Funktionen der dll kann ich arbeiten, aber bei dieser versteh ich den Umgang damit nicht.
Dann habe ich im Form.Create:

Delphi-Quellcode:
SetCallback (@keyProc);
Hier tritt der im Titel erwähnte Fehler auf

Und weiter vorne

Delphi-Quellcode:
function keyProc(pressedKeys:integer):integer;
begin
 beep;
end;

Luckie 8. Sep 2008 00:43

Re: Incompatible types: 'Cardinal' and 'Pointer' bei DLL-Auf
 
Du übergibst einen Zeiger, die Funktion erwartet aber ein DWORD. Die Fehlrmeldung ist doch eigentlich klar verständlich.

Versuch es mal so:
Delphi-Quellcode:
SetCallback(DWORD(@keyProc));


Alle Zeitangaben in WEZ +1. Es ist jetzt 03:36 Uhr.

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