Dom,
GetWindowModuleFileName() is one of the many Windows calls that can
operate as an ASCII or Unicode function. Your code is defaulting to the
Unicode version:
UINT GetWindowModuleFileNameW(HWND hwnd, LPWSTR pszFileName, UINT
cchFileNameMax);
Use a Java char[] buffer instead of a Java byte[] buffer (corresponding
to using LPWSTR/wchar_t* instead of LPSTR/char*).
Everything else will be the same--Native.toString(char[]) turns the
char[] buffer into a String.
michael
Dominik Jall wrote:
Hi guys,
I am trying to get a list of all windows and print out all the
corresponding module names for them using this code:
User32 user32 = User32.INSTANCE;
Kernel32 kernel32 = Kernel32.INSTANCE;
user32.EnumWindows(new User32.WNDENUMPROC() {
int count;
public boolean callback(HWND hWnd, Pointer
userData) {
System.out.println("Found window " + hWnd + ",
total " + ++count);
User32 user32 = User32.INSTANCE;
byte text[] = new byte[1024];
user32.GetWindowModuleFileName(hWnd, text, 1024);
String test = Native.toString(text);
System.out.println(test);
return true;
}
}, null);
But apparently. only the first character (i.e. "C:\Program
Files\myexe.exe" --> "C") ist printed out.
What am I doing wrong?
Greetings, dom