Fails to convert process name to wxString

Eran Ifrah eran.ifrah at gmail.com
Thu Nov 1 12:28:26 PDT 2007


Thanks, but this was my first attempt.
I also tried various conversion classes, all seems to fail (wxConvUTF8 etc)

Eran


On 11/1/07, Eric Jensen <ej at xe847.com> wrote:
>
> EI> Problematic OS:
> EI> Win XP SP2, gdb 6.6, gcc 3.4.5 mingw, wx 2.8.4, Debug/Release Unicode
> EI> monolithic dll
>
> EI> I am trying to get a process name by its PID, however I fails to
> convert the
> EI> string to proper wxString on Windows.
>
> EI> I am using WinAPI  (windows)/ ps command (linux), my code looks
> something
> EI> like this:
>
> EI> PROCESSENTRY32 pe;
> EI> wxZeroMemory(pe);
> EI> pe.dwSize =3D sizeof(PROCESSENTRY32);
>
> EI> if (!lpfProcess32First(hProcessSnap, &pe)) {
> EI>     CloseHandle (hProcessSnap);
> EI>     return wxEmptyString;
> EI> }
>
> EI> //Loop over and search for our process ID
> EI> bool cont(true);
> EI> while( cont ){
> EI>     wxLogMessage(pe.szExeFile);
> EI>     if(pe.th32ProcessID =3D=3D (DWORD)pid){
> EI>         //Conversion need to be taken here fro pe.szExeFile to
> wxString
> EI>         CloseHandle (hProcessSnap);
> EI>         return wxEmptyString;
> EI>     }
> EI>     wxZeroMemory(pe);
> EI>     pe.dwSize =3D sizeof(PROCESSENTRY32);
> EI>     cont =3D lpfProcess32Next (hProcessSnap, &pe) ? true : false;
> EI> }
>
> EI> The problem is that I manage to find my process ID, but I cant seem to
>
> EI> properly convert the string (located at pe.szExeFile) I tried
> debugging it
> EI> with gdb / VC debugger, both failed to display the string properly.
>
> EI> Anyone experienced with such problem?
>
> return wxString(pe.szExeFile);
>
> should work just fine.
>
> Eric
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>


-- =

Eran Ifrah
eran.ifrah at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20071101/a61=
fbf78/attachment.htm


More information about the wx-users mailing list