Semen, thank you it was just what i needed. Don't know how i overlooked that. I know about the UDT alignment issues and that In /Out won't work under NT / 2000.
Thanks
Doug
------------------
Announcement
Collapse
No announcement yet.
pointers
Collapse
X
-
Doug --
You can simply declare Sub PBOUT(ByVal PT As Integer, ByVal t2 As Byte Ptr) Export and do not use StAddress at all, but:
1) You forgot, that alignment in VB UDT and PB UDT are different.
The easyiest way in your case to declare all parameters in UDT as Long or to pass string from VB (MKI$ ... + MKL$ + ...).
2) Don't forget that under NT/2000 you can't use IN/OUT.
------------------
Leave a comment:
-
Tom, Thanks for replying. I had the arguements passed byval at one time. The code above was just the last state it was in and I should have corrected that before posting it. The problem is that the PB6 code won't compile. I get an error at value = @t2
Tanks
------------------
Leave a comment:
-
Originally posted by Doug McDonald:
SUB PBOUT(BYVAL PT AS INTEGER, StAddress AS DWORD) EXPORT
Code:SUB PBOUT(BYVAL PT AS INTEGER, BYVAL StAddress AS DWORD) EXPORT
Code:Declare Sub PBOUT Lib "port32.dll" (ByVal pt As Integer, mtype As myType2)
------------------
Tom Hanlin
PowerBASIC Staff
Leave a comment:
-
pointers
Ok I'm lost, I'm tring to pass a pointer for a UDT from VB to pb6
then send it to an I/O port a byte at a time. This code will not
compile but it will if i pass a VARPRT of a string from VB (changing
some of the code of course). The problem is value = @t2. I thought, and
I'm wrong, that @t2 would be a pointer the the first byte of the
structure.
'pb code:
#COMPILE DLL "c:\windows\system\port32.dll"
'#INCLUDE "win32api.inc"
TYPE myType1
t1mytype2 AS LONG
END TYPE
TYPE myType2
testInt AS INTEGER
testUDT AS myType1
testLong AS LONG
END TYPE
SUB PBOUT(BYVAL PT AS INTEGER, StAddress AS DWORD) EXPORT
DIM t2 AS myType2 PTR
t2 = StAddress
DIM i AS LONG
DIM value AS BYTE
FOR i = 0 TO LEN(myType2)
value = @t2
! mov AL, value
! mov DX, PT
! out DX, AL
INCR t2
MSGBOX HEX$(value)
NEXT i
END SUB
FUNCTION PBINP(BYVAL PT AS INTEGER) EXPORT AS LONG
! mov DX, PT
! in AL, DX
! mov FUNCTION[0], AL
END FUNCTION
'VB Code:
Type myType1
t1mytype2 As Long
End Type
Type myType2
testInt As Integer
testUDT As myType1
testLong As Long
End Type
Declare Sub PBOUT Lib "port32.dll" (pt As Integer, mtype As myType2)
Dim t1 As myType1
Dim t2 As myType2
Private Sub Command1_Click()
t1.t1mytype2 = &HFFFFFFFF
t2.testInt = &HFFFF
t2.testLong = &HFFFFFFFF
PBOUT 300, t2
End Sub
Private Sub Command2_Click()
End
End Sub
Tags: None
Leave a comment: