Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than oleaut32, prefix the name with the module name and a period.
VarBstrFromDisp (oleaut32)
.
C# Signature:
[DllImport("oleaut32.dll", SetLastError=false, ExactSpelling=true)]
static extern int VarBstrFromDisp(IntPtr Disp, int lcid, int dwFlags, [MarshalAs(UnmanagedType.BStr)] out string pbstrOut);
VB Signature:
Declare Function VarBstrFromDisp Lib "oleaut32.dll" (Byval Disp as IntPtr, Byval lcid As Integer, Byref pbstrOut as String) As Integer
User-Defined Types:
None.
Alternative Managed API:
There is no alternative API in .NET except for Dispatch Invoke the default value (DispId == 0)
However, you could use the dynamic keyword. But this expects you to know the name of the default property. (Which can be Value but Text or any name as the original Dispatch interface developer (eg in VB6) had intended to).
Notes:
The sample cannot be used on DCOM (remote COM). It is not tested.
Tips & Tricks:
Please add some!
Sample Code:
object pComObject = rs.Fields[0]; // ADODB COM stuff
if (Marshal.IsComObject(pComObject)) // shows as System.__ComObject
{
string pbstrOut;
int hr = VarBstrFromDisp(Marshal.GetIDispatchForObjectInContext(pComObject), Thread.CurrentThread.CurrentCulture.LCID, 0, out pbstrOut);
if (hr != 0)
{
Marshal.ThrowExceptionForHR(hr);
}
}
Click to read this page
9/7/2021 12:55:49 AM - tmo793-180.150.94.207
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).