Show Me More!!!|

Journey&Flower

园龄:7年3个月粉丝:40关注:121

C#调用C函数 out int 对应 java 数据类型 com.sun.jna.ptr.IntByReference

How to use
IntByReference
in

Best Java code snippets using com.sun.jna.ptr.IntByReference(Showing top 20 results out of 603)

Kernel32Utils.waitForExitProcess(...)      来源:jenkins/Kernel32Utils.java at master · jenkinsci/jenkins (github.com)

复制代码
/**
 * Given the process handle, waits for its completion and returns the exit code.
 */
public static int waitForExitProcess(Pointer hProcess) throws InterruptedException {
  while (true) {
    if (Thread.interrupted())
      throw new InterruptedException();
    Kernel32.INSTANCE.WaitForSingleObject(hProcess,1000);
    IntByReference exitCode = new IntByReference();
    exitCode.setValue(-1);
    Kernel32.INSTANCE.GetExitCodeProcess(hProcess,exitCode);
    int v = exitCode.getValue();
    if (v !=Kernel32.STILL_ACTIVE) {
      return v;
    }
  }
}
复制代码

ProcessTreeDarwinDarwinProcess.parse()             来源:jenkins/ProcessTree.java at master · jenkinsci/jenkins (github.com)

复制代码
 private void parse() {
        try {
// allocate them first, so that the parse error wil result in empty data
          // and avoid retry.
          arguments = new ArrayList<String>();
          envVars = new EnvVars();

          IntByReference intByRef = new IntByReference();

          IntByReference argmaxRef = new IntByReference(0);
          IntByReference size = new IntByReference(sizeOfInt);

          // for some reason, I was never able to get sysctlbyname work.
//        if(LIBC.sysctlbyname("kern.argmax", argmaxRef.getPointer(), size, NULL, _)!=0)
          if(LIBC.sysctl(new int[]{CTL_KERN,KERN_ARGMAX},2, argmaxRef.getPointer(), size, NULL, intByRef)!=0)
            throw new IOException("Failed to get kern.argmax: "+LIBC.strerror(Native.getLastError()));

          int argmax = argmaxRef.getValue();

          class StringArrayMemory extends Memory {
            private long offset=0;

            StringArrayMemory(long l) {
              super(l);
            }

            int readInt() {
              int r = getInt(offset);
              offset+=sizeOfInt;
              return r;
            }

            byte peek() {
              return getByte(offset);
            }

            String readString() {
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              byte ch;
              while((ch = getByte(offset++))!='\0')
                baos.write(ch);
              return baos.toString();
            }

            void skip0() {
              // skip padding '\0's
              while(getByte(offset)=='\0')
                offset++;
            }
          }
          StringArrayMemory m = new StringArrayMemory(argmax);
          size.setValue(argmax);
          if(LIBC.sysctl(new int[]{CTL_KERN,KERN_PROCARGS2,pid},3, m, size, NULL, intByRef)!=0)
            throw new IOException("Failed to obtain ken.procargs2: "+LIBC.strerror(Native.getLastError()));


          /*
          * Make a sysctl() call to get the raw argument space of the
            * process.  The layout is documented in start.s, which is part
            * of the Csu project.  In summary, it looks like:
            *
            * /---------------\ 0x00000000
            * :               :
            * :               :
            * |---------------|
            * | argc          |
            * |---------------|
            * | arg[0]        |
            * |---------------|
            * :               :
            * :               :
            * |---------------|
            * | arg[argc - 1] |
            * |---------------|
            * | 0             |
            * |---------------|
            * | env[0]        |
            * |---------------|
            * :               :
            * :               :
            * |---------------|
            * | env[n]        |
            * |---------------|
            * | 0             |
            * |---------------| <-- Beginning of data returned by sysctl()
            * | exec_path     |     is here.
            * |:::::::::::::::|
            * |               |
            * | String area.  |
            * |               |
            * |---------------| <-- Top of stack.
            * :               :
            * :               :
            * \---------------/ 0xffffffff
            */

          // I find the Darwin source code of the 'ps' command helpful in understanding how it does this:
          // see http://www.opensource.apple.com/source/adv_cmds/adv_cmds-147/ps/print.c
          int argc = m.readInt();
          String args0 = m.readString(); // exec path
          m.skip0();
          try {
            for( int i=0; i<argc; i++) {
              arguments.add(m.readString());
            }
          } catch (IndexOutOfBoundsException e) {
            throw new IllegalStateException("Failed to parse arguments: pid="+pid+", arg0="+args0+", arguments="+arguments+", nargs="+argc+". Please see https://jenkins.io/redirect/troubleshooting/darwin-failed-to-parse-arguments",e);
          }

          // read env vars that follow
          while(m.peek()!=0)
            envVars.addLine(m.readString());
        } catch (IOException e) {
          // this happens with insufficient permissions, so just ignore the problem.
        }
      }
    }
View
复制代码

OpenVR.getRenderSize(...)      来源:https://www.tabnine.com/web/assistant/code/rs/5c781696e70f870001969d92#L326

复制代码
@Override
public void getRenderSize(Vector2f store) {
  if( vrsystemFunctions == null ) {
    // 1344x1512
    store.x = 1344f;
    store.y = 1512f;
  } else {
    IntByReference x = new IntByReference();
    IntByReference y = new IntByReference();
    vrsystemFunctions.GetRecommendedRenderTargetSize.apply(x, y);
    store.x = x.getValue();
    store.y = y.getValue();
  }
}
/*
复制代码

Find out what application (window) is in focus in Java    来源:Find out what application (window) is in focus in Java - Stack Overflow

复制代码
 public interface Psapi extends StdCallLibrary {
  Psapi INSTANCE = (Psapi) Native.loadLibrary("Psapi", Psapi.class);

  WinDef.DWORD GetModuleBaseNameW(Pointer hProcess, Pointer hModule, byte[] lpBaseName, int nSize);
}
  if (Platform.isWindows()) {
    final int PROCESS_VM_READ=0x0010;
    final int PROCESS_QUERY_INFORMATION=0x0400;
    final User32 user32 = User32.INSTANCE;
    final Kernel32 kernel32=Kernel32.INSTANCE;
    final Psapi psapi = Psapi.INSTANCE;
    WinDef.HWND windowHandle=user32.GetForegroundWindow();
    IntByReference pid= new IntByReference();
    user32.GetWindowThreadProcessId(windowHandle, pid);
    WinNT.HANDLE processHandle=kernel32.OpenProcess(PROCESS_VM_READ | PROCESS_QUERY_INFORMATION, true, pid.getValue());

    byte[] filename = new byte[512];
    Psapi.INSTANCE.GetModuleBaseNameW(processHandle.getPointer(), Pointer.NULL, filename, filename.length);
    String name=new String(filename);
    System.out.println(name);
    if (name.endsWith("wwahost.exe")) { // Metro App
      // There is no stable API to get the current Metro app
      // But you can guestimate the name form the current directory of the process
      // To query this, see:
      // http://stackoverflow.com/questions/16110936/read-other-process-current-directory-in-c-sharp
    }
复制代码

passing a int** to a C routine using JNA      来源:java - passing a int** to a C routine using JNA - Stack Overflow

复制代码
 // Original C declaration
void allocate_buffer(char **bufp, int* lenp);

// Equivalent JNA mapping
 void allocate_buffer(PointerByReference bufp, IntByReference lenp);

// Usage
PointerByReference pref = new PointerByReference();
IntByReference iref = new IntByReference();
lib.allocate_buffer(pref, iref);
Pointer p = pref.getValue();
byte[] buffer = p.getByteArray(0, iref.getValue());
复制代码

JnaSession.getAttrNames(...)        来源:gatk/JnaSession.java at master · broadgsa/gatk (github.com)

复制代码
private static List<String> getAttrNames(PointerByReference names) throws DrmaaException {
  List<String> namesList = new ArrayList<String>();
  IntByReference size = new IntByReference();
  int errnum;
  errnum = LibDrmaa.drmaa_get_num_attr_names(names.getValue(), size);
  checkError(errnum, "unable to get attribute names");
  int num = size.getValue();
  Memory value = new Memory(LibDrmaa.DRMAA_ATTR_BUFFER);
  for (int i = 1; i <= num; i++) {
    errnum = LibDrmaa.drmaa_get_next_attr_name(names.getValue(), value, LibDrmaa.DRMAA_ATTR_BUFFER_LEN);
    checkError(errnum, "unable to get attribute name " + i);
    if (errnum == LibDrmaa.DRMAA_ERRNO.DRMAA_ERRNO_NO_MORE_ELEMENTS)
      break;
    namesList.add(value.getString(0));
  }
  return namesList;
}
复制代码

WevtapiUtil.EvtNextPublisherId(...)        来源:https://www.tabnine.com/web/assistant/code/rs/5c65f49c1095a5000191f2f0#L185

复制代码
/**
 * Gets the identifier of a provider from the enumerator.
 *
 * @param publisherEnum [in] A handle to the registered providers enumerator that
 *                      the {@link Wevtapi#EvtOpenPublisherEnum} function returns.
 * @return The name of the registered provider.
 */
public static String EvtNextPublisherId(EVT_HANDLE publisherEnum) {
  IntByReference publisherIdBufferUsed = new IntByReference();
  boolean result = Wevtapi.INSTANCE.EvtNextPublisherId(publisherEnum, 0, null, publisherIdBufferUsed);
  int errorCode = Kernel32.INSTANCE.GetLastError();
  if ((!result) && errorCode != Kernel32.ERROR_INSUFFICIENT_BUFFER) {
    throw new Win32Exception(errorCode);
  }
  char[] publisherIdBuffer = new char[publisherIdBufferUsed.getValue()];
  result = Wevtapi.INSTANCE.EvtNextPublisherId(publisherEnum, publisherIdBuffer.length, publisherIdBuffer, publisherIdBufferUsed);
  if (!result) {
    throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
  }
  return Native.toString(publisherIdBuffer);
}
复制代码

W32Service.queryServiceConfig2(...)        来源:https://www.tabnine.com/web/assistant/code/rs/5c65f49c1095a5000191f2eb#L125

复制代码
private Pointer queryServiceConfig2(int type) {
  IntByReference bufferSize = new IntByReference();
  Advapi32.INSTANCE.QueryServiceConfig2(_handle, type, Pointer.NULL, 0, bufferSize);
  Pointer buffer = new Memory(bufferSize.getValue());
  if (!Advapi32.INSTANCE.QueryServiceConfig2(_handle, type, buffer, bufferSize.getValue(),
      new IntByReference())) {
    throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
  }
  return buffer;
}
复制代码

WinspoolUtil.getPrinterInfo2(...)          来源:https://www.tabnine.com/web/assistant/code/rs/5c65f49c1095a5000191f306#L78

复制代码
private static PRINTER_INFO_2[] getPrinterInfo2(int flags) {
  IntByReference pcbNeeded = new IntByReference();
  IntByReference pcReturned = new IntByReference();
  Winspool.INSTANCE.EnumPrinters(flags, null, 2, null, 0, pcbNeeded, pcReturned);
  if (pcbNeeded.getValue() <= 0)
    return new PRINTER_INFO_2[0];
  PRINTER_INFO_2 pPrinterEnum = new PRINTER_INFO_2(pcbNeeded.getValue());
  if (!Winspool.INSTANCE.EnumPrinters(flags, null, 2, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded,
      pcReturned))
    throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
  pPrinterEnum.read();
  return (PRINTER_INFO_2[]) pPrinterEnum.toArray(pcReturned.getValue());
}
复制代码

ProcessTree$Darwin.<init>(...)          来源:jenkins/ProcessTree.java at master · jenkinsci/jenkins (github.com)

复制代码
    Darwin(boolean vetoersExist) {
      super(vetoersExist);

      String arch = System.getProperty("sun.arch.data.model");
      if ("64".equals(arch)) {
        sizeOf_kinfo_proc = sizeOf_kinfo_proc_64;
        kinfo_proc_pid_offset = kinfo_proc_pid_offset_64;
        kinfo_proc_ppid_offset = kinfo_proc_ppid_offset_64;
      } else {
        sizeOf_kinfo_proc = sizeOf_kinfo_proc_32;
        kinfo_proc_pid_offset = kinfo_proc_pid_offset_32;
        kinfo_proc_ppid_offset = kinfo_proc_ppid_offset_32;
      }
      try {
        IntByReference ref = new IntByReference(sizeOfInt);
        IntByReference size = new IntByReference(sizeOfInt);
        Memory m;
        int nRetry = 0;
        while(true) {
          // find out how much memory we need to do this
          if(LIBC.sysctl(MIB_PROC_ALL,3, NULL, size, NULL, ref)!=0)
            throw new IOException("Failed to obtain memory requirement: "+LIBC.strerror(Native.getLastError()));

          // now try the real call
          m = new Memory(size.getValue());
          if(LIBC.sysctl(MIB_PROC_ALL,3, m, size, NULL, ref)!=0) {
            if(Native.getLastError()==ENOMEM && nRetry++<16)
              continue; // retry
            throw new IOException("Failed to call kern.proc.all: "+LIBC.strerror(Native.getLastError()));
          }
          break;
        }

        int count = size.getValue()/sizeOf_kinfo_proc;
        LOGGER.fine("Found "+count+" processes");

        for( int base=0; base<size.getValue(); base+=sizeOf_kinfo_proc) {
          int pid = m.getInt(base+ kinfo_proc_pid_offset);
          int ppid = m.getInt(base+ kinfo_proc_ppid_offset);
//                    int effective_uid = m.getInt(base+304);
//                    byte[] comm = new byte[16];
//                    m.read(base+163,comm,0,16);

          super.processes.put(pid,new DarwinProcess(pid,ppid));
        }
      } catch (IOException e) {
        LOGGER.log(Level.WARNING, "Failed to obtain process list",e);
      }
    }
复制代码

OpenVRUtil.getTrackedDeviceStringProperty(...)          来源:https://www.tabnine.com/web/assistant/code/rs/5c781695e70f870001969cea#L20

复制代码
/**
 * Get the value of the given string {@link JOpenVRLibrary.ETrackedDeviceProperty property} attached to the given device.
 * @param system the underlying OpenVR system.
 * @param deviceIndex the index of the device to query.
 * @param property the property to query.
 * @param bufferSize the size of the buffer to use for storing native string.
 * @return the value of the given string property attached to the given device.
 * @see OpenVRInput#getTrackedControllerCount()
 * @see JOpenVRLibrary.ETrackedDeviceProperty
 * @see #getTrackedDeviceStringProperty(VR_IVRSystem_FnTable, int, int)
 */
public static String getTrackedDeviceStringProperty(VR_IVRSystem_FnTable system, int deviceIndex, int property, int bufferSize){
  String str ="";
  
  int unBufferSize = 256;
  Pointer pchValue = new Memory(unBufferSize); 
  IntByReference pError = new IntByReference();
  
  system.GetStringTrackedDeviceProperty.apply(deviceIndex, property, pchValue, unBufferSize, pError);
  
  if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_Success){
    str = pchValue.getString(0);
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_BufferTooSmall){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_CouldNotContactServer){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidDevice){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_InvalidOperation){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_NotYetAvailable){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_PermissionDenied){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_StringExceedsMaximumLength){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_UnknownProperty){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_ValueNotProvidedByDevice){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDataType){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else if (pError.getValue() == ETrackedPropertyError.ETrackedPropertyError_TrackedProp_WrongDeviceClass){
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  } else {
    throw new IllegalArgumentException("Cannot access property \""+getETrackedDevicePropertyString(property)+"\" ("+property+") for device "+deviceIndex+": "+getETrackedPropertyErrorString(pError.getValue())+" ("+pError.getValue()+")");
  }
  
  return str;
}
View
复制代码

Gst$NativeArgs.<init>(...)          来源:https://www.tabnine.com/web/assistant/code/rs/5c6579f91095a50001550202#L107

复制代码
public NativeArgs(String progname, String[] args) {
  //
  // Allocate some native memory to pass the args down to the native layer
  //
  argsCopy = new Memory[args.length + 2];
  argvMemory = new Memory(argsCopy.length * Pointer.SIZE);
  
  //
  // Insert the program name as argv[0]
  //
  Memory arg = new Memory(progname.getBytes().length + 4);
  arg.setString(0, progname, false);
  argsCopy[0] = arg;
  
  for (int i = 0; i < args.length; i++) {
    arg = new Memory(args[i].getBytes().length + 1);
    arg.setString(0, args[i], false);
    argsCopy[i + 1] = arg;
  }
  argvMemory.write(0, argsCopy, 0, argsCopy.length);
  argvRef = new PointerByReference(argvMemory);
  argcRef = new IntByReference(args.length + 1);
}
String[] toStringArray() {
复制代码

Java: JNA SystemParametersInfo parameters type        来源:pointers - Java: JNA SystemParametersInfo parameters type - Stack Overflow

复制代码
 IntByReference intPtr = new IntByReference();
//that's the place where i'm stuck trying to initialize with Pointer constructor
Pointer ptr = new Memory(Pointer.SIZE * 256);
User32.INSTANCE.SystemParametersInfo(User32.SPI_GETSCREENSAVERRUNNING, 0,intPtr.getPointer(), 0);
User32.INSTANCE.SystemParametersInfo(User32.SPI_GETDESKWALLPAPER,256, ptr, 0);
复制代码

ExecutableFileInfo.getVersionInfo(...)            来源:ui-automation/ExecutableFileInfo.java at master · mmarquee/ui-automation (github.com)

复制代码
  /**
   * Gets the version info (if present) from the file in the path.
   * @param path Pathname to file
   * @return The version info array (loads of integers)
   */
  public static int[] getVersionInfo(final String path) {
    IntByReference dwDummy = new IntByReference();
    dwDummy.setValue(0);

    int versionlength = com.sun.jna.platform.win32.Version.INSTANCE.GetFileVersionInfoSize(path, dwDummy);

    byte[] bufferarray = new byte[versionlength];
    Pointer lpData = new Memory(bufferarray.length);
    PointerByReference lplpBuffer = new PointerByReference();
    IntByReference puLen = new IntByReference();
    com.sun.jna.platform.win32.Version.INSTANCE.GetFileVersionInfo(path, 0, versionlength, lpData);
    com.sun.jna.platform.win32.Version.INSTANCE.VerQueryValue(lpData, "\\", lplpBuffer, puLen);

    VerRsrc.VS_FIXEDFILEINFO lplpBufStructure = new VerRsrc.VS_FIXEDFILEINFO(lplpBuffer.getValue());
    lplpBufStructure.read();

    int v1 = (lplpBufStructure.dwFileVersionMS).intValue() >> 16;
    int v2 = (lplpBufStructure.dwFileVersionMS).intValue() & 0xffff;
    int v3 = (lplpBufStructure.dwFileVersionLS).intValue() >> 16;
    int v4 = (lplpBufStructure.dwFileVersionLS).intValue() & 0xffff;
    System.out.println("Version: " + v1 + "." + v2 + "." + v3 + "." + v4);
    return new int[]{v1, v2, v3, v4};
  }
}
复制代码

Advapi32Util.registryGetKeys(...)        来源:https://www.tabnine.com/web/assistant/code/rs/5c66906a1095a50001cf5b42#L1342

复制代码
/**
 * Get names of the registry key's sub-keys.
 *
 * @param hKey
 *            Registry key.
 * @return Array of registry key names.
 */
public static String[] registryGetKeys(HKEY hKey) {
  IntByReference lpcSubKeys = new IntByReference();
  IntByReference lpcMaxSubKeyLen = new IntByReference();
  int rc = Advapi32.INSTANCE
      .RegQueryInfoKey(hKey, null, null, null, lpcSubKeys,
          lpcMaxSubKeyLen, null, null, null, null, null, null);
  if (rc != W32Errors.ERROR_SUCCESS) {
    throw new Win32Exception(rc);
  }
  ArrayList<String> keys = new ArrayList<String>(lpcSubKeys.getValue());
  char[] name = new char[lpcMaxSubKeyLen.getValue() + 1];
  for (int i = 0; i < lpcSubKeys.getValue(); i++) {
    IntByReference lpcchValueName = new IntByReference(
        lpcMaxSubKeyLen.getValue() + 1);
    rc = Advapi32.INSTANCE.RegEnumKeyEx(hKey, i, name, lpcchValueName,
        null, null, null, null);
    if (rc != W32Errors.ERROR_SUCCESS) {
      throw new Win32Exception(rc);
    }
    keys.add(Native.toString(name));
  }
  return keys.toArray(new String[0]);
}
复制代码

Gst$NativeArgs.toStringArray()          来源:https://www.tabnine.com/web/assistant/code/rs/5c6579f91095a50001550202#L130

复制代码
  String[] toStringArray() {
    //
    // Unpack the native arguments back into a String array
    //
    List<String> args = new ArrayList<String>();
    Pointer argv = argvRef.getValue();
    for (int i = 1; i < argcRef.getValue(); i++) {
      Pointer arg = argv.getPointer(i * Pointer.SIZE);
      if (arg != null) {
        args.add(arg.getString(0, false));
      }
    }
    return args.toArray(new String[args.size()]);
  }   
}
复制代码

ProcessEpoll.checkDeadPool()            来源:NuProcess/ProcessEpoll.java at master · brettwooldridge/NuProcess (github.com)

复制代码
private void checkDeadPool()
{
 if (deadPool.isEmpty()) {
   return;
 }
 IntByReference ret = new IntByReference();
 Iterator<LinuxProcess> iterator = deadPool.iterator();
 while (iterator.hasNext()) {
   LinuxProcess process = iterator.next();
   int rc = LibC.waitpid(process.getPid(), ret, LibC.WNOHANG);
   if (rc == 0) {
    continue;
   }
   iterator.remove();
   if (rc < 0) {
    process.onExit((Native.getLastError() == LibC.ECHILD) ? Integer.MAX_VALUE : Integer.MIN_VALUE);
    continue;
   }
   handleExit(process, ret.getValue());
 }
}
复制代码

EmbeddedInternalConnection$EmbeddedInternalStream.write(...)          来源:https://www.tabnine.com/web/assistant/code/rs/5c6621101095a50001a5bfb2#L157

复制代码
@Override
public void write(final List<ByteBuf> buffers) {
  byte[] message = createCompleteMessage(buffers);
  PointerByReference outputBufferReference = new PointerByReference();
  IntByReference outputSize = new IntByReference();
  MongoDBCAPIHelper.client_invoke(clientPointer, message, outputBufferReference, outputSize, clientStatusPointer);
  curResponse = outputBufferReference.getValue().getByteBuffer(0, outputSize.getValue());
}
复制代码

Netapi32Util.getJoinStatus(...)            来源:https://www.tabnine.com/web/assistant/code/rs/5c65f49c1095a5000191f2c3#L141

复制代码
/**
 * Return the domain/workgroup join status for a computer. 
 * @param computerName Computer name.
 * @return Join status.
 */
public static int getJoinStatus(String computerName) {
  PointerByReference lpNameBuffer = new PointerByReference();
  IntByReference bufferType = new IntByReference();
  
  try {
    int rc = Netapi32.INSTANCE.NetGetJoinInformation(computerName, lpNameBuffer, bufferType);
    if (LMErr.NERR_Success != rc) {
      throw new Win32Exception(rc);            
    }
    return bufferType.getValue();
  } finally {
    if (lpNameBuffer.getPointer() != null) {
      int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
      if (LMErr.NERR_Success != rc) {
        throw new Win32Exception(rc);            
      }
    }
  }        
}
复制代码

OpenVR.getType()            来源:https://www.tabnine.com/web/assistant/code/rs/5c781696e70f870001969d92#L541

复制代码
@Override
public HmdType getType() {
  if( vrsystemFunctions != null ) {      
    Pointer str1 = new Memory(128);
    Pointer str2 = new Memory(128);
    String completeName = "";
    vrsystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd,
                                JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ManufacturerName_String,
                                str1, 128, hmdErrorStore);
    if( hmdErrorStore.getValue() == 0 ) completeName += str1.getString(0);
    vrsystemFunctions.GetStringTrackedDeviceProperty.apply(JOpenVRLibrary.k_unTrackedDeviceIndex_Hmd,
                                JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_ModelNumber_String,
                                str2, 128, hmdErrorStore);
    if( hmdErrorStore.getValue() == 0 ) completeName += " " + str2.getString(0);
    if( completeName.length() > 0 ) {
      completeName = completeName.toLowerCase(Locale.ENGLISH).trim();
复制代码

 

本文来源: com.sun.jna.ptr.IntByReference java code examples | Tabnine

本文作者:Journey&Flower

本文链接:https://www.cnblogs.com/JourneyOfFlower/p/15601278.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   Journey&Flower  阅读(450)  评论(0编辑  收藏  举报
评论
收藏
关注
推荐
深色
回顶
收起
点击右上角即可分享
微信分享提示
  1. 1 404 Not Found REOL
  2. 2 白色恋人 游鸿明
  3. 3 盛夏的果实 莫文蔚
  4. 4 以父之名 周杰伦
  5. 5 晴天 周杰伦
  6. 6 简单爱 周杰伦
  7. 7 东风破 周杰伦
  8. 8 稻香 周杰伦
  9. 9 爱在西元前 周杰伦
  10. 10 千里之外 费玉清-周杰伦
  11. 11 偏爱 张芸京
  12. 12 大海 张雨生
  13. 13 月亮惹的祸 张宇
  14. 14 雨一直下 张宇
  15. 15 过火 张信哲
  16. 16 隐形的翅膀 张韶涵
  17. 17 天下 张杰
  18. 18 当你孤单你会想起谁 张栋梁
  19. 19 清明雨上 许嵩
  20. 20 玫瑰花的葬礼 许嵩
  21. 21 断桥残雪 许嵩
  22. 22 城府 许嵩
  23. 23 等一分钟 徐誉滕
  24. 24 客官不可以 徐良_小凌
  25. 25 坏女孩 徐良_小凌
  26. 26 犯贱 徐良
  27. 27 菠萝菠萝蜜 谢娜
  28. 28 贝多芬的悲伤 萧风
  29. 29 睫毛弯弯 王心凌
  30. 30 我不是黄蓉 王蓉
  31. 31 秋天不回来 王强
  32. 32 今天你要嫁给我 陶喆,蔡依林
  33. 33 丁香花 唐磊
  34. 34 绿光 孙燕姿
  35. 35 求佛 誓言
  36. 36 十一年 邱永传
  37. 37 下辈子如果我还记得你 马郁
  38. 38 一千年以后 林俊杰
  39. 39 江南 林俊杰
  40. 40 曹操 林俊杰
  41. 41 背对背拥抱 林俊杰
  42. 42 会呼吸的痛 梁静茹
  43. 43 勇气 梁静茹
  44. 44 爱你不是两三天 梁静茹
  45. 45 红日 李克勤
  46. 46 星月神话 金莎
  47. 47 嘻唰唰 花儿乐队
  48. 48 穷开心 花儿乐队
  49. 49 六月的雨-《仙剑奇侠传》电视剧插曲 胡歌
  50. 50 一个人的寂寞两个人的错 贺一航
  51. 51 好想好想-《情深深雨濛濛》电视剧片尾曲 古巨基
  52. 52 情人 刀郎
  53. 53 冲动的惩罚 刀郎
  54. 54 西海情歌 刀郎
  55. 55 2002年的第一场雪 刀郎
  56. 56 红玫瑰 陈奕迅
  57. 57 浮夸 陈奕迅
  58. 58 爱情转移 陈奕迅
  59. 59 独家记忆 陈小春
  60. 60 记事本 陈慧琳
  61. 61 看我72变 蔡依林
  62. 62 寂寞在唱歌 阿桑
  63. 63 樱花草 Sweety
  64. 64 中国话 S.H.E
  65. 65 波斯猫 S.H.E
  66. 66 杀破狼-《仙剑奇侠传》电视剧片头曲 JS
  67. 67 Lydia F.I.R.
  68. 68 I Miss You 罗百吉_青春美少女.
盛夏的果实 - 莫文蔚
00:00 / 00:00
An audio error has occurred, player will skip forward in 2 seconds.

作词 : 李焯雄

作曲 : Meyna Co

编曲 : 张佳添

也许放弃 才能靠近你 不再见你

你才会把我记起 时间累积

这盛夏的果实 回忆里寂寞的香气

我要试着离开你 不要再想你

虽然这并不是我本意

你曾说过 会永远爱我

也许承诺 不过因为没把握 别用沉默

再去掩饰什么 当结果是那么赤裸裸

以为你会说什么 才会离开我

你只是转过头 不看我

不要刻意说 你还爱我

当看尽潮起潮落 只要你记得我

你曾说过 会永远爱我 也许承诺

不过证明没把握 不用难过

不用掩饰什么 当结果是那么赤裸裸

其实不必说什么

才能离开我 起码那些经过 属于我

也许放弃 才能靠近你 不再见你

你才会把我记起 时间累积

这盛夏的果实 回忆里爱情的香气

我以为不露痕迹 思念却满溢

或许这代表了我的心

不要刻意说 你还爱我

当看尽潮起潮落 只要你记得我

如果你会梦见我 请你再抱紧我