interop

How do you write a Module Definition File in Visual C++ ?

Here is the code for my head file... #pragma once #pragma unmanaged __declspec(dllexport) public void CallMe(wchar_t *p); Here is all the code SO FAR for my definition file... LIBRARY "CppWrapper" My "CallMe" function's name compiles to "?CallMe@@YAXPA_W@Z". What do I need to add/write in my .def file to correct the compiled name ...

Delphi 5 calling C++ dll causing Access Violation

Here is the Delphi code calling the C++ dll... implementation {$R *.DFM} procedure CallMe(x: Integer); stdcall; external 'CppWrapper.dll'; procedure TForm1.Button1Click(Sender: TObject); begin CallMe(1); end; end. Here is the error message...(Access Violation at 00000001. Read of Address 00000001.) The CallMe procedure exec...

C#: Send input from inactive window.

I'm trying to send input from a WPF Window which doesn't have focus. The idea is to create a virtual numpad, whereby pressing Alt+M for example sends Alt+Numpad0. I've got Michael Kennedy's global hooks working, but I can't find a way to: 1) Send keys from an inactive window 2) Swallow these keys so they're not processed by the applicati...

how to pass parameters to a function in a .net dll via COM/VB6?

hi guys, i have a .net dll written in c# which reads data off a data source and acts as a wrapper to allow other apps to call its function to retrieve those data. the thing is i didn't anticipate the .net dll to be used for other than .net apps, so now i was told this all is going to be used in a vba/powerpoint macro which i figure is r...

What happens if I marshal a null pointer using the [MarshalAs(UnmanagedType.LPStr)]

If I try a marshal a string that is really a NULL pointer, what will happen? ...

Programmatically (C#) convert Excel to an image

Hi, I want to convert an excel file to an image (every format is ok) programmatically (c#). Currently I'm using Microsoft Interop Libraries & Office 2007, but it does not support saving to an image by default. So my current work-around is as follows: Open Excel file using Microsoft Interop; Find out the max range (that contains data)...

COM Interop, DllImport vs. Adding a reference

I'm trying to get into COM interop So, there is a simple example: SpeechLib.SpVoice voice = new SpVoice(); voice.Speak("Hello sucker!",SpeechVoiceSpeakFlags.SVSFDefault); Of course I have to add reference to %windir%\system32\speech\common\sapi.dll before, and VS will add Interop.SpeechLib.dll to the project folder, and now I hav...

Create Native DLL

I'm C# programmer, and don't introduce with Native. I have a Native DLL, & I'v to use that in my project, but cause some of types are impracticable in Managed code. I'll to prepare a DLL in Native(C++), and I want when an event occure, then aware my Managed Code; How can I do that? ...

Loading .net 3.5 wpf-forms in a .net 2.0 application

I'm trying to load and host a WPF control in a .net 2.0 windows forms application. The WPF control should only be loaded if .net 3.5 is installed. I found a link to Hosting WPF Content in an MFC Application and that is about what I'm trying to do but my C++ knowledge isnt sufficient to be able to 'translate' it to .net. Anyway, here is...

Marshalling BSTRs from C++ to C# with COM interop

I have an out-of-process COM server written in C++, which is called by some C# client code. A method on one of the server's interfaces returns a large BSTR to the client, and I suspect that this is causing a memory leak. The code works, but I am looking for help with marshalling-out BSTRs. Simplifying a bit, the IDL for the server metho...

Calling Windows SDK GetGlyphIndices from VB.Net

I am calling GetGlyphIndices from Vb.Net. I am using a single character string. I get the correct value in the indices array for the character '6' but not for characters requiring 2 bytes to be returned. Does anyone have any experience with this API call? My next step is to write the C equivalent and make sure I can get it working witho...

Inspecting an instance of a COM / Interop class properly in VS.Net's debugger?

Good afternoon, does anyone know if and how it's possible to see COM / Interop objects properly (in their correct type) in VisualStudio's debugger? All I get is the 'evil' System.__ComObject value (even though it correctly identifies the type)? E.g.: ...

Convert Interface IDL file to C#

I have an interface defined in an IDL file that I would like to use in C#. Is there a way to convert the IDL to something usable in C#? ...

How to make Taskbar Flash on Lost Focus

I stumbled on this code below and tried to implement it in my WinForm App to help my users as many are very NOT tech-savy. Unfortunately, it does nothing. It does not generate any errors or anything. It just doesn't make it Flash. Can anyone offer any insight? I have tried it on Win 7(x64) & Win XP (x86) with the same results on ...

Recieve a message FROM another process.

I've been teaching myself how to use messages with Window's APIs, and have actually been doing very well learning them. Problem is, I can't figure out how to receive a message from another application to start code within mine. Essentially, what I want to do is allow others using a commercial application to click the save button (on the...

Adding a COM Reference with Visual Studio renames interfaces in Interop Assembly

Hey all, I'm adding a C++ COM dll as a reference to a C# project (Visual Studio 2008). VS adds the reference however the generated interop library does not reflect the naming in the original typelib (.idl) definition. Here's what my library definition looks like: [ uuid(...), helpstring("MyLib") ] library MyLib { [ uuid(......

Setting dllimport programatically in c#

I am using DllImport in my solution. My problem is that I have two versions of the same DLL one built for 32 bit and another for 64 bit. They both expose the same functions with identical names and identical signatures. My problem is that I have to use two static methods which expose these and then at run time use IntPtr size to determi...

Firebird .NET interoperation

Has anyone had experience with using Firebird in interoperating with the .NET framework and if so, how did it go? ...

HwndSource does not display the Adorner layer

When I host WPF controls that use adorners (the error border of the textbox) in a HwndSource the adorners are not shown. It seems that the adorner layer is not there. Why is that so and what can I do against it? Is this a known bug? ...

Send keys to WPF Browser control

Can I programatically send [UserID]{TAB}[Password]{CARRIAGE RETURN} to a webbrowser control which has a userID, password and Sign-in button there. I wanted to use my own virtual keyboard in my application. Any tips here? ...