From: Jim Mack on
ralph wrote:
> Jim Mack wrote:
>>
>> Nope. When you use a TLB for an external library -- even if it's
>> not a COM DLL -- you can completely specify how arguments are
>> passed. If the interface says "BSTR" then you get a true Unicode
>> BSTR with no conversion. If the interface says "LPSTR" then VB
>> will perform the usual conversions.
>
> I'll be damn you gentlemen are correct.
> The conversion feature appears tied to the Declare Directives.

Actually, when using a TLB you almost always want to avoid Declares.
There are essentially two 'interfaces' for external standard
functions: the Declare and the TLB. The Declare will take precedence
if it's present -- and there's no way using a Declare to avoid the
Unicode-->Ansi conversions for 'As String'.

So if the point of using the TLB is to avoid the conversions, using a
Declare is counterproductive. Of course there are other reasons to use
a TLB -- very strong typing for one -- but in almost every case an
added Declare is redundant and sometimes works against you.

Aside: another benefit of using TLB and BSTR is that you can define a
parameter as [in], and avoid another time-waster in the Declare
method... VB not only converts Declared 'As String' arguments TO Ansi,
it reconverts FROM Ansi on return, just in case the string was
modified in the call.

--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"

First  |  Prev  | 
Pages: 1 2 3 4 5
Prev: New form on Main thread.
Next: Pasting text to browser