visual studio 2008 - C++ Convert Sytem::String^ to LPCOLESTR -
i write in mixed mode (c++/cli) , can not resolve problem:
string ^progid = "matrikon.opc.server"; clsid clsid; hresult result = clsidfromprogid(progid, &clsid);
error c2664: 'clsidfromprogid' : cannot convert parameter 1 'system::string ^' 'lpcolestr'
how can convert string^
lpcolestr
?
thanks!
first, lets convert system::string char*
intptr p = marshal::stringtohglobalansi(progid); char *pnewcharstr = static_cast<char*>(p.topointer());
second, casting char * lpcolestr using atl conversion macro:
lpcolestr converted_string = a2cole(pnewcharstr);
Comments
Post a Comment