Thanks, how do you go in the opposite direction i.e. unmanaged to managed?
I can't seem to figure out how to take the length into account in this case.
"Tomas Restrepo (MVP)" <to****@mvps.org> wrote in message
news:uu**************@TK2MSFTNGP09.phx.gbl...
Tom,
I have a managed method that has an int parameter that has to be passed
to an unmanaged method that takes a PBYTE and associated length as a DWORD.
Anyone have any sample code that shows how to do this?
#using <mscorlib.dll>
#include <windows.h>
#include <iostream>
using namespace System;
#pragma unmanaged
void f(LPBYTE buffer, DWORD size)
{
std::cout << "Buffer size: " << size << std::endl;
}
#pragma managed
__gc class A
{
public:
void Man(int n)
{
f( (LPBYTE)&n, sizeof(n) );
}
};
int main()
{
A* a = new A();
a->Man(12);
}