![]() |
Dll-Aufruf Konvertierung von VB-Code nach Delphi
Hi @All!
ich habe diesen Code
Code:
von einem VB-Beispiel genommen und wollte ihn in Delphicode umwandeln,
Public Enum eMode
CommonMode = 0 IMode_1 = 1 IMode_2 = 2 IMode_3 = 3 IMode_4 = 4 IMode_5 = 5 SimpleMode = 6 End Enum Declare Sub SetDeviceEnabled Lib "AN21xx.dll" (ByVal DevNumber As Byte, _ ByVal DriverName As String, _ ByVal MC_Mode As eMode, _ ByVal ID As String, _ ByVal KeyWord As String, _ I_Error As Long) aber irgendwas mach ich falsch:
Delphi-Quellcode:
ich komme einfach nicht drauf.const CommonMode = 0; IMode_1 = 1; IMode_2 = 2; IMode_3 = 3; IMode_4 = 4; SimpleMode = 5; type TDLL_AN21xx_SetDeviceEnabled = procedure( const aDevNumber : Byte; const aDriverName : PChar; const aMC_Mode : integer; const aID : PChar; const aKeyWord : PChar; var aError : integer ); var DLL_AN21xx_SetDeviceEnabled : TDLL_AN21xx_SetDeviceEnabled = nil; function DLL_An21xx_Init : Boolean; implementation function DLL_An21xx_init : Boolean; var a : Cardinal; begin a := LoadLibrary(pChar(ExtractFilePath( Application.exename) + 'AN21xx.dll')); @DLL_AN21xx_SetDeviceEnabled := GetProcAddress (a,'SetDeviceEnabled'); if @DLL_AN21xx_SetDeviceEnabled = nil then Result := false else Result := true; end; immer wenn ich dann die Proceduer DLL_AN21xx_SetDeviceEnabled aufrufe kommt eine Zugriffsverletzung. Also muss irgendein parameter falsch sein? Hoffe ihr könnt mir weiterhelfen. Danke schonmal im voraus. Wolfgang |
Re: Dll-Aufruf Konvertierung von VB-Code nach Delphi
Moin Wolfgang,
die DLL kenne ich jetzt zwar nicht, aber probier mal bei der Deklaration stdcall mit anzugeben. |
Re: Dll-Aufruf Konvertierung von VB-Code nach Delphi
Danke!
Das wars :dp: dachte den stdcall befehl braucht man nur wenn man die Dll direkt aufruft, also ohne Pluginlösung. tja und wieder was dazugelernt. Thx Wolfgang |
Re: Dll-Aufruf Konvertierung von VB-Code nach Delphi
Moin Wolfgang,
damit wird die Aufrufkonvention angegeben. Ob die Funktion nur statisch oder dynamisch importiert wird spielt dabei keine Rolle. Stdcall war auch nur geraten, aber in den meisten Fällen stimmt's ;-) |
Alle Zeitangaben in WEZ +1. Es ist jetzt 03:20 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz