interop

Position cursor at start/end of Word document

老子叫甜甜 提交于 2019-11-27 07:39:37
问题 We are manipulating our Word 2007 documents from .Net using Word Interop. Mostly doing stuff with fields as in: For Each f In d.Fields f.Select() //do stuff with fields here Next This leaves the last field in the document selected. So, for the sake of neatness we would like to position the cursor at the end of the document (or even the start would be OK). Googling for the answer doesn't throw up much ... the nearest I can get seems to be suggesting we need to involve ourselves with ranges or

How can I invoke a static method on a .NET object over COM interop?

白昼怎懂夜的黑 提交于 2019-11-27 07:35:37
问题 Is it possible to invoke a static method on a .NET Object, via COM interop? I know I could write a wrapper class. What if I don't wanna do that? 回答1: No you cannot do this. COM interop communicates via objects, not types. Work arounds I know of ... The best work around is to create a wrapper method on an instance to do the call on the type. Yes this still requires an instance so it defeats the purpose but it's you're best option. Reverse PInvoke: Still requires you to pass a function pointer

Best Way to Release Excel Interop com Object

♀尐吖头ヾ 提交于 2019-11-27 07:29:12
问题 Experts, Please let me know the best way I can do this... I am working on a VB.Net application that uses the Microsoft.Office.Interop.Excel Object Library to create worksheets within a workbook and Pivot Tables within those worksheets. My code looks something like this: Dim ExcelApp As New Microsoft.Office.Interop.Excel.Application Dim wbk As Microsoft.Office.Interop.Excel.Workbook = Nothing Dim wksRawData As Microsoft.Office.Interop.Excel.Worksheet = Nothing Dim wksPvtTbl As Microsoft.Office

How to use MS UI Automation in Delphi 2009

不问归期 提交于 2019-11-27 07:26:38
问题 I have a C# application, which uses Microsoft UI Automation functionality, e. g. a call like AutomationElement.RootElement.FindFirst(...) . Now I need to do the same thing (use MS UI Automation) in Delphi 2009. How can I a) declare that my Delphi code uses MS UI Automation library and b) make calls like AutomationElement.RootElement.FindFirst(...) ? There are several tutorials (tutorial 1, tutorial 2) explaining how to package one's own .NET code so that it can be used with Delphi, but in my

How do I marshall a pointer to a pointer of an array of structures?

天大地大妈咪最大 提交于 2019-11-27 06:51:33
问题 My C declarations are as follows: int myData(uint myHandle, tchar *dataName, long *Time, uint *maxData, DATASTRUCT **data); typedef struct { byte Rel; __int64 Time; char Validated; unsigned char Data[1]; } DATASTRUCT ; My C# declarations are as follows: [DllImport("myData.dll", EntryPoint = "myData")] public static extern int myData(uint myHandle, [MarshalAs(UnmanagedType.LPTStr)] string dataName, out long Time, out uint maxData, ref DATASTRUCT[] data); [StructLayout(LayoutKind.Sequential,

How do I get an entire column in used range?

为君一笑 提交于 2019-11-27 06:41:25
问题 I am trying to get a column, but limiting it to used range... public static Excel.Application App = new Excel.Application(); public static Excel.Workbook WB; WB = App.Workbooks.Open("xxx.xls", ReadOnly: true); var sheet = (WB.Sheets[1] as Excel.Worksheet); // returns 65536 rows, I want only 82 (used range) sheet.get_Range("F:F"); sheet.UsedRange.get_Range("F:F").Rows.Count; // 65536 How can I get it? 回答1: You can use sheet.UsedRange.Columns[6, Type.Missing].Rows.Count or this sheet.UsedRange

Overloads in COM interop (CCW) - IDispatch names include suffix (_2, _3, etc)

拟墨画扇 提交于 2019-11-27 06:27:13
问题 I have a managed assembly containing a few classes, and those classes have overloaded methods. I expose the assembly to COM/IDispatch callers via [ComVisible(true)] ..and also setting the proper Guid, on the assembly itself. I do not define an explicit interface for the COM interop. It's all done dynamically. I run regasm.exe /codebase on the managed DLL and it registers it for COM interop. When I run OleView, I can see the ProgId's of the various classes in the assembly. But, browsing into

How to cast System.Object[*] to System.Object[]

坚强是说给别人听的谎言 提交于 2019-11-27 06:14:02
问题 When I Tried to return an Array in VFP9 language COM/DLL to my .NET C# project I receive a System.Object[*] array and I can not cast to System.Object[] (Without asterisk). 回答1: Timwi's solution should work fine. You can do something a bit simpler using Linq: object[] newArray = sourceArray.Cast<object>().ToArray(); In case you need to recreate a System.Object[*] to pass it back to VFP, you can use this overload of the Array.CreateInstance method: public static Array CreateInstance( Type

Excel dll for Microsoft.Office.Interop.Excel

会有一股神秘感。 提交于 2019-11-27 06:11:49
问题 We want to use Microsoft.Office.Interop.Excel in our web application. Everything works fine on our local machines, but on our test machine we're running into problems. It has neither Visual Studio nor Office installed on it. We're using .NET framework 2.0 and the server is running on Windows Server 2003 with IIS6. Is there a dll that needs to be installed on the machine or added to the bin of the web application? 回答1: You will need to have MS Office and the Office Interop assemblies installed

C# get the list of unmanaged C dll exports

白昼怎懂夜的黑 提交于 2019-11-27 06:08:11
问题 I have a C dll with exported functions I can use the command-line tool dumpbin.exe /EXPORTS to extract the list of exported functions, and then use them in my C# code to (successfully) call these functions. Is there a way to get this exported-functions-list directly from .NET, without having to use an external command-line tool? Thanks 回答1: As far as I know there is no class in the .Net Framework that provides the information you need. However you can use the platform invocation services