G
Guest
I have a string object that I need to convert into an unmanged char * to be
used by several unmnaged 3rd party functions.
I have tried to use: (Marshal::StringToHGlobalAuto (Profname))
This would get me an IntPtr value, but I could not find the correct way to
cast an IntPtr to an unmanged char *.
One example I tried was:
char *inifile;
inifile = static_cast <char*> (Marshal::StringToHGlobalAuto (Profname));
It gave following compile error:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(236): error C2440: 'static_cast' : cannot convert from 'System::IntPtr' to 'char *'
No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
There is another wrinkle on top of this, which I am hoping wont be a problem
once I figure the above example out. That is the parameter to function is
defined as a COMSTR which is a typedef to char far *.
The only reason profname is a string is that it is created and passed to
this function through a managed class and I could not get the managed class
to correctly keep a unmanaged char array.
Thanks,
Brian
used by several unmnaged 3rd party functions.
I have tried to use: (Marshal::StringToHGlobalAuto (Profname))
This would get me an IntPtr value, but I could not find the correct way to
cast an IntPtr to an unmanged char *.
One example I tried was:
char *inifile;
inifile = static_cast <char*> (Marshal::StringToHGlobalAuto (Profname));
It gave following compile error:
c:\T02010_NET_ora9\cgi-bin\programs\TimeReader\TimeReaderWinService.cpp(236): error C2440: 'static_cast' : cannot convert from 'System::IntPtr' to 'char *'
No user-defined-conversion operator available that can perform this
conversion, or the operator cannot be called
There is another wrinkle on top of this, which I am hoping wont be a problem
once I figure the above example out. That is the parameter to function is
defined as a COMSTR which is a typedef to char far *.
The only reason profname is a string is that it is created and passed to
this function through a managed class and I could not get the managed class
to correctly keep a unmanaged char array.
Thanks,
Brian