Java 类com.sun.jna.Function 实例源码

项目:Hearthtracker    文件:HearthRobot.java   
public static boolean isAeroEnabled(){      
    if( HearthHelper.getOSName().equals("win") && DWM == null){
        try{
            DWM = NativeLibrary.getInstance("dwmapi");
        } catch(Throwable e) {}
    }

    boolean dwmEnabled = false;

       if(DWM != null){
        boolean[] bool = { false };
        Object[] args = { bool };
        Function DwmIsCompositionEnabled = DWM.getFunction("DwmIsCompositionEnabled");
        HRESULT result = (HRESULT) DwmIsCompositionEnabled.invoke(HRESULT.class, args);
        boolean success = result.intValue()==0;

        if(success && bool[0]){
            dwmEnabled = true;
        }
       }  

    return dwmEnabled;
}
项目:DigitalMediaServer    文件:CoreFoundation.java   
@Override
public String toString() {
    if (getPointer() == null) {
        return "null";
    }
    if (getPointer() instanceof Function || getPointer() instanceof Memory) {
        return "Java initialized, not a real CF type";
    }
    CFStringRef description = INSTANCE.CFCopyDescription(this);
    try {
        return description.toString();
    } finally {
        INSTANCE.CFRelease(description);
    }
}
项目:intellij-ce-playground    文件:Win7TaskBar.java   
private static void initialize() {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return;
  }

  Ole32 ole32 = Ole32.INSTANCE;
  ole32.CoInitializeEx(Pointer.NULL, 0);

  Guid.GUID CLSID_TaskbarList = Ole32Util.getGUIDFromString("{56FDF344-FD6D-11d0-958A-006097C9A090}");
  Guid.GUID IID_ITaskbarList3 = Ole32Util.getGUIDFromString("{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}");
  PointerByReference p = new PointerByReference();
  WinNT.HRESULT hr = ole32.CoCreateInstance(CLSID_TaskbarList, Pointer.NULL, ObjBase.CLSCTX_ALL, IID_ITaskbarList3, p);
  if (!W32Errors.S_OK.equals(hr)) {
    LOG.error("Win7TaskBar CoCreateInstance(IID_ITaskbarList3) hResult: " + hr);
    ourInitialized = false;
    return;
  }

  myInterfacePointer = p.getValue();
  Pointer vTablePointer = myInterfacePointer.getPointer(0);
  Pointer[] vTable = new Pointer[TaskBarList_Methods];
  vTablePointer.read(0, vTable, 0, vTable.length);

  mySetProgressValue = Function.getFunction(vTable[TaskBarList_SetProgressValue], Function.ALT_CONVENTION);
  mySetProgressState = Function.getFunction(vTable[TaskBarList_SetProgressState], Function.ALT_CONVENTION);
  mySetOverlayIcon = Function.getFunction(vTable[TaskBarList_SetOverlayIcon], Function.ALT_CONVENTION);
}
项目:PanBox    文件:FuseFilesystem.java   
@FuseMethod
final int _readdir(final String path, final Pointer buf,
        final Pointer fillFunction, final TypeOff offset,
        final StructFuseFileInfo info) {
    return readdir(
            path,
            new DirectoryFillerImpl(buf, Function.getFunction(fillFunction)));
}
项目:tools-idea    文件:Win7TaskBar.java   
private static void initialize() {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return;
  }

  Ole32 ole32 = Ole32.INSTANCE;
  ole32.CoInitializeEx(Pointer.NULL, 0);

  Guid.GUID CLSID_TaskbarList = Ole32Util.getGUIDFromString("{56FDF344-FD6D-11d0-958A-006097C9A090}");
  Guid.GUID IID_ITaskbarList3 = Ole32Util.getGUIDFromString("{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}");
  PointerByReference p = new PointerByReference();
  WinNT.HRESULT hr = ole32.CoCreateInstance(CLSID_TaskbarList, Pointer.NULL, ObjBase.CLSCTX_ALL, IID_ITaskbarList3, p);
  if (!W32Errors.S_OK.equals(hr)) {
    LOG.error("Win7TaskBar CoCreateInstance(IID_ITaskbarList3) hResult: " + hr);
    ourInitialized = false;
    return;
  }

  myInterfacePointer = p.getValue();
  Pointer vTablePointer = myInterfacePointer.getPointer(0);
  Pointer[] vTable = new Pointer[TaskBarList_Methods];
  vTablePointer.read(0, vTable, 0, vTable.length);

  mySetProgressValue = Function.getFunction(vTable[TaskBarList_SetProgressValue], Function.ALT_CONVENTION);
  mySetProgressState = Function.getFunction(vTable[TaskBarList_SetProgressState], Function.ALT_CONVENTION);
  mySetOverlayIcon = Function.getFunction(vTable[TaskBarList_SetOverlayIcon], Function.ALT_CONVENTION);
}
项目:native-c    文件:JnaNativeInterface.java   
@Override
public INativeFunction createFunction(long address, Object callingConvention) {
    int callFlags;
    if (callingConvention == INativeFunction.CallingConventionCdecl) {
        callFlags = Function.C_CONVENTION;
    } else if (callingConvention == INativeFunction.CallingConventionStdcall) {
        callFlags = Function.ALT_CONVENTION;
    } else {
        throw new IllegalArgumentException("illegal calling convention");
    }
    Pointer pointer = new Pointer(address);
    Function function = Function.getFunction(pointer, callFlags);
    return new JnaNativeFunction(function);
}
项目:native-c    文件:JnaNativeInterface.java   
@Override
public INativeLibrary createLibrary(String name, Object callingConvention) {
    Map<String, Object> options = new HashMap<>(2);
    if (callingConvention == INativeFunction.CallingConventionCdecl) {
        options.put(Library.OPTION_CALLING_CONVENTION,
                Function.C_CONVENTION);
    } else if (callingConvention == INativeFunction.CallingConventionStdcall) {
        options.put(Library.OPTION_CALLING_CONVENTION,
                Function.ALT_CONVENTION);
    } else {
        throw new IllegalArgumentException("illegal calling convention");
    }
    options.put(Library.OPTION_OPEN_FLAGS, -1);
    return new JnaNativeLibrary(this, name, options);
}
项目:consulo    文件:Win7TaskBar.java   
private static void initialize() {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return;
  }

  Ole32 ole32 = Ole32.INSTANCE;
  ole32.CoInitializeEx(Pointer.NULL, 0);

  Guid.GUID CLSID_TaskbarList = Ole32Util.getGUIDFromString("{56FDF344-FD6D-11d0-958A-006097C9A090}");
  Guid.GUID IID_ITaskbarList3 = Ole32Util.getGUIDFromString("{EA1AFB91-9E28-4B86-90E9-9E9F8A5EEFAF}");
  PointerByReference p = new PointerByReference();
  WinNT.HRESULT hr = ole32.CoCreateInstance(CLSID_TaskbarList, Pointer.NULL, ObjBase.CLSCTX_ALL, IID_ITaskbarList3, p);
  if (!W32Errors.S_OK.equals(hr)) {
    LOG.error("Win7TaskBar CoCreateInstance(IID_ITaskbarList3) hResult: " + hr);
    ourInitialized = false;
    return;
  }

  myInterfacePointer = p.getValue();
  Pointer vTablePointer = myInterfacePointer.getPointer(0);
  Pointer[] vTable = new Pointer[TaskBarList_Methods];
  vTablePointer.read(0, vTable, 0, vTable.length);

  mySetProgressValue = Function.getFunction(vTable[TaskBarList_SetProgressValue], Function.ALT_CONVENTION);
  mySetProgressState = Function.getFunction(vTable[TaskBarList_SetProgressState], Function.ALT_CONVENTION);
  mySetOverlayIcon = Function.getFunction(vTable[TaskBarList_SetOverlayIcon], Function.ALT_CONVENTION);
}
项目:jdotxt    文件:Jdotxt.java   
public static void onWindows() {
    // Windows taskbar fix: provideAppUserModelID
    try {
        NativeLibrary lib = NativeLibrary.getInstance("shell32");
        Function function = lib.getFunction("SetCurrentProcessExplicitAppUserModelID");
        Object[] args = {new WString(APPID)}; 
        function.invokeInt(args);
    } catch (Error e) {
        return;
    } catch (Exception x) {
        return;
    }
}
项目:domino-jna    文件:NotesNativeAPI.java   
public native short SECKFMGetPublicKey(
Memory pName,
short Function,
short Flags,
IntByReference rethPubKey);
项目:ChallengeTask_Group2    文件:FuseFilesystem.java   
@FuseMethod
final int _readdir(final String path, final Pointer buf, final Pointer fillFunction, final TypeOff offset,
        final StructFuseFileInfo info)
{
    return readdir(path, new DirectoryFillerImpl(buf, Function.getFunction(fillFunction)));
}
项目:ChallengeTask_Group2    文件:DirectoryFillerImpl.java   
DirectoryFillerImpl(final Pointer buf, final Function nativeFunction)
{
    this.buf = buf;
    this.nativeFunction = nativeFunction;
    add(currentDirectory, parentDirectory);
}
项目:PanBox    文件:DirectoryFillerImpl.java   
DirectoryFillerImpl(final Pointer buf, final Function nativeFunction)
{
    this.buf = buf;
    this.nativeFunction = nativeFunction;
    add(currentDirectory, parentDirectory);
}
项目:native-c    文件:JnaNativeLibrary.java   
@Override
public INativeFunction getFunction(String name) {
    Function function = getLibrary().getFunction(name);
    return new JnaNativeFunction(function);
}
项目:native-c    文件:JnaNativeFunction.java   
public JnaNativeFunction(Function function) {
    this.function = function;
}
项目:native-c    文件:JnaNativeFunction.java   
protected Function getFunction() {
    return function;
}