當前位置: 首頁>>代碼示例>>Java>>正文


Java W32APIOptions類代碼示例

本文整理匯總了Java中com.sun.jna.win32.W32APIOptions的典型用法代碼示例。如果您正苦於以下問題:Java W32APIOptions類的具體用法?Java W32APIOptions怎麽用?Java W32APIOptions使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


W32APIOptions類屬於com.sun.jna.win32包,在下文中一共展示了W32APIOptions類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: while

import com.sun.jna.win32.W32APIOptions; //導入依賴的package包/類
/**
 * Finds the given process in the process list.
 *
 * @param processEntry The process entry.
 * @param filenamePattern pattern matching the filename of the process.
 * @return The found process entry.
 */
public static boolean findProcessEntry
                (final Tlhelp32.PROCESSENTRY32.ByReference processEntry,
                 final Pattern filenamePattern) {
    Kernel32 kernel32 = Native.loadLibrary(Kernel32.class, W32APIOptions.UNICODE_OPTIONS);

    WinNT.HANDLE snapshot = kernel32.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPPROCESS, new WinDef.DWORD(0));

    boolean found = false;

    try {
        while (kernel32.Process32Next(snapshot, processEntry)) {
            String fname = Native.toString(processEntry.szExeFile);

            if (fname != null && filenamePattern.matcher(fname).matches()) {
                found = true;
                break;
            }
        }
    } finally {
        kernel32.CloseHandle(snapshot);
    }

    return found;
}
 
開發者ID:mmarquee,項目名稱:ui-automation,代碼行數:32,代碼來源:Utils.java

示例2: isMassEffect3Running

import com.sun.jna.win32.W32APIOptions; //導入依賴的package包/類
/**
 * Checks if MassEffect3.exe is currently running. Uses native code.
 * 
 * @return
 */
public static boolean isMassEffect3Running() {
	try {
		Kernel32 kernel32 = (Kernel32) Native.loadLibrary(Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
		Tlhelp32.PROCESSENTRY32.ByReference processEntry = new Tlhelp32.PROCESSENTRY32.ByReference();
		boolean result = false;
		WinNT.HANDLE snapshot = kernel32.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPPROCESS, new WinDef.DWORD(0));
		try {
			while (kernel32.Process32Next(snapshot, processEntry)) {
				if ("MassEffect3.exe".toUpperCase().equals(Native.toString(processEntry.szExeFile).toUpperCase())) {
					result = true;
					break;
				}
			}
		} finally {
			kernel32.CloseHandle(snapshot);
		}
		ModManager.debugLogger.writeMessage("Mass Effect 3 is " + (result ? "" : "not ") + "currently running.");
		return result;
	} catch (Throwable t) {
		ModManager.debugLogger.writeErrorWithException("Critical native access exception: ", t);
		ModManager.debugLogger.writeError("Mod Manager will report that the game is not running to continue normal operations.");
		return false;
	}
}
 
開發者ID:Mgamerz,項目名稱:me3modmanager,代碼行數:30,代碼來源:ModManager.java

示例3: attemptLoad

import com.sun.jna.win32.W32APIOptions; //導入依賴的package包/類
/**
 * Internal function. Ensures kernel libraries are loaded if possible.
 */
private static void attemptLoad()
{
    if(attemptedLoad)return;
    try
    {
        kernel32 = (Kernel32) Native.loadLibrary("kernel32", Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
        user32 = (User32) Native.loadLibrary("user32", User32.class, W32APIOptions.UNICODE_OPTIONS);
    }catch(UnsatisfiedLinkError ignored)
    {
        System.out.println("Native libraries not available");
    }
    attemptedLoad = true;
}
 
開發者ID:thatdude624,項目名稱:Spark-Reader,代碼行數:17,代碼來源:KernelController.java

示例4: getRunningMatlabs

import com.sun.jna.win32.W32APIOptions; //導入依賴的package包/類
/**
 * Returns a map containing the current matlab running processes. The key is the process file path, and the value is
 * the matlab version
 * 
 * @return
 * @throws MatlabRegistryException
 */
public static List<MatlabProcessInformation> getRunningMatlabs() throws MatlabRegistryException {
    Kernel32 kernel32 = (Kernel32) Native.loadLibrary(Kernel32.class, W32APIOptions.UNICODE_OPTIONS);
    Map<String, Integer> processes = findProcessPIDs(kernel32);
    AvailableVersions versions = findAvailableMatlabVersions(kernel32);
    List<MatlabProcessInformation> runningMatlabs = findRunningMatlabsFromPIDs(versions, processes);
    return runningMatlabs;
}
 
開發者ID:viatra,項目名稱:massif,代碼行數:15,代碼來源:MatlabRunningManager.java


注:本文中的com.sun.jna.win32.W32APIOptions類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。