当前位置: 首页>>代码示例>>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;未经允许,请勿转载。