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);
}
Tom Glenn - 27 May 2004 18:50 GMT
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.
> Tom,
>
[quoted text clipped - 30 lines]
> a->Man(12);
> }
Tomas Restrepo \(MVP\) - 28 May 2004 00:43 GMT
Hi Tom,
> 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.
Not quite sure what you're saying here... care to explain what you want to
do exactly in the opposite case?

Signature
Tomas Restrepo
tomasr@mvps.org