本文整理汇总了Java中com.sun.jna.platform.win32.WinDef.MAX_PATH属性的典型用法代码示例。如果您正苦于以下问题:Java WinDef.MAX_PATH属性的具体用法?Java WinDef.MAX_PATH怎么用?Java WinDef.MAX_PATH使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.jna.platform.win32.WinDef
的用法示例。
在下文中一共展示了WinDef.MAX_PATH属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveFolder
public String resolveFolder(FolderId folderId) {
int folder = convertFolderId(folderId);
char[] pszPath = new char[WinDef.MAX_PATH];
HRESULT result = Shell32.INSTANCE.SHGetFolderPath(null, folder, null, null,
pszPath);
if (W32Errors.S_OK.equals(result)) {
return Native.toString(pszPath);
}
logger.error("SHGetFolderPath returns an error: {}", result.intValue());
throw new AppDirsException(
"SHGetFolderPath returns an error: " + result.intValue());
}
示例2: getProcessTree
/**
* Gets the process tree.
*
* @param pid the pid
* @return the process tree
*/
public static List<Integer> getProcessTree(final int pid) {
final List<Integer> pids = new ArrayList<Integer>();
pids.add(new Integer(pid));
final HANDLE processes = MyKernel32.INSTANCE.CreateToolhelp32Snapshot(MyKernel32.TH32CS_SNAPPROCESS,
0);
// The process can be childless
if (processes == null) {
return pids;
}
final Map<Integer, PROCESSENTRY32> processMap = new HashMap<Integer, PROCESSENTRY32>();
final Map<Integer, List<Integer>> childrenMap = new HashMap<Integer, List<Integer>>();
final PROCESSENTRY32 me = new PROCESSENTRY32();
me.szExeFile = new char[WinDef.MAX_PATH];
me.dwSize = me.size();
if (MyKernel32.INSTANCE.Process32First(processes, me)) {
do {
if (me.th32ProcessID > 0)
processMap.put(new Integer(me.th32ProcessID), me);
if (me.th32ParentProcessID > 0 && processMap.get(new Integer(me.th32ParentProcessID)) != null) {
List<Integer> value = childrenMap.get(me.th32ParentProcessID);
if (value == null) {
value = new LinkedList<Integer>();
childrenMap.put(me.th32ParentProcessID, value);
}
value.add(me.th32ProcessID);
}
} while (MyKernel32.INSTANCE.Process32Next(processes, me));
} else {
System.out.println("cannot access first process in list ");
}
Kernel32.INSTANCE.CloseHandle(processes);
return getProcessTree(childrenMap, pids);
}