iowkit and VB6
Moderator: Guido Körber
iowkit and VB6
Hi
I had problems with VB6 crashing when the IO warrior library iowkit.dll was in my system32 folder (w2k) on my old laptop.
I have just received a new laptop and I can't remember what I did to sort this problem.
Has anyone had problems using the SDK samples with VB6 ?
Nigel
I had problems with VB6 crashing when the IO warrior library iowkit.dll was in my system32 folder (w2k) on my old laptop.
I have just received a new laptop and I can't remember what I did to sort this problem.
Has anyone had problems using the SDK samples with VB6 ?
Nigel
-
- Posts: 55
- Joined: Thu Apr 15, 2004 11:23 pm
- Contact:
functions GetSerialNumber and GetProductId not working
Hi,
Has anyone code examples for IowKitGetProductId and IowKitGetSerialNumber functions in VB6?
I try to use these functions in vb6 but:
- IowKitGetSerialNumber function crashes the vb6-ide
- IowKitGetProductId returns different values each time the function is called.
I think the reason for the IowKitGetProductId function for not working properly, is because the function declaration in iow.bas is possible incorrect: There is no parameter declared for the device handle. I added the handle myself, but the return values are different each time the function is called.
I have a functional program to messure temperature with iow24/iow40 and a ds1621-i2c temperaturesensor. The only thing missing is the possibility to show the ProductId and the SerialNumber of the iow device.
So i'm looking for code example of a correct iow.bas and a code example how to use the functions in my program.
gr
Edzer
Has anyone code examples for IowKitGetProductId and IowKitGetSerialNumber functions in VB6?
I try to use these functions in vb6 but:
- IowKitGetSerialNumber function crashes the vb6-ide
- IowKitGetProductId returns different values each time the function is called.
I think the reason for the IowKitGetProductId function for not working properly, is because the function declaration in iow.bas is possible incorrect: There is no parameter declared for the device handle. I added the handle myself, but the return values are different each time the function is called.
I have a functional program to messure temperature with iow24/iow40 and a ds1621-i2c temperaturesensor. The only thing missing is the possibility to show the ProductId and the SerialNumber of the iow device.
So i'm looking for code example of a correct iow.bas and a code example how to use the functions in my program.
gr
Edzer
-
- Posts: 543
- Joined: Mon Dec 01, 2003 6:09 pm
-
- Posts: 543
- Joined: Mon Dec 01, 2003 6:09 pm
The problem with IowKitGetProductId has been solved with a new version of the DLL to be delivered soon.
IowKitGetProductId returns a WORD, but the VB6 declaration is Long.
You get a random high word in the result of the function. Try masking it off in your code for now.
The next version of the DLL simply returns a DWORD to solve the problems.
The above is from the revised example for the next DLL, but it should work with the current DLL also.
IowKitGetProductId returns a WORD, but the VB6 declaration is Long.
You get a random high word in the result of the function. Try masking it off in your code for now.
The next version of the DLL simply returns a DWORD to solve the problems.
Code: Select all
Private Sub Form_Load()
Dim I As Long
Dim S(18) As Byte
' Initialize everything
' Open device
iowHandles(0) = IowKitOpenDevice()
' Fail if can't open
If iowHandles(0) = 0 Then
' Barf and exit from program
MsgBox "Can not open device!", 0, "Error"
End
End If
' Get number of IO-Warrior devices in system
numIows = IowKitGetNumDevs()
' Get all IO-Warrior handles
For I = 2 To numIows
iowHandles(I - 1) = IowKitGetDeviceHandle(I)
Next I
Call ClearAllButton_Click
I = IowKitGetSerialNumber(iowHandles(0), S(0))
ReadLabel.Caption = S
ReadLabel.Caption = "Serial number: " + ReadLabel.Caption
ReadLabel.Refresh
End Sub
Robert, thanks for your post.
VB6 returns an 'ByRef argument type mismatch' error on the IowKitGetSerialNumber function. De function declaration in iow.bas is:
It wont accept S(0) as an argument.
Any suggestions?
I have not tried masking the result of IowKitGetProductId, I will try this later.
The next few days i'm not ably to check the forum. I will possibly check it on next Friday.
VB6 returns an 'ByRef argument type mismatch' error on the IowKitGetSerialNumber function. De function declaration in iow.bas is:
Code: Select all
Public Declare Function IowKitGetSerialNumber _
Lib "iowkit" _
(ByVal iowHandle As Long, ByRef buffer As String) _
As Long
Any suggestions?
I have not tried masking the result of IowKitGetProductId, I will try this later.
The next few days i'm not ably to check the forum. I will possibly check it on next Friday.
-
- Posts: 543
- Joined: Mon Dec 01, 2003 6:09 pm
Oops, i forgot that i changed the declaration also.
Code: Select all
Public Declare Function IowKitGetSerialNumber _
Lib "iowkit" _
(ByVal iowHandle As Long, ByRef serialNumber As Byte) _
As Long
Problems solved! Both IowKitGetProductId and IowKitGetSerialNumber seem to work properly now.
Masking the two most significant bytes from the return value of IowKitGetProductId to zero, does the trick.
The code we talked about in one view.
The declaration part, with corrections on the orginal iow.bas dated sept 29 2003:
The program part:
This makes it a lot easier to identify multiple iow devices on my system.
Robert, thanks.
Masking the two most significant bytes from the return value of IowKitGetProductId to zero, does the trick.
The code we talked about in one view.
The declaration part, with corrections on the orginal iow.bas dated sept 29 2003:
Code: Select all
Public Declare Function IowKitGetSerialNumber _
Lib "iowkit" _
(ByVal iowHandle As Long, ByRef serialNumber As Byte) _
As Long
Public Declare Function IowKitGetProductId _
Lib "iowkit" _
(ByVal iowHandle As Long) _
As Long
Code: Select all
Dim s(18) As Byte
Dim sTmp As String
Dim l As Long
' Get SerialNumber
l = iow.IowKitGetSerialNumber(iowHandle, s(0))
sTmp = s
Debug.Print "SerialNumber(hex): " & sTmp
' In my case, output in immediate window is: SerialNumber(hex): 000007CE
' Get ProductID,
' dec 5377=hex 1501=IOW24;
' dec 5376=hex 1500=IOW40;
Debug.Print "ProductID(dec): " & CStr(iow.IowKitGetProductId(iowHandle) And 65535)
' In my case, output in immediate window is: ProductID(dec): 5377
Robert, thanks.