Leslie Chong
August 9th, 2001, 05:38 AM
Hello,
I've been trying to pass a string reference to a DLL function (created by myself). I always get the only 4 bytes in the return string 'DataOut':
private Sub CommandRead_Click()
Dim DataOut as string
Dim BlkNo as Integer
Dim BlkLen as Integer
DataOut = 0
'Read Data
BlkNo = 0
BlkLen = 32
Status = ReadBlock(BlkNo, BlkLen, DataOut)
Text1.Text = DataOut
End Sub
public Declare Function ReadBlock Lib "TestMemCard.dll" (byval BlkNo as Integer, byval BlkLen as Integer, byval DataOut as string) as Long
During creation of "TestMemCard.dll" , the function 'ReadBlock' was defined as
extern "C" long CALLDLL WINAPI ReadBlock(BYTE BlkNo,BYTE BlkLen,char *DataOut)
...where 'BYTE' is unsigned char.
I tried both 'ByVal' and 'ByRef' for 'DataOut', and get always 4 bytes for 'ByVal' while 'RyRef' gives illegal operation.
I appreciate if anyone could help. Thanks.
I've been trying to pass a string reference to a DLL function (created by myself). I always get the only 4 bytes in the return string 'DataOut':
private Sub CommandRead_Click()
Dim DataOut as string
Dim BlkNo as Integer
Dim BlkLen as Integer
DataOut = 0
'Read Data
BlkNo = 0
BlkLen = 32
Status = ReadBlock(BlkNo, BlkLen, DataOut)
Text1.Text = DataOut
End Sub
public Declare Function ReadBlock Lib "TestMemCard.dll" (byval BlkNo as Integer, byval BlkLen as Integer, byval DataOut as string) as Long
During creation of "TestMemCard.dll" , the function 'ReadBlock' was defined as
extern "C" long CALLDLL WINAPI ReadBlock(BYTE BlkNo,BYTE BlkLen,char *DataOut)
...where 'BYTE' is unsigned char.
I tried both 'ByVal' and 'ByRef' for 'DataOut', and get always 4 bytes for 'ByVal' while 'RyRef' gives illegal operation.
I appreciate if anyone could help. Thanks.