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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -