interop

How can I write a generic C function for calling a Win32 function?

To allow access to the Win32 API from a scripting language (written in C), I would like to write a function such as the following: void Call(LPCSTR DllName, LPCSTR FunctionName, LPSTR ReturnValue, USHORT ArgumentCount, LPSTR Arguments[]) which will call, generically, any Win32 API function. (the LPSTR parameters are essentially be...

Getting this Win32 Interop code to work under Mono?

So i have this code in a .NET 2.0 console app: [DllImport("kernel32.dll")] private static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput, int wAttributes); [DllImport("kernel32.dll")] private static extern IntPtr GetStdHandle(uint nStdHandle); private static readonly IntPtr hConsole; And then in a method i have this...

Where can I find an AS400 to Java interface?

Does anyone have links and resources to connect to an AS400 from Java? I remember years ago, somebody told me about a connector that simulates KeyStrokes from the keyboard and other "purest" approach that connected directly. On the web I have found a lot of links, but I cannot find a complete product to do this (I am probably not usin...

Return array of objects from VB6 to C# using Interop

I need to return an array of initialized objects from VB6 into C# using interop. My VB function looks like Public Function CreateMyObjArray(ByVal MaxCount As Integer) As MyObj() Dim i As Integer Dim temparray() As MyObj ReDim temparray(MaxCount) As MyObj For i = 0 To MaxCount Set temparray(i) = New MyObj Next i Crea...

Converting Excel to PDF with VS2008 and Office2007

I am trying to use Interop.Excell to save an Excel Workbook as a PDF file. I am using VS2008 and Office2007, and have downloaded and installed the SaveAsPDFandXPS.exe from Microsoft. This enabled me to save a Word document as a pdf using the following code: object frmt = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatPDF; ...

Best way to consume .NET web services in Java

I'm trying to consume some .NET web services using JAX-WS. I have generated the Java classes using the wsimport tool. However, when I try to use these (proprietary, not public) web services in Java, I notice that most of the methods and properties provided by the vendor in their C# examples are not avaiable in the generated classes (desp...

Is there a way to get the number of sub items in a listview?

I am writing a C# application that needs to extract data from a ListView control that resides in an external process. I already have the code to extract data and get the number of items in a ListView but I need the equivalent of the following for sub items: public int GetListViewRowCount() { if (list_view_handle != null...

Running Word from a SharePoint Workflow

Hi All, based on http://stackoverflow.com/questions/630449/join-ms-word-documents I have made a console application that splices multiple word files into one. Now I want to do the same from a Workflow in SharePoint. In short, my code before it fails looks like this: object oMissing = System.Reflection.Missing.Value; Microsoft.Office.Int...

Should I use ReAllocHGlobal or FreeHGlobal/AllocHGlobal?

The legacy database that I'm interfacing with uses a data buffer to pass rows to applications. To handle this in C#, I wrote a class that provides methods for reading and writing different types in the buffer. Each data file uses one data buffer, but the buffer has to be resized for certain operations. To do this, I added an Allocate met...

Get the number of bytes stored in a block of memory?

I'm allocating a block of memory in C# to retrieve information from an unmanaged data buffer: handle = Marshal.AllocHGlobal(33455); The maximum size of the information retrieved is 33,455 bytes, but the size of the information may be smaller than that in some cases. How can I determine how many bytes are actually being used in the al...

How do I disable ALL .NET security policies?

I'm trying to replace a old homebrewed single threaded web server with a ASP.NET solution that will run on IIS. The old server does alot of weird stuff like access files outside it's path, do com calls, write to c: and much more. It does all of this from library writen in C++. In the new application we want to use the same library so we...

Memory leaks in a multi-threaded application using COM & C#

I have written a multi thread unmanaged application which uses COM objects in its worker threads. Everything went fine until I started using .NET objects exported as COM to do the work. Playing around with the code and commenting out parts of the .NET object functionality I managed to pin it down to the usage of COM objects from within...

Using Scripting.Dictionary from C#

I need to pass a Scripting.Dictionary between my C# app and another app. I would like to be able to create instances of and modify the dictionary in my C# app. I know little about Scripting.Dictionary and ActiveX in general. Various forums suggest that I should use functions like System.Type.GetTypeFromProgID() and System.Activator.Crea...

Send C++ string to C# string. Interop.

I am new to inter process communication and need some help. I want to be able to send a string from a C++ program to a C# program. My problem is that the resultant string is gibberish. Here is my code: Sending program (C++): void transmitState(char* myStr) { HWND hWnd = ::FindWindow(NULL, _T("myApp v.1.0")); if (hWnd) {...

Where is the System.Windows.Forms.Integration namespace?

I can't seem to find it, trying to keyboard input in a wpf form spawned from a winforms form. Found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/442782b1-00a1-4e2e-9cc6-ae99b6699126/ But when I try to use it, VS2008 complains about not being able to find the System.Windows.Forms.Integration namespace. I couldn't find ...

Establishing communication between Java client and .NET server

Hi, I would like to create a server using .NET and Java client (Android application). The client will be connected to the server through mobile network so it's impossible to use tcp socket for two-way communication. I would like to develop a logic for client login: The client sends username and password to the server and server repli...

Where does IDispatchEx exists?

Hi, Can't find the library which contains IDispatchEx interface. I want to implement this interface, but can't find it. Does anyone knows where it is? Thanks, Paul. ...

Why IExpando.AddMethod was not called?

Hi, I'm hosting my WinForms control in Internet Explorer. Additionally I've implemented IExpando interface to be able to emulate unexisted fields and methods in my C# code when javascript code try to access them. For example var myobj = new ActiveXObject('server.object'); myobj.Foo = "FooText"; myobj.Bar("BarText"); Note that my C# c...

How to return a JavaScript 'native' array from a C# method?

I'm trying to call a C# method from JavaScript by using ActiveXObject: var myobj = new ActiveXObject('myobject'); var arr = myobj.GetArray(); Eventually, arr will contain a SAFEARRAY object, but not JScript array. Is there any way to return native JavaScript object from a C# method? ...

Open file without (really) locking it?

Is it possible to open a file in a way that allows subsequent deletion/renaming of its parent folder? I know you can do this: File.Open("foo.bar", FileMode.Open, FileAccess.Read, FileShare.Read | FileShare.Delete) Which will allow for the file to be deleted when the file handle is closed. However, if it does not allow the parent fol...