Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Dll-Aufruf Konvertierung von VB-Code nach Delphi (https://www.delphipraxis.net/13293-dll-aufruf-konvertierung-von-vbulletin-code-nach-delphi.html)

Funky-Sepp 15. Dez 2003 15:55


Dll-Aufruf Konvertierung von VB-Code nach Delphi
 
Hi @All!

ich habe diesen Code
Code:
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)
von einem VB-Beispiel genommen und wollte ihn in Delphicode umwandeln,
aber irgendwas mach ich falsch:

Delphi-Quellcode:

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;
ich komme einfach nicht drauf.

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

Christian Seehase 15. Dez 2003 15:59

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.

Funky-Sepp 15. Dez 2003 16:02

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

Christian Seehase 15. Dez 2003 16:05

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