BSTR type in VB
I received a DLL which uses BSTR as string type:example : given in the include file
DLLEXPORT BSTR WINAPI I2cGetInterfaceTypeStr (BSTR Interface);
how do i access this function in vb. This doesn't work.
DeclareFunction I2cGetInterfaceTypeStrLib "I2CAPI32.DLL" (ByVal InterfaceTypeAsString)AsString
Other functions of the DLL which don't use BSTR are working ok.
Can anyone help me.
Thanks, Jan
[976 byte] By [
jan_hk] at [2008-2-5]
Hello Johan
My question was not complete. I discovered i have only a problem with empty string.
I have next C++ example
// get first interface from the registry
// (first interface is returned when passing an empty string ! )
InterfaceGUID = I2cGetNextInterface( (BSTR)(""));
while(1)
{
// compare the interface found in the registry with ’cIFType’ (the one we want to use )
if (!strcmp(cIFType, (const char*)I2cGetInterfaceTypeStr(InterfaceGUID)))
break; FirstGUID = I2cGetNextInterface("{00DA5BA0-2540-11d1-8110-00400534438D}") ' this works gives the next string
FirstGUID = I2cGetNextInterface("") ' this returns also empty string
regards, Jan
Is it possible that GetNextInterface argument is meant to be the buffer it will write the value back to you? In that case if you provide it with something that can hold a guid it would work, and if you gave it an empty string it wouldn't have enough space and thus just return the empty string again.