Gemeinsam zu mehr Effizienz in der Anwendungserstellung
K |
K |
||
Zeile 1: | Zeile 1: | ||
* Object statt Variant in COM Interface: <code>[MarshalAs(UnmanagedType.IDispatch)]</code> | * Object statt Variant in COM Interface: <code>[MarshalAs(UnmanagedType.IDispatch)]</code> | ||
- | + | <source lang="csharp">void CallTestByName(string procName, [MarshalAs(UnmanagedType.IDispatch)] out object test2Add);</source> | |
+ | * ByRef-Übergabe mit InvokeMember und Application.Run: ParameterModifier verwenden - damit kann ByRef markiert werden | ||
+ | <source lang="csharp">object[] parameters = { getTestClassFactoryProcedureName(className), new Object() }; | ||
+ | ParameterModifier p = new ParameterModifier(2); | ||
+ | p[1] = true; | ||
+ | ParameterModifier[] modifiers = { p }; | ||
+ | |||
+ | OfficeApplication.GetType().InvokeMember("Run", BindingFlags.InvokeMethod, null, OfficeApplication, | ||
+ | parameters, modifiers, null, null);</source> |
[MarshalAs(UnmanagedType.IDispatch)]
void CallTestByName(string procName, [MarshalAs(UnmanagedType.IDispatch)] out object test2Add);
object[] parameters = { getTestClassFactoryProcedureName(className), new Object() }; ParameterModifier p = new ParameterModifier(2); p[1] = true; ParameterModifier[] modifiers = { p }; OfficeApplication.GetType().InvokeMember("Run", BindingFlags.InvokeMethod, null, OfficeApplication, parameters, modifiers, null, null);