PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Using Systems32 .DLL
Using Systems32 .DLL
Débuté par Ruan, 19 avr. 2014 09:36 - 4 réponses
Membre enregistré
209 messages
Popularité : +1 (1 vote)
Posté le 19 avril 2014 - 09:36
Good day

I have a .dll file I need to use in a project "k8055d.dll". This is the visual basic code:
Option Explicit
PRIVATE Declare FUNCTION Version Lib "k8055d.dll" () As Long
PRIVATE Declare FUNCTION SearchDevices Lib "k8055d.dll" () As Long


how will i put this in windev?

Thanks
Membre enregistré
68 messages
Posté le 19 avril 2014 - 18:53
Look at the API Description variable -> http://doc.windev.com/en-US/…

Here is one I use
gGetMemName is API Description
gGetMemName..DLLName = "GetMember.dll"
gGetMemName..FunctionName = "GetMember"
gGetMemName.ReturnType = apiString
gGetMemName.Parameter[1]..Type = apiSystemInt
//gGetMemName.Parameter[2]..type = apiString

So yours would be like this
//Version Lib "k8055d.dll" () As Long
gVersion is API Description
gVersion.DLLName = "k8055d.dll"
gVersion.ReturnType = apiSystemInt

Then to use it -
nMyVersion Is int

nMyVersion = gVersion()


HTH
Chris

--
Stay calm keep coding.
Membre enregistré
209 messages
Popularité : +1 (1 vote)
Posté le 20 avril 2014 - 00:20
ccordes wrote:
Look at the API Description variable -> http://doc.windev.com/en-US/…

Here is one I use
gGetMemName is API Description
gGetMemName..DLLName = "GetMember.dll"
gGetMemName..FunctionName = "GetMember"
gGetMemName.ReturnType = apiString
gGetMemName.Parameter[1]..Type = apiSystemInt
//gGetMemName.Parameter[2]..type = apiString

So yours would be like this
//Version Lib "k8055d.dll" () As Long
gVersion is API Description
gVersion.DLLName = "k8055d.dll"
gVersion.ReturnType = apiSystemInt

Then to use it -
nMyVersion is int

nMyVersion = gVersion()


HTH
Chris

--
Stay calm keep coding.



Hi ccordes

I tested it and got it to return data, but the deeper i go the more difficult this is getting: I think I need to explain more to what the whole purpose of this is. I got a USB INTERFACE BOARD / CARD with inputs, outputs and LED's. All of this is triggered from "k8055d.dll". When I push a button that says test the outputs the lights on the board must light up, that means that the ReturnType must be something else? Not sure. Here is the small test from excel...i have NO idea how to convert all of this to Windev..

Option Explicit
PRIVATE Declare FUNCTION Version Lib "k8055d.dll" () As Long
PRIVATE Declare FUNCTION SearchDevices Lib "k8055d.dll" () As Long
PRIVATE Declare FUNCTION SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
PRIVATE Declare FUNCTION OpenDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long
PRIVATE Declare Sub CloseDevice Lib "k8055d.dll" ()
PRIVATE Declare FUNCTION ReadAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long) As Long
PRIVATE Declare Sub ReadAllAnalog Lib "k8055d.dll" (Data1 As Long, Data2 As Long)
PRIVATE Declare Sub OutputAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long, ByVal Data As Long)
PRIVATE Declare Sub OutputAllAnalog Lib "k8055d.dll" (ByVal Data1 As Long, ByVal Data2 As Long)
PRIVATE Declare Sub ClearAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
PRIVATE Declare Sub SetAllAnalog Lib "k8055d.dll" ()
PRIVATE Declare Sub ClearAllAnalog Lib "k8055d.dll" ()
PRIVATE Declare Sub SetAnalogChannel Lib "k8055d.dll" (ByVal Channel As Long)
PRIVATE Declare Sub WriteAllDigital Lib "k8055d.dll" (ByVal Data As Long)
PRIVATE Declare Sub ClearDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
PRIVATE Declare Sub ClearAllDigital Lib "k8055d.dll" ()
PRIVATE Declare Sub SetDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long)
PRIVATE Declare Sub SetAllDigital Lib "k8055d.dll" ()
PRIVATE Declare FUNCTION ReadDigitalChannel Lib "k8055d.dll" (ByVal Channel As Long) As boolean
PRIVATE Declare FUNCTION ReadAllDigital Lib "k8055d.dll" () As Long
PRIVATE Declare FUNCTION ReadCounter Lib "k8055d.dll" (ByVal CounterNr As Long) As Long
PRIVATE Declare Sub ResetCounter Lib "k8055d.dll" (ByVal CounterNr As Long)
PRIVATE Declare Sub SetCounterDebounceTime Lib "k8055d.dll" (ByVal CounterNr As Long, ByVal DebounceTime As Long)
PRIVATE Declare FUNCTION SetTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long, _
ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
PRIVATE Declare FUNCTION KillTimer Lib "user32" ( _
ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Dim TimerID As Long
Dim TimerSeconds As Single
Dim CardAddress As Long
Dim n As Long

Sub Button1_Click()
Dim h As Long
n = 0
h = OpenDevice(0)
IF h = 0 THEN
ActiveSheet.Cells(1, 4) = "Card 0 Connected"
TimerSeconds = 1 ' the Timer interval is Now 1 sec.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
ELSE
ActiveSheet.Cells(1, 4) = "Card 0 Not Found"
END IF

END Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
On Error Resume Next
Dim Data1 As Long
Dim Data2 As Long
Dim i As Long
ReadAllAnalog Data1, Data2
ActiveSheet.Cells(2, 2) = Data1
ActiveSheet.Cells(3, 2) = Data2
WriteAllDigital n
ActiveSheet.Cells(5, 2) = n
n = n + 1
IF n = 32 THEN n = 0
i = ReadAllDigital
ActiveSheet.Cells(7, 2) = i
END Sub

Sub Button3_Click()
KillTimer 0&, TimerID
CloseDevice
ActiveSheet.Cells(1, 4) = "Card 0 Closed"
END Sub


one of the ones I don't understand is the "ByVal" function.

Thanks for your help.
Membre enregistré
68 messages
Posté le 22 avril 2014 - 14:58
ByVal just means that the parameter is passed to the procedure by value rather than the WD default; by Address.

Look at this for help - http://doc.windev.com/en-US/…

In Wx, instead of using ByVal, you use LOCAL in the procedure definition. Calling the procedure makes no difference.

Also, items passed by Address can be updated by the called procedure. That makes those parameters a two-way variable. Whereas an item passed byValue or Local, cannot be passed back to the calling procedure; making them a one-way communication.

I don't know how much VB you know, so I'll apologize up front for explaining this -
Here is one of the functions from above -
PRIVATE Declare FUNCTION SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long

PRIVATE - No one else can change this function
Declare - create a structure for the compiler
FUNCTION - this procedure returns a value and so it is considered as a variable of that type
SetCurrentDevice - Name of the procedure
Lib "k8055d.dll" - the name of the DLL where this function is found
( - start the parameters - the list of values that the procedure needs to work
ByVal CardAddress As Long - the parameter named CardAddress is a 4-byte integer and is passed as a value
) - end of the parameters
As Long - this function returns a 4-byte integer (apiInt_4 in Wx)

In the Wx, it looks like this -
gSetCurrentDevice is API Description
gSetCurrentDevice..DLLName = "k8055d.dll"
gSetCurrentDevice..FunctionName = "SetCurrentDevice"
gSetCurrentDevice..ReturnType = apiInt_4
gSetCurrentDevice..Parameter[1]..Type = apiInt_4

Here is another - PRIVATE Declare Sub SetAllDigital Lib "k8055d.dll" ()
The difference is that this is a Sub(routine) named SetAllDigital
Sub - this procedure does not return a value. It affects some other processes like display or global / class values
Its Api Description would look like this -
gSetAllDigital is API Description
gSetAllDigital..DLLName = "k8055d.dll"
gSetAllDigital..FunctionName = "SetAllDigital"


You should be able to take it from there. There are very few data types to worry about in those functions.
Here is a link to VB data types - http://msdn.microsoft.com/en-us/library/47zceaw7.aspx (I have this one book marked)
A Single, I believe, is an apiReal_4 - a short Floating point.

HTH,
Chris

--
Sometimes waiting is the best way forward...
Membre enregistré
209 messages
Popularité : +1 (1 vote)
Posté le 24 avril 2014 - 13:07
ccordes wrote:
ByVal just means that the parameter is passed to the procedure by value rather than the WD default; by Address.

Look at this for help - http://doc.windev.com/en-US/…

In Wx, instead of using ByVal, you use LOCAL in the procedure definition. Calling the procedure makes no difference.

Also, items passed by Address can be updated by the called procedure. That makes those parameters a two-way variable. Whereas an item passed byValue or Local, cannot be passed back to the calling procedure; making them a one-way communication.

I don't know how much VB you know, so I'll apologize up front for explaining this -
Here is one of the functions from above -
PRIVATE Declare FUNCTION SetCurrentDevice Lib "k8055d.dll" (ByVal CardAddress As Long) As Long

PRIVATE - No one else can change this function
Declare - create a structure for the compiler
FUNCTION - this procedure returns a value and so it is considered as a variable of that type
SetCurrentDevice - Name of the procedure
Lib "k8055d.dll" - the name of the DLL where this function is found
( - start the parameters - the list of values that the procedure needs to work
ByVal CardAddress As Long - the parameter named CardAddress is a 4-byte integer and is passed as a value
) - end of the parameters
As Long - this function returns a 4-byte integer (apiInt_4 in Wx)

In the Wx, it looks like this -
gSetCurrentDevice is API Description
gSetCurrentDevice..DLLName = "k8055d.dll"
gSetCurrentDevice..FunctionName = "SetCurrentDevice"
gSetCurrentDevice..ReturnType = apiInt_4
gSetCurrentDevice..Parameter[1]..Type = apiInt_4

Here is another - PRIVATE Declare Sub SetAllDigital Lib "k8055d.dll" ()
The difference is that this is a Sub(routine) named SetAllDigital
Sub - this procedure does not return a value. It affects some other processes like display or global / class values
Its Api Description would look like this -
gSetAllDigital is API Description
gSetAllDigital..DLLName = "k8055d.dll"
gSetAllDigital..FunctionName = "SetAllDigital"


You should be able to take it from there. There are very few data types to worry about in those functions.
Here is a link to VB data types - http://msdn.microsoft.com/en-us/library/47zceaw7.aspx (I have this one book marked)
A Single, I believe, is an apiReal_4 - a short Floating point.

HTH,
Chris

--
Sometimes waiting is the best way forward...


Hi Chris

Thanks for the reply. I will check it out and let you know.

Thanks