PC Review


Reply
 
 
=?Utf-8?B?Um9kcmlndWU=?=
Guest
Posts: n/a
 
      13th Sep 2004
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
 
Reply With Quote
 
 
 
 
Tom Shelton
Guest
Posts: n/a
 
      13th Sep 2004
In article <11156045-7742-4F95-9C42-(E-Mail Removed)>, Rodrigue wrote:
> 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...

--
Tom Shelton [MVP]
 
Reply With Quote
 
 
 
 
=?Utf-8?B?Um9kcmlndWU=?=
Guest
Posts: n/a
 
      14th Sep 2004
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......

"Tom Shelton" wrote:

> In article <11156045-7742-4F95-9C42-(E-Mail Removed)>, Rodrigue wrote:
> > 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...
>
> --
> Tom Shelton [MVP]
>

 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      14th Sep 2004
On Mon, 13 Sep 2004 16:09:03 -0700, Rodrigue wrote:

> 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.

--
Tom Shelton [MVP]
 
Reply With Quote
 
=?Utf-8?B?Um9kcmlndWU=?=
Guest
Posts: n/a
 
      17th Sep 2004
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.

"Tom Shelton" wrote:

> On Mon, 13 Sep 2004 16:09:03 -0700, Rodrigue wrote:
>
> > 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.
>
> --
> Tom Shelton [MVP]
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:03 PM.