VB.NET

G

Guest

I upgraded to VB.net and I am having trouble calling a DLL. The old way a
call is made from VB6 to a C dll. The dll would convert the BSTR to a null
terminated string and reverse the process to return the string to VB. The
dll is unmanaged code. The documentation is at best confusing. Any help will
be appreciated
 
T

Tom Shelton

I upgraded to VB.net and I am having trouble calling a DLL. The old way a
call is made from VB6 to a C dll. The dll would convert the BSTR to a null
terminated string and reverse the process to return the string to VB. The
dll is unmanaged code. The documentation is at best confusing. Any help will
be appreciated

It really depends... Can you post the VB6 declaration and maybe a
sample usage? This would go a long way in explaining what needs to be
done...
 
G

Guest

I am writing this from home, so I do not have the code in front of me but it
goes something like this
In Vb: declare sub procedure(mystring1 as string, mystring2 as string)
in the dll which is written in C:
void procedure(BSTR mystring1, BSTR
mystring2)
call convert to string......
 
T

Tom Shelton

I am writing this from home, so I do not have the code in front of me but it
goes something like this
In Vb: declare sub procedure(mystring1 as string, mystring2 as string)
in the dll which is written in C:
void procedure(BSTR mystring1, BSTR
mystring2)
call convert to string......

Are these string parameters altered at all by the procedure? Off the top
of my head, I would say:

Declare Ansi Function procedure lib "mylib.dll" (ByVal mystring1 as string,
Byval mystring2 as string)

That's if the the strings are to be constant values... If the strings are
to be altered by the calling procedure, then I would pass them as
System.Text.StringBuilder instead.
 
G

Guest

I checked the DLL and the string were received OK and yet I was getting the
system.runtime.execution error, so I changed the call to multiple calls
passing one string and it worked without any other modification. It must be a
bug in the net framework. The strings are not nodified in the DLL.
 

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