interop

C++ Interop: embedding an array in a UDT

青春壹個敷衍的年華 提交于 2019-12-01 07:26:45
问题 I have an application that involves a lot of communication between managed (C#) and unmanaged (C++) code. We are using Visual Studio 2005 (!), and we use the interop assembly generated automatically by tlbimp. We have fairly good luck passing simple structs back and forth as function arguments. And because our objects are fairly simple, we can pack them into SAFEARRAYs using the IRecordInfo interface. Passing these arrays as arguments to COM methods seems to work properly. We would like to be

Disable the Save As Button in Word 2010

ぃ、小莉子 提交于 2019-12-01 07:22:53
问题 I have the following code that should disable the Save As button in Word 2010. The method below is being called in the Document_Startup event: private void DisableSaveAsButton() { Object MenuBar = 40; Object FileMenu = 1; Object SaveAsButton = 5; var saveAsBtn = this.ThisApplication.CommandBars[MenuBar].Controls[FileMenu].accChild[SaveAsButton] as CommandBarButton; saveAsBtn.Enabled = false; } I am expecting the Save as Button to be grayed out, but it isn't and it still functions. What am I

How to programatically tell if a word document is corrupt?

孤街浪徒 提交于 2019-12-01 07:19:47
问题 I've got a little C# application that interops with word converting a bunch of word .doc files into textfiles and for the most part this works fine. However, if the document is currupt then word cannot open the file and a dialog box pops up, which means that I cannot fully automate this conversion process - someone has to watch for the dialogs. Is there a way to test if a word .doc is currupt, without opening it? Perhaps through word interop or maybe through a 3rd party tool. One idea I've

Killing an interop Application process

夙愿已清 提交于 2019-12-01 06:56:23
I have the following in a program (written in VB.NET): Imports Microsoft.Office.Interop.Excel Public Class Form1 Dim eApp As New Excel.Application Dim w As Excel.Workbook w = eApp.Workbooks.Open( "path.xls", ReadOnly:=True) .. Processing Code .. //Attempts at killing the excel application w.Close() eApp.Workbooks.Close() eApp.Quit() End Class When I run this a couple of times, I get a bunch of EXCEL.EXE instances in my task manager. How can I kill these processes in code? All of the ones in the code have been tried and did not work. I had to do this a while back in NET 1.1, so please forgive

adapt wrapper class for two dimensional case

不羁岁月 提交于 2019-12-01 06:56:20
问题 This question is an extension of this question. I would like to adapt the wrapper for the two dimensional case. This is my first attempt: public class EmxArrayRealTWrapper : IDisposable { private readonly emxArray_real_T _value; private GCHandle _dataHandle; private GCHandle _sizeHandle; public emxArray_real_T Value { get { return _value; } } public EmxArrayRealTWrapper(double[,] data) { _dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned); _value.data = _dataHandle.AddrOfPinnedObject();

Help in creating Zip files from .Net and reading them from Java

允我心安 提交于 2019-12-01 06:55:20
I'm trying to create a Zip file from .Net that can be read from Java code. I've used SharpZipLib to create the Zip file but also if the file generated is valid according to the CheckZip function of the #ZipLib library and can be successfully uncompressed via WinZip or WinRar I always get an error when trying to uncompress it using the Java.Utils.Zip class in Java. Problem seems to be in the wrong header written by SharpZipLib, I've also posted a question on the SharpDevelop forum but with no results (see http://community.sharpdevelop.net/forums/t/8272.aspx for info) but with no result. Has

Passing string from C++ to C#

不问归期 提交于 2019-12-01 06:47:28
问题 I am using the PInvoke, reverse PInvoke scheme as described by Thottam R. Sriram http://blogs.msdn.com/b/thottams/archive/2007/06/02/pinvoke-reverse-pinvoke-and-stdcall-cdecl.aspx Everything seems to work well, except for passing a string from C++ to C. ( In Sriram the string is constructed in c# and passed untouched through c++, so the issue is avoided. ) The c# code looks like this class Program { public delegate void callback(string str); public static void callee(string str) { System

Is there a way for registration free activation of EXE COM components

两盒软妹~` 提交于 2019-12-01 06:47:04
Is there a way to activate a COM component which is an EXE COM application and also it's dependent COM dlls? I want to activate this COM component from .NET application(VS 2005/VS 2008). The path of call is C# application --> invoking out-of-proc exe(this is through COM) and then this out-of-proc invokes few COM dlls Reg-free COM does not work for out of process components. ActiveX EXE and ActiveX Document project types cannot be used with Reg-Free COM, as discussed in the sidebar. Simplify App Deployment with ClickOnce and Registration-Free COM Look at Microsoft Forum Registration-Free EXE

ASP.NET web app calling Delphi DLL on IIS webserver, locks up when returning PChar string

南楼画角 提交于 2019-12-01 06:37:45
Works fine if I don't return anything, or I return an integer. But if I try to return a PChar, ie.. result := PChar('') or result:= PChar('Hello') The web app just freezes up and I watch its memory count gradually get higher and higher in task manager. The odd thing is that the DLL works fine on the VStudio debug server, or through a C# app. The only thing I can think of that would make a difference is that the IIS server is running in 64bit Windows. It doesn't appear to be a compatability issue though because I can successfully write to text files and do other things from the DLL... I just

using c# to sort a column in excel

我与影子孤独终老i 提交于 2019-12-01 06:22:00
i am trying to sort a worksheet by the first column in excel using INTEROP. i just want a simple sort of the entire range by the first column. i am doing the following: valueRange.Sort(valueRange.Columns[7, Type.Missing], Excel.XlSortOrder.xlAscending, valueRange.Columns[7, Type.Missing], Type.Missing, Excel.XlSortOrder.xlAscending, Type.Missing, Excel.XlSortOrder.xlAscending, Excel.XlYesNoGuess.xlNo, Type.Missing, Type.Missing, Excel.XlSortOrientation.xlSortColumns, Excel.XlSortMethod.xlPinYin, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption.xlSortNormal, Excel.XlSortDataOption