today i started programming a little for Windows.
So my first application should be a tool for listing all windows and getting the name of the executables.
I read a lot about it. And it seems that there are some problems with Windows 7. But i dont know how i can solve this.
I get the following error message:
unhandled exeption at 0x77B6016E (ntdll.dll) in ConsoleApplication2.exe: 0x00000000
<EDIT> Forgot to tell the line of the occurance: Its GetWindowModuleFileName </EDIT>
LPWSTR is a pointer, not a string. It's basically a typedef for wchar_t*.
GetWindowModuleFileNameW will write the string data to whatever buffer you provide to it. But your 'name' buffer is not a buffer, but is just a pointer to some random area in memory (and likely read-only memory at that -- so when the function tries to write to it, it could explode).
You need to give the function an actual buffer:
1 2 3 4
wchar_t name[100]; // if you want to be able to have 100 characters, you need a buffer of at least 100
GetWindowModeulFileNameW( hwnd, name, 100 ); // if using wide characters, use the wide
// version of the function (note the W at the end)