Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing a String to a DLL
Message
From
26/04/2001 04:34:22
Duncan Jones
Merrion Computing Ltd
Dublin, Ireland
 
 
To
24/04/2001 15:20:07
General information
Forum:
Visual Basic
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00499201
Message ID:
00500013
Views:
20
You may have fallen foul of a Visual basic cludge fix.

In VB4(32) and beyond strings are held internally as OLE (BSTR) style strings. Most DLLs are written in C or C++ and there require their strings in the NULL terminated C style. Visual Basic handles the conversion for you behind the scenes in before calling the DLL however the way id decides which style of string you are passing is by use of the ByVal keyword. (This is very counter-intuitive).

So - if your DLL requires a C style string declare it ByVal in the Declare statement, if it requires a BSTR style string declare it ByRef.

(This is explained better in "The Visual Basic programmer's guide to the Win32 API" by Daniel Appleman)
Previous
Reply
Map
View

Click here to load this message in the networking platform