Home All Groups Group Topic Archive Search About

Call a DLL in C from VB

Author
10 Mar 2006 2:33 AM
bokiteam
Hi All,

I have the code as below:

( this is vb version )

Public Declare Function Retrivexxxx Lib "A.dll" (ByRef str As Byte) As
Integer
Public Declare Function SendDatatoxxx Lib "A.dll" (ByRef buf As Byte,
ByVal nbufSize As Integer, ByRef strRet As Byte) As Boolean

Public Declare Function Receivexxxdata Lib "A.dll" (ByRef buf As Byte,
ByVal nbufSize As Integer, ByRef nRetBytes As Integer) As Boolean


Public Declare Function Inp Lib "A32.dll" Alias "I32" (ByVal
PortAddress As Integer) As Integer
Public Declare Sub Out Lib "A32.dll" Alias "O32" (ByVal PortAddress As
Short, ByVal Value As Short)

could you please advice how to convert it in vc version ?

Thank you very much!

Best regards,
Boki.

Author
10 Mar 2006 4:02 AM
Randy Birch
Short = Integer in VB
Byte is fine
As Boolean should be As Long in VB

Note too that if the DLL's declares are in cdecl, you won't be able to call
the APIs from VB directly; they must be declared as stdcall.  If this is the
case, see Matt Curland's book at
http://www.awprofessional.com/bookstore/product.asp?isbn=0201707128&rl=1

--

Randy Birch
MS MVP Visual Basic
http://vbnet.mvps.org/

Please reply to the newsgroups so all can participate.




<bokit***@ms21.hinet.net> wrote in message
news:1141957996.072702.213420@v46g2000cwv.googlegroups.com...
Hi All,

I have the code as below:

( this is vb version )

Public Declare Function Retrivexxxx Lib "A.dll" (ByRef str As Byte) As
Integer
Public Declare Function SendDatatoxxx Lib "A.dll" (ByRef buf As Byte,
ByVal nbufSize As Integer, ByRef strRet As Byte) As Boolean

Public Declare Function Receivexxxdata Lib "A.dll" (ByRef buf As Byte,
ByVal nbufSize As Integer, ByRef nRetBytes As Integer) As Boolean


Public Declare Function Inp Lib "A32.dll" Alias "I32" (ByVal
PortAddress As Integer) As Integer
Public Declare Sub Out Lib "A32.dll" Alias "O32" (ByVal PortAddress As
Short, ByVal Value As Short)

could you please advice how to convert it in vc version ?

Thank you very much!

Best regards,
Boki.
Author
10 Mar 2006 4:29 AM
Jeff Johnson [MVP: VB]
"Randy Birch" <rgb_removet***@mvps.org> wrote in message
news:%23uDwCe$QGHA.4792@TK2MSFTNGP14.phx.gbl...

> Short = Integer in VB

And, similarly, what most languages call an "integer" or "int" must be
declared Long in VB.