Groups | Blog | Home
all groups > visual c > july 2003 >

visual c : Converting a managed string to const WCHAR*


Tomas Restrepo (MVP)
7/27/2003 11:17:29 AM
Kieran,

[quoted text, click to view]

You're very close. All you're missing is pinning the resulting pointer from
PtrToStringChars():

const WCHAR __pin* fn = PtrToStringChars(filename);

--
Tomas Restrepo
tomasr@mvps.org

Kieran Benton
7/27/2003 1:21:30 PM
Hi,
Sorry to post this, I feel like a right fool but Im under serious time
pressure! Afraid I'm a newbie to managed C++ (Ive had to resort to it as Im
wrapping some COM objects for C# use).

Any ideas how to get this working?

void Configure(int port,String* filename,int maxclients)
{
//const WCHAR* fn = const_cast<__wchar_t*>(PtrToStringChars(filename));
const WCHAR* fn = filename->ToCharArray();
m_nw->Configure(port,fn,maxclients,0);
}

Thanks,
Kieran

AddThis Social Bookmark Button