Hi,
I want to call GetShortPathNameW
(http://msdn2.microsoft.com/en-us/library/aa364989(VS.85).aspx). What is the
right mapping for LPCTSTR and LPTSTR? Maybe this?:
public interface Kernel32 extends StdCallLibrary {
public int GetShortPathNameW(PointerByReference lpszLongPath, PointerByReference
lpszShortPath, int cchBuffer);
}
This is one of my attemps but it doesn't work
(java.lang.IndexOutOfBoundsException: Bounds exceeds available space : size=4,
offset=112)
public class NativeCallUtils {
private static Kernel32 INSTANCE;
static {
System.setProperty("jna.encoding", "UTF8");
INSTANCE = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class);
}
public static String getEightPointThreePathName(String longPathName) {
PointerByReference pbr = new PointerByReference();
pbr.getPointer().setString(0, "\\\\?\\" + longPathName);
PointerByReference pbr2 = new PointerByReference();
INSTANCE.GetShortPathNameW(pbr, pbr2, longPathName.length());
String s = pbr2.getValue().getString(0);
return s;
}
}
Sorry, if this is actually a dumb question but I haven't done much C/C++
programming so far.