Smart Device Functions:
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.
Changes an oleautomation variant (.NET an object) to a specific oleautomation compliant type, e.g. VT_BSTR (vbString) .
Very handy to convert a reference to a Dispatch interface to a string (which is in fact the result of recursive Invoke(s) to the DISPID(0).
private extern static int VariantChangeTypeEx([MarshalAs(UnmanagedType.Struct)]out object pvargDest,
Declare Function VariantChangeTypeEx Lib "oleaut32.dll" (TODO) As TODO
Alternative Managed API:
The alternative would be lots of invokes on an imported IDispatch interface if the source type is an object (Dispatch) and lots of conversion checks. Some of them could be converted using Convert.ToString(), however Convert.ToString() would not deal with Dispatch types.
See also VarBstrFromDisp
Tips & Tricks:
There is a lot to write about automation variables. E.g. a parameter can be optional and thus, have a default value which is in the TYpeLib. Or VT_ERROR | DISP_E_PARAMNOTFOUND (which is equivalent to VarType() = vbMissing). This is passed to .NET as Type.Missing. See sample code.
The SetLastError API
6/17/2013 12:06:05 PM - -188.8.131.52
Handy function Invoke the default value(s) on a ComObject reference within C#/VB.NET. The full code to retrieve DispId(0) (Default Value) from a Dispatch interface is ugly. This pinvoke is elegant and quick. Also supported on 64 bit of course.
3/17/2012 10:29:13 AM - -184.108.40.206
Please edit this page!
Do you have...