Re: wxString and LPWSTR

417 views
Skip to first unread message

Iulian-Nicu Serbanoiu

unread,
Jan 9, 2006, 7:46:56 AM1/9/06
to wx-u...@lists.wxwidgets.org
Peter Gordon wrote:

>I have to use the function GetNamedSecurityInfoW and it needs a pointer
>to a file in the format LPWSTR.
>
>How to I convert a wxString to LPWSTR ?
>
>Thanks,
>
>Peter
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
>For additional commands, e-mail: wx-use...@lists.wxwidgets.org
>
>
>
>
*GetNamedSecurityInfo

it depends if you want to use it with Wide Chars ( unicode ) -
**GetNamedSecurityInfoW*
*or Chars ( ascii, not unicode ) - **GetNamedSecurityInfoA

Check this out:

-------------------
**wxString::c_str

**const wxChar ** *c_str*() *const
*

Returns a pointer to the string data (const char* in ANSI build, const
wchar_t* in Unicode build).

*------------------
[wchar_t *] is the same as *LPWSTR
[wxChar *] is the same as LPTSTR
[char *] is the same as LPSTR

If you want to use the unicode version of the function in the ansi build
of wxWidgets you will need to convert
from ANSI ( char * ) to wchar_t *... and I think this is no problem.

and [char *] is returned by the c_str function of the wxString class.

If you use the same 'unicodeness' you can call the function directly:

/////////////
wxString s;

....

*GetNamedSecurityInfo( s.c_str() , ...... );
*/////////////

Hope it helps,

Iulian

Gunnar Roth

unread,
Jan 9, 2006, 11:22:06 AM1/9/06
to wx-u...@lists.wxwidgets.org
Peter Gordon wrote:

>I am using pure Unicode.
>
>If I have
>
>GetNamedSecurityInfoW(L"c:\\temp\a",......
>
>the code works.
>
>If I have
>s = wxString(_T("c:\\temp\\a")) ;
>GetNamedSecurityInfoW(s.c_str(),...
>
>it fails.
>
>
So if you use "pure" unicode and not the standard tchar based
mechanisms,you should write that code:

s = wxString(L"c:\\temp\\a") ;
GetNamedSecurityInfoW(s.wc_str(),...

regards,
gunnar


Reply all
Reply to author
Forward
0 new messages