Problem with an unmanaged DLL (unsigned char)

J

Jim Wilson [eMVP]

I know you said that the you know the Dat & Idt parameters are fine but they
look like the problem to me. The unmanaged function expects those
parameters to be pointers but you are passing them ByVal. To pass those
parameters as pointers, you need to pass them ByRef.

Just my 2 cents

Jim Wilson, eMVP
http://www.jwhedgehog.com
http://www.develop.com
 
T

Thomas

Hi group !

I've some problems to call an unmanaged function which requires
unsigned char parameter.

The definition of the function :
char ReadTag(unsigned char Page,unsigned char* Dat,unsigned char* Idt)
Page is an unsigned number on 8 bits

My code in VB.NET :
- Declaration :
<DllImport("RFIDHT1.dll", CharSet:=CharSet.Unicode)> _
Private Shared Function ReadTag(ByVal page As Byte, ByVal Dat() As
Byte, ByVal Idt() As Byte) As Integer
End Function

- Execution :
Dim DataTag(1024) As Byte
Dim IdTag(1024) As Byte
Dim ResNum As Integer

ResNum = ReadTag(CByte(4), DataTag, IdTag)

I've no errors on execution but the function returns me an error code
as if one parameter was incorrect.
I know that the problem is not on Dat and Idt parameters because some
other functions work fine.

Thank you for your help !

Thomas
 
A

Alex Feinman [MVP]

I don't see a problem here. Are you sure it is not caused by something
else - such is a lack of initialization, or an invalid parameter value?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top