Prev: Linking errors
Next: wxwidget 2.6.2 and mysql 4.1.11
From: Peter Gordon on 9 Jan 2006 07:28 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-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Iulian-Nicu Serbanoiu on 9 Jan 2006 07:46 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-unsubscribe(a)lists.wxwidgets.org >For additional commands, e-mail: wx-users-help(a)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 --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Peter Gordon on 9 Jan 2006 08:30 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. The documentation says that for GetNamedSecrityInfoW file name needs to be null terminated. So I tried, s = wxString(_T("c:\\temp\\a")) ; wxChar d('\0') ; s = s + d ; GetNamedSecurityInfoW(s.c_str(),... and it still fails. Can someone suggest the correct incantation? Thanks Peter On Mon, 2006-01-09 at 14:46 +0200, Iulian-Nicu Serbanoiu wrote: > 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-unsubscribe(a)lists.wxwidgets.org > >For additional commands, e-mail: wx-users-help(a)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 > > --------------------------------------------------------------------- > To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org > For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Iulian-Nicu Serbanoiu on 9 Jan 2006 08:51 Try this and see what happens: GetNamedSecurityInfo(_T("c:\\temp\\a")); s = wxString(_T("c:\\temp\\a")) ; GetNamedSecurityInfo( s.c_str() ); without the last W . It is possible that you are using wxWidgets library not in the Unicode build ( i think ). Also you could test by displaying some message boxes to test that the strings received as parameters are identical. the strings are: L"c:\\temp\a" and s = wxString(_T("c:\\temp\\a")) ; s.c_str(); Try this with this function ::wxMessageBox or the winapi function MessageBox Also try this to see what type of wxLibrary ( unicode or not you have ) #ifdef _UNICODE message box saying we have unicode #else message box saying we don't have unicode #endif No more ideas for the moment but maybe this will help, Iulian 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. > >The documentation says that for GetNamedSecrityInfoW file name needs to >be null terminated. So I tried, > >s = wxString(_T("c:\\temp\\a")) ; >wxChar d('\0') ; >s = s + d ; >GetNamedSecurityInfoW(s.c_str(),... >and it still fails. > >Can someone suggest the correct incantation? > >Thanks > >Peter > > > > > > >On Mon, 2006-01-09 at 14:46 +0200, Iulian-Nicu Serbanoiu wrote: > > >>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-unsubscribe(a)lists.wxwidgets.org >>>For additional commands, e-mail: wx-users-help(a)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 >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org >>For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org >> >> >> >> >> > > > >--------------------------------------------------------------------- >To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org >For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org
From: Peter Gordon on 9 Jan 2006 09:27
You were spot on. I was running a test program and had forgotten to set the Unicode flag. Thanks for your help. Perer On Mon, 2006-01-09 at 15:51 +0200, Iulian-Nicu Serbanoiu wrote: > Try this and see what happens: > > GetNamedSecurityInfo(_T("c:\\temp\\a")); > > s = wxString(_T("c:\\temp\\a")) ; > > GetNamedSecurityInfo( s.c_str() ); > > without the last W . It is possible that you are using wxWidgets library > not in the Unicode build ( i think ). > > Also you could test by displaying some message boxes to test that the > strings received as parameters > are identical. > > the strings are: > > L"c:\\temp\a" > > and > > s = wxString(_T("c:\\temp\\a")) ; > s.c_str(); > > Try this with this function ::wxMessageBox or the winapi function MessageBox > > > Also try this to see what type of wxLibrary ( unicode or not you have ) > > #ifdef _UNICODE > > message box saying we have unicode > > #else > > message box saying we don't have unicode > > #endif > > > No more ideas for the moment but maybe this will help, > > Iulian > > > 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. > > > >The documentation says that for GetNamedSecrityInfoW file name needs to > >be null terminated. So I tried, > > > >s = wxString(_T("c:\\temp\\a")) ; > >wxChar d('\0') ; > >s = s + d ; > >GetNamedSecurityInfoW(s.c_str(),... > >and it still fails. > > > >Can someone suggest the correct incantation? > > > >Thanks > > > >Peter > > > > > > > > > > > > > >On Mon, 2006-01-09 at 14:46 +0200, Iulian-Nicu Serbanoiu wrote: > > > > > >>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-unsubscribe(a)lists.wxwidgets.org > >>>For additional commands, e-mail: wx-users-help(a)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 > >> > >>--------------------------------------------------------------------- > >>To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org > >>For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org > >> > >> > >> > >> > >> > > > > > > > >--------------------------------------------------------------------- > >To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org > >For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org > > > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org > For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org > > > --------------------------------------------------------------------- To unsubscribe, e-mail: wx-users-unsubscribe(a)lists.wxwidgets.org For additional commands, e-mail: wx-users-help(a)lists.wxwidgets.org |