Java call for Windows API GetShortPathName

前端 未结 1 1494
遇见更好的自我
遇见更好的自我 2021-01-14 09:58

I\'d like to use native windows api function in my java class.

The function I am interested in is GetShortPathName. http://msdn.microsoft.com/en-us/library/aa364989%

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-14 10:50

    Thanks for hint. Following is my improved function. It uses Unicode version of the GetShortPathName

    import com.sun.jna.Native;
    import com.sun.jna.platform.win32.Kernel32;
    
    public static String GetShortPathName(String path) {
        char[] result = new char[256];
    
        Kernel32.INSTANCE.GetShortPathName(path, result, result.length);
        return Native.toString(result);
    }
    

    0 讨论(0)
提交回复
热议问题