unmanaged

Concatenating a string and byte array in to unmanaged memory.

This is a followup to my last question. I now have a byte[] of values for my bitmap image. Eventually I will be passing a string to the print spooler of the format String.Format("GW{0},{1},{2},{3},", X, Y, stride, _Bitmap.Height) + my binary data; I am using the SendBytesToPrinter command from here. Here is my code so far to send it t...

Calling unmanaged code from .NET

I am trying to use a dll in my c# program but I just cant seem to get it to work. I have made a test app shown below. The return value is 0, however it does not actually do what it is supposed to do. Whereas the following command does work: rundll32 cmproxy.dll,SetProxy /source_filename proxy-1.txt /backup_filename roxy.bak /DialRasEnt...

Calling unmanaged dll from C#. Take 2

I have written a c# program that calls a c++ dll that echoes the commandline args to a file When the c++ is called using the rundll32 command it displays the commandline args no problem, however when it is called from within the c# it doesnt. I asked this question to try and solve my problem, but I have modified it my test environment ...

ERROR_MORE_DATA --- PVOID and C# --- Unmanaged types.

How can I get the value from the following DLL? offreg.dll. In my below code, I have successfully opened the hive, the key and now I am trying to get the value of the key and I keep running into the ERROR_MORE_DATA (234) error. Here is the C++ .dll: DWORD ORAPI ORGetValue ( __in ORHKEY Handle, __in_opt PCWSTR lpSubKey, ...

Create unmanaged c++ object in c#

I have an unmanaged dll with a class "MyClass" in it. Now is there a way to create an instance of this class in C# code? To call its constructor? I tried but the visual studio reports an error with a message that this memory area is corrupted or something. Thanks in advance ...

Marshalling to a native library in C#

I'm having trouble calling functions of a native library from within managed C# code. I am developing for the 3.5 compact framework (Windows Mobile 6.x) just in case this would make any difference. I am working with the waveIn* functions from coredll.dll (these are in winmm.dll in regular Windows I believe). This is what I came up with:...

allocating "unmanaged" memory in c#

Hi, I'm writting a program in c# that uses a C++ library, and for some reason I need to allocate an unmanaged buffer to pass it to the lib. Is there a way to do this in c# ? Basically I would just need to do a malloc in C#... Thanks ...

Receiving an object in a unmanaged callback function

Eg. I have following delegate method I want to use as a callback function with unmanaged code: public delegate void Callback(IntPtr myObject); Callback callback; I register it in the following way: [DllImport("a.dll")] public static void registerCallback(IntPtr callbackFunction, IntPtr anObject); // ... this.myObject = new MyClas...

How do I find out what the windows constants like WM_MOUSEMOVE and WM_MOUSEDOWN are if I'm using C#?

I'm writing some code that uses some unmanaged calls into user32 functions such as SetWindowsHookEx, etc. This requires me to use lots of constants that I'm not sure what their value is. For example, if I want to set the hook as a low-level mouse hook I need to know that WM_MOUSE_LL = 14. Where can I look these up? I need to know wha...

How to pass SAFEARRAY of UDTs to unmaged code from C#.

I also used VT_RECORD. But didn't got success in passing safearray of UDTs. [ComVisible(true)] [StructLayout(LayoutKind.Sequential)] public class MY_CLASS { [MarshalAs(UnmanagedType.U4)] public Int32 width; [MarshalAs(UnmanagedType.U4)] public Int32 height; ...

MFC Dll with COM Interface

Hi All, I am pretty new to managed/unmanaged interoperability and COM concepts. I received a suggestion of using COM Interop, for using my existing MFC code in C#. But the problem for me is, i have a MFC Dll which is not a valid COM component. How to make this MFC DLLs to have COM-accessible interfaces ready for use in .NET. I tried t...

How do I combine an unmanaged dll and a managed assembly into one file?

SQLite from PHX Software has combined a managed assembly (System.Data.SQLite) with an unmanaged dll (the SQLite 32- or 64-bit dll) into one file, and managed to link them together. How do I do this? Do I need to embed the managed assembly into the unmanaged dll, or vice versa? ie. my questions are: In which order do I need to do this...

How to call a unmanaged C++ exe from managed c++ exe.

Please tell me how to call a unmanaged c++ exe functions from managed c++ exe or dll? help with code example would be more useful. Thank you ...

what's the best way to consume an axis 1.3 web service using visual studio 2005 in c++

Hi I'm trying to consume an axis web service in VS 2005 & unmanaged c++.. The inbuilt sproxy.exe in VS falls over with a namespace error as the input/output namespaces are different.. though if I consume the web service in c# it works fine.. i've investigated gSOAP as well as Axis C++ both seem rather complex for what I need All the...

Managed form as child of unmanaged HWND

I need to show my System.Windows.Forms.Form as a child window of an unmanaged C++ HWND. This is the C# SDK code that retrieves the NativeWindow: public static NativeWindow MainWindow() { Diagnostics.Process process = Diagnostics.Process.GetCurrentProcess(); if (null == process) return null; IntPtr handle = process.MainWindowHa...

Calling member method on unmanaged C++ pointer from C# (I think)

I apologize in advance if this is a trivial question... I'm pretty C++ / unmanaged dumb. Here's a simplified analog to my setup: --In myUnmanagedObject.h in DLL: class myUnmanagedObject { public: virtual void myMethod(){} } --In MyControl.h in Assembly #1: #pragma make_public(myUnmanagedObject) [event_source(manag...

How to capture the event if a new process (application!) is started?

I would like to have some eventhandler which raise if a new application is started. I've heard that this is possible by using a hook but the only examples I can find are based on mouse/keyboard events. What is an example link of how I can create such a hook in C#? Oh and btw: Nope, I don't want to use WMI which could be a solution as w...

Abort call to unmanaged DLL

I have an unmanaged DLL with a function that can run for a long time if the input parameter is a large value, sometimes that is desirable but not always. How can I in c# call this function so that I can abort it when needed? So far I have tried to put the call in a separate thread, but neither interrupt nor abort seem to stop the proce...

In a Visual Studio C++ project with /clr, are its dependencies also compiled to managed code?

To be a bit more clear. If I have a Visual Studio C++ solution that has two projects, say a static library with CLR support turned off, and a second project with CLR support turned on that depends on this static library, does the static library get compiled as managed code? What about libraries that the CLR project uses that are external...

Unmanaged DLL in C# Web Service

Hi Guys, please help με as I am new into accessing an unmanaged DLL from C#.. I have a large unmanaged DLL in C++ and I am trying to access the DLL's classes and functions from a C# Web Service. I have seen many examples how to use DLLImport, but for some reason I am stuck with my very first wrapper method spending many hours with no l...