Calling unmanaged code C++ dll from VB.NET -
i have problem reuse c++ dll used vb 6.0 vb.net.
a mate of mine programmed code in vb6.0 called ansi c++ dll programmed in vc 6.0++.
the function declared following;
ctype dword cconv iniciagestion(hwnd newhventana, char *ficheroini, char *mensaerror)
the former code in vb6.0 called dll in way
status = iniciagestion(me.hwnd, "drvcomm2.ini", mensaerror)
where mensaerror
output parameter defined as
public mensaerror string * 256
now can use dll vb.net?
i have problem declaration of third parameter.
using declaration
<dllimport("gestionprg.dll", callingconvention:=callingconvention.stdcall, charset:=charset.ansi)> _ public shared function iniciagestion(<marshalas(unmanagedtype.i4)> byval integer, <marshalas(unmanagedtype.lpstr)> byval b string, <outattribute(), marshalas(unmanagedtype.lptstr)> byref c string) long
and function called following
dim mensaerror string class1.iniciagestion(me.handle, "c:\\windows\\drvcomm2.ini", mensaerror)
i debugging , function called when going assigned value mensaerror
in c++ code exception produced.
can me in declaration in vb.net?
please use 4 whitespaces in front of code - makes lot easier read...
<system.runtime.interopservices.dllimport("yourdll.dll")> _ public shared function iniciagestion(byval intptr, byref b string, byref c string) long end function private sub callcode() dim mensaerror string = "" iniciagestion(me.handle, "c:\windows\drvcomm2.ini", mensaerror) end sub
should job...
Comments
Post a Comment