pinvoke

MAPI and managed code experiences?

Using MAPI functions from within managed code is officially unsupported. Apparently, MAPI uses its own memory management and it crashes and burns within managed code (see here and here) All I want to do is launch the default e-mail client with subject, body, AND one or more attachments. So I've been looking into MAPISendDocuments and ...

FlashWindowEx FLASHW_STOP still keeps taskbar colored

I am developing an application that controls an Machine. When I receive an error from the Machine the users should be able to directly notice it, one way that is done is Flashing the tray on the taskbar. When the machine clears the error the tray should stop flashing. There's one little annoyance using the FlashWindowEx function, when I...

P/Invoke in Mono

What's the current status of Mono's Platform Invoke implementation on Linux? And on Solaris? ...

Best programming language to write a Windows File Manager app.

I would like to write my own file manager i.e. something like what XYplorer or Free Commander does but with a feature set that's more helpful to programmers. What's the best language to write this. I'm basically looking for a language that has both rich GUI libraries and a nice wrapper library over the Windows Shell API. I tried with C...

C# P/Invoke with Variants

Anybody know what my DLLImport statement should look like here: extern "C" __declspec(dllexport) long SomeFunction(VARIANT *argNames, VARIANT *argValues, VARIANT *pVal) { ... } ...

Is there a .NET performance counter to show the rate of p/invoke calls being made?

Is there a .NET performance counter to show the rate of p/invoke calls made? I've just noticed that the application I'm debugging was making a call into native code from managed land within a tight loop. The intended implementation was for a p/invoke call to be made once and then cached. I'm wondering if I could have noticed this mist...

How can I determine the current focused process name and version in C#

For example if I'm working on Visual Studio 2008, I want the values devenv and 2008 or 9. The version number is very important... ...

How do you extract an RT_RCDATA section from a Win32 executable (preferably in C#)?

The only way I know how to do this currently is opening up the EXE in Visual Studio. I'd love to be able to do this entirely in C# if possible. Other options include: P/Invoking LoadResource() from the Win32 API Using an existing tool (anybody know one?) Other ideas? Thanks! ...

How do I pInvoke the function SHCameraCapture (camera dialog) from Aygshell.dll from WinMO6

I need to show a camera capture dialog in a compact framework 3.7 application by pinvoking SHCameraCapture from the dll Aygshell.dll. I cannont use the managed object CameraCaptureDialog because of limitations with the technology I'm working with. Instead, I need to access it by Pinvoking it. See http://msdn.microsoft.com/en-us/librar...

Available space left on drive - WinAPI - Windows CE

Hi, I've forgotten the WinAPI call to find out how much space is remaining on a particular drive and pinvoke.net isn't giving me any love. It's compact framework by the way, so I figure coredll.dll. Can anyone with a better memory jog mine? ...

How do I call a Win32 Function in PowerShell 1.0 using P/Invoke?

There are many scenarios where it would be useful to call a Win32 function or some other DLL from a PowerShell script. to Given the following function signature: bool MyFunction( char* buffer, int* bufferSize ) I hear there is something that makes this easier in PowerShell CTP 2, but I'm curious how this is best done in PowerShell 1.0...

Using P/Invoke correctly

Hi, I need to call an external dll from c#. This is the header definition: enum WatchMode { WATCH_MODE_SYSTEM = 0, WATCH_MODE_APPLICATION = 1 }; LONG ADS_API WDT_GetMode ( LONG i_hHandle, WatchMode * o_pWatchMode ); I've added the enum and the call in C#: public enum WatchMode { WATCH_MODE_SYSTEM = 0, WAT...

Marshal "char *" in C#

Given the following C function in a DLL: char * GetDir(char* path ); How would you P/Invoke this function into C# and marshal the char * properly. .NET seems to know how to do LPCTSTR but when I can't figure out any marshaling that doesn't cause a NotSupportedException to fire when calling this function. ...

Why does handling WM_NCCALCSIZE cause my window to jump?

I have a WPF app which snaps to screen edges (I just set the .Top or .Left of the window if you're within 20 pixels of the screen edge), but I recently added some code provided by the WPF SDK Team to "mess" with the window chrome, and although it's working great (screenshot), it's causing the "snapto" to move the window unexpectedly (e.g...

Instantiating a C++ class in C# using P/Invoke via a pointer

I am importing the CreateICeeFileGen() function from the unmanaged DLL mscorpe.dll in a C# application, in order to generate a PE file. This function returns a pointer to an C++ object defined here, is there any way I can access fields from this class via C# or do I need to write an unmanaged wrapper DLL? The code I'm using currently i...

DLLImport Int** - How to do this if it can be done.

I am trying to use a third party DLL that wants an int** as one of the parameters to the method. It describes the parameter as the address of the pointer that will point to the memory allocation. Sorry for any confusion. The parameter is two-way I think. The DLL is for talking to an FPGA board and the method is setting up DMA transfe...

Should I use Ansi or Unicode charset with dllimport?

When you use DllImport to import a function you can specify a CharSet to use. I noticed that in C#, C++ and visual basic the .Net runtime defaults to using Ansi instead of Unicode for this. So for any system call that has an A and a W version the A version will be called by default. .Net uses unicode internally and if I'm not mistaken ne...

C# invoking CPP function with unknown number of args from CPP

i have a function in CPP with the following prototype: char* complexFunction(char* arg1, ...); i import it from a C# using DLLImport attribute. the questions are: how do i define the prototype in the C# (under the DLLImport attribute)? how do i pass the arguments to this function? thanks ...

Pointer math in C#

I am trying to use some pinvoke code to call a C function. The function fills a buffer with data. The structure is set up as a DWORD for the length, followed by a string. How do I extract the string from the IntPtr? IntPtr buffer = Marshal.AllocHGlobal(nRequiredSize); PInvokedFunction(buffer, nRequiredSize); string s = Marshal.Ptr...

CUDA for .net?

I know that there are a lot of CUDA language bindings, such as PyCUDA, but are there any good bindings for .Net? The only one I've seen is this one, but I'd like to know if there are any others. ...