Didn't check the JNA example code before responding--the basic idea's
still the same, but if you want to use the default example code without
adding a char[] variant function, you can:
1) interpret the byte[] as a UTF16 string (be sure your buffer has
length 2 * cchFileNameMax)
2) ask JNA to default to ASCII (set "w32.ascii" system property)
3) create an ASCII instance of the User32 library
User32 asciiInstance = (User32)
Native.loadLibrary("user32", User32.class, ASCII_OPTIONS);
There may be better options someone else can mention.
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.