Umsetzung Aufruf externer DLL nach PB
Verfasst: 29.06.2007 17:04
Moin, moin
ich habe trotz Suchen und Lesen im Forum ein Problem mit der Umsetzung des Aufrufs einer Funktion in einer externen DLL.
Mit VB funktioniert es ohne Probleme, es liegt wohl an der Art wie ich aufrufe, es wird immer ein leerstring zurückgegeben.
Vielen Dank für Eure Hilfe
Tom
ich habe trotz Suchen und Lesen im Forum ein Problem mit der Umsetzung des Aufrufs einer Funktion in einer externen DLL.
Mit VB funktioniert es ohne Probleme, es liegt wohl an der Art wie ich aufrufe, es wird immer ein leerstring zurückgegeben.
Vielen Dank für Eure Hilfe
Tom
Code: Alles auswählen
; VB
; Public Declare Function QAPIGetLastErrorStringEx Lib "QLIB32" (ByVal buffer As String, ByVal buffersize As Long) As Long
; Public Declare Function QAPIGetLastErrorCode Lib "QLIB32" () As Long
; Public Declare Sub QAPIWatchdogEnable Lib "QLIB32" ()
;
; Dim buffer As String * 256
; Dim result As Long
; Call QAPIWatchdogEnable
; If (QAPIGetLastError() <> 0) Then
; result = QAPIGetLastErrorStringEx(buffer, 256)
; MsgBox Left(buffer, result)
; EndIf
;
#CRlf = Chr(13)+Chr(10)
Global dll.l
dll = OpenLibrary(#PB_Any,"c:\windows\system32\qlib32")
If dll = 0
Return
EndIf
Procedure enable()
ProcedureReturn CallFunction(dll,"QAPIWatchdogEnable")
EndProcedure
Procedure disable()
ProcedureReturn CallFunction(dll,"QAPIWatchdogDisable")
EndProcedure
Procedure retrigger()
ProcedureReturn CallFunction(dll,"QAPIWatchdogRetrigger")
EndProcedure
Procedure lasterr()
ProcedureReturn CallFunction(dll,"QAPIGetLastError")
EndProcedure
Procedure maxcards()
ProcedureReturn CallFunction(dll,"QAPIExtNumOfCards")
EndProcedure
Procedure.s errorstring()
buffer.s = Space(256)
nLen.l = 256
;nerg.l = CallFunction(0,"QAPIGetLastErrorStringEx",@buffer, @nLen)
nerg.l = CallFunction(0,"QAPIGetLastErrorStringEx",buffer, nLen)
; nerg.l ist immer 0, Buffer immer space(256)
ProcedureReturn Left(buffer, nerg)
EndProcedure
enable()
nLasterr.l = lasterr()
;nMaxcards.l = maxcards()
If nLasterr <> 0
; ist 22 , genau wie in VB
CallDebugger
cerr.s = errorstring()
; cerr.s ist immer leer
MessageRequester( "ERR",cerr)
EndIf