unmanaged

Best practice of sending array from native code to managed code(C++/CLI)?

I'm writing a win32 dll for read/write USB HID device. The data for exchange is a 64 byte unsigned char array. The client program is written in C++/CLI. In order to achieve max speed and minimum overhead, I need an efficient way to sending the array to managed client. There are two options I can think of right now: Native: use PostMe...

What is an un/managed DLL? What is un/managed code?

Could someone please explain? Thank you. ...

C++, unmanaged, class, members: How (if at all) can I list all the members in a class?

Possible Duplicate: Iterate through struct variables. So I have a header file and a code file. The class is representation of a View that will be queried from stored proc. For each col. in view there is one data member in class. Currently in code we have something like this: Load( Reader reader) { m_col1 = reader("m_col1...

Is it possible to use attributes in unmanaged code?

I have an unmanaged C++ application (unmanaged meaning: not using anything of the the fancy .Net stuff). I want to extend it with some meta information, and it looks like I could use the concept of attributes. What I actually try to achieve is the following. Starting from something a simple class like this: class Book { public: ...

Do native method reference have to be disposed - and if so are there any recommended practices to do so

I have a class which uses a method in user32.dll: [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr windowHandlerPtr); According to Effective C#, should all classes which uses unmanaged code implement both IDisposable and a finalizer. Without going into the details in that d...

Can a managed handle be passed to an unmanaged process using pipes and DuplicateHandle?

I have been Googling on and off for a few weeks...searching for answer and not finding anything that fits my needs precisely. So, I'll ask the experts here. I currently have a managed (C#) Windows application that contains an image viewer in the main form. At present, the application uses PInvoke to pass a handle to its viewer down to ...

Code Coverage when using NUnit to test unmanaged C++

My team is currently using CppUnit for all our unmanaged C++ unit tests but I'm toying with the idea of transitioning to NUnit through either GenTestAsm (pure C#) or C++/CLI. Either way, what consequences would I face on the Code Coverage front with either of these approaches? We currently use PureCoverage to instrument our unmanaged...

What's a good reference for creating and updating Performance Counters in unmanaged code?

I have several apps that need to create and write to Performance Counters. One of them is written in C++. Currently, upgrading that app to .NET is not an option. Where is a good resource for accessing Performance Counters using unmanaged code? Thanks! ...

How to track down unmanaged heap corruption caused by VB6 application on Windows XP Pro?

Hello all. I've been having trouble with VB6, of late. I'm receiving heap corruption errors on closing the legacy VB6 application that we maintain. What I see, when I close the app, is that there was an error during run-time which, for whatever reason, didn't get reported during run-time (as we do have a pretty standard error handli...

Using unmanaged library

So in visual studio i have my solution with two projects, first one is managed c++ code and second one is unmanaged c++ library (waffles). I want to use classes from library in my managed code. If i simply add 'include "GMacros.h"', then i get 'cannot compile with /clr' error. Tried to wrap include in #pragma unmanaged/managed, but it d...

Saving image data of the fax job

I'm using WinFax.dll to send and recieve faxes in my application and it works rather well for now. The problem is that I want to Save the image information in a FaxJob but the output is not any recognizable format. I have tried with Tiff, Gif, Bmp, Png and Jpg but it is not working so I thought maybe there is a problem in how I do it. ...

Calling unsafe code from managed (C#). Reading byte array.

Hello everyone, I have this method that I need to call and use in my application, but I don't know really know how to do it exactly. This is the function that I need to call. [DllImport(dll_Path)] public static extern int DTS_GetDataToBuffer(int Position, int Length, char* Buffer, int* DataRead); In my code, I have this function and...

Wrapping a C++ DLL with a managed class.

Hi! I'm trying to wrap a unmanaged C++ DLL with managed C++ and I keep getting linking errors. even though I include my library.lib in the project and include the correct header file. This is the managed class: #pragma once #include "..\Terminal\Terminal.h" public ref class ManagedTerminal { private: Terminal * m_unTerminal; pu...

Use unmanaged FindFirstVolume to enumerate volumes in C#

I am trying to enumerate drives that are mounted without a direve letter so I can obtain the remaining space on each of the drives. This application must work with Windows XP so the Win32_Volume class is not available. When the following code is executed, a System.ExecutionEngineException is thrown. using System; using System.Text; us...

how to use ICLRStrongName in .NET 4?

Related to my previous posts I'm moving to .NET 4. I've found that using the previous StrongName.h to get my assembly signing key in unmanaged code is now deprecated, and I need to use MetaHost.h and ICLRStrongName::StrongNameTokenFromAssembly. The previous StrongNameTokenFromAssembly(..) was very straight forward, now this new one has ...

binary '=' : no operator found which takes a right-hand operand of type 'gcroot<T> *' error with VS2010

This is a Windows Forms Application project using Visual Studio 2010. That being said: I've an unmanaged 'Vector' implementation, something like: template<class T> class Vector { public: T* data; unsigned len; (...constructors and operators overloading like =, [], == and !=) }; It works great. I've done several tests bef...