C#调用C函数 out int 对应 java 数据类型 com.sun.jna.ptr.IntByReference
How to use
IntByReference
in
- IntByReference
- PointerByReference
Represents a reference to a pointer to native data. In C notation, void**.
- LongByReference
- DoubleByReference
- NativeLongByReference
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; } } }
ProcessTreeDarwinProcess.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. } } }
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; }
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 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步