G
Guest
Hi there,
I'm having a bit of trouble using an HRASCONN object as a class member
variable inside my managed C++ class. When I call RasDial() and pass in the
address of my HRASCONN object, I get the following compiler error from Visual
C++ 2005:
error C2664: 'RasDialW' : cannot convert parameter 6 from
'cli::interior_ptr<Type>' to 'HRASCONN *'
Here is my code snippet:
RasInterface.h:
--------------------
#include <ras.h>
private ref class RasInterface
{
private:
HRASCONN _rasConnection;
....
};
RasInterface.cpp:
-----------------------
void RasInterface:ial()
{
....
DWORD result = RasDial(NULL, NULL, _dialParams, NULL, NULL,
&_rasConnection);
....
}
My question is: Do I need to use a pin_ptr<> here? After some
investigation, I tried the following:
pin_ptr<HRASCONN> rasConnectionPinned = &_rasConnection;
DWORD result = RasDial(NULL, NULL, _dialParams, NULL, NULL,
rasConnectionPinned);
This compiles and appears to run correctly, but is this The Right Thing To
Do? Thanks in advance for any thoughts!
I'm having a bit of trouble using an HRASCONN object as a class member
variable inside my managed C++ class. When I call RasDial() and pass in the
address of my HRASCONN object, I get the following compiler error from Visual
C++ 2005:
error C2664: 'RasDialW' : cannot convert parameter 6 from
'cli::interior_ptr<Type>' to 'HRASCONN *'
Here is my code snippet:
RasInterface.h:
--------------------
#include <ras.h>
private ref class RasInterface
{
private:
HRASCONN _rasConnection;
....
};
RasInterface.cpp:
-----------------------
void RasInterface:ial()
{
....
DWORD result = RasDial(NULL, NULL, _dialParams, NULL, NULL,
&_rasConnection);
....
}
My question is: Do I need to use a pin_ptr<> here? After some
investigation, I tried the following:
pin_ptr<HRASCONN> rasConnectionPinned = &_rasConnection;
DWORD result = RasDial(NULL, NULL, _dialParams, NULL, NULL,
rasConnectionPinned);
This compiles and appears to run correctly, but is this The Right Thing To
Do? Thanks in advance for any thoughts!