0

I have created a module snapshot and I got MODULEENTRY32 struct which contains data, which I would output like this:

   _tprintf( TEXT("%6d %-15s %s\n"),pe.th32ProcessID,me.szModule,me.szExePath);

Now lets say I would want to use that path, which is WCHAR me.szExePath and another method requires a path of const *char. How could I handle that, would I need to convert data type?

Aracthor
  • 5,757
  • 6
  • 31
  • 59
J. Doe
  • 905
  • 1
  • 10
  • 23
  • I can't understand your question. What is "other method parameters"? – user253751 Jan 16 '16 at 10:35
  • Sorry, lets say as ezExePath is WCHAR, anf ifstream src... requires a parameter of const *char, which is path, how am I able to handle this, convert the WCHAR to const, or what? Thanks! – J. Doe Jan 16 '16 at 10:44
  • 2
    Then it depends on what you want to do. To open a file with a Unicode (WCHAR) filename, [you can just pass it to the constructor like usual, as a Microsoft-specific extension](http://stackoverflow.com/questions/821873/how-to-open-an-stdfstream-ofstream-or-ifstream-with-a-unicode-filename) – user253751 Jan 16 '16 at 10:47
  • 2
    Do stop using tchar.h, there has not been any point to it for over a decade. You use use %ls to always match wchar_t*, %hs to always match char*. – Hans Passant Jan 16 '16 at 11:01
  • Thank you, as I'm farily new to c++ that does help a lot =) – J. Doe Jan 16 '16 at 11:07
  • 1
    You go all in and use Unicode everywhere. – David Heffernan Jan 16 '16 at 12:23

0 Answers0