Package com.sun.jna.ptr

Examples of com.sun.jna.ptr.PointerByReference


        }

        public List<WindowReference> children() {
            X11.WindowByReference root_return = new X11.WindowByReference();
            X11.WindowByReference parent_return = new X11.WindowByReference();
            PointerByReference ptr = new PointerByReference();
            IntByReference numChildren = new IntByReference();
            X.XQueryTree(display, window, root_return, parent_return, ptr, numChildren);
            if (ptr.getValue() == null || ptr.getValue() == Pointer.NULL)
                return null;

            List<WindowReference> ret = new ArrayList<>();

            Pointer base = ptr.getValue();
            int off = 0;
            for(int i = 0, count = numChildren.getValue(); i < count; i++) {
                X11.WindowByReference wref = new X11.WindowByReference();
                wref.setPointer(base.share(off));
                off += Pointer.SIZE;
                ret.add(new X11WindowReference(display, wref.getValue()));
            }

            X.XFree(ptr.getValue());
            return ret;
        }
View Full Code Here


    static final int FREENECT_DEPTH_10BIT_PACKED_SIZE = 384000;

    protected Freenect() {}

    public static Context createContext() {
        PointerByReference ctxPtr = new PointerByReference();
        int rval = freenect_init(ctxPtr, Pointer.NULL);
        if (rval == 0) {
            NativeContext ctx = new NativeContext(ctxPtr.getValue());
            ctx.startEventThread();
            return ctx;
        }
        throw new IllegalStateException("init() returned " + rval);
    }
View Full Code Here

            return freenect_num_devices(this);
        }

        @Override
        public Device openDevice(int index) {
            PointerByReference devicePtr = new PointerByReference();
            int rval = freenect_open_device(this, devicePtr, index);
            if (rval != 0) {
                throw new IllegalStateException("freenect_open_device() returned " + rval);
            }
            return new NativeDevice(devicePtr.getValue(), index);
        }
View Full Code Here

   *  HRESULT
   * @return
   *  Formatted message.
   */
  public static String formatMessageFromHR(HRESULT code) {
    PointerByReference buffer = new PointerByReference();       
        if (0 == Kernel32.INSTANCE.FormatMessage(
            WinBase.FORMAT_MESSAGE_ALLOCATE_BUFFER
            | WinBase.FORMAT_MESSAGE_FROM_SYSTEM
            | WinBase.FORMAT_MESSAGE_IGNORE_INSERTS,
                null,
                code.intValue(),
                0, // TODO: MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)
                buffer,
                0,
                null)) {
          throw new LastErrorException(Kernel32.INSTANCE.GetLastError());
        }        
      String s = buffer.getValue().getString(0, ! Boolean.getBoolean("w32.ascii"));
      s = s.replace(".\r",".").replace(".\n",".");
      Kernel32.INSTANCE.LocalFree(buffer.getValue());
      return s;   
  }
View Full Code Here

   *   Specifies the name of the domain.
   * @return
   *  Name of the primary domain controller.
   */
  public static String getDCName(String serverName, String domainName) {
    PointerByReference bufptr = new PointerByReference();
    try {   
        int rc = Netapi32.INSTANCE.NetGetDCName(domainName, serverName, bufptr);
        if (LMErr.NERR_Success != rc) {
          throw new Win32Exception(rc);
        }
        return bufptr.getValue().getString(0, true);
    } finally {
      if (W32Errors.ERROR_SUCCESS != Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue())) {
        throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
      }
    }
  }
View Full Code Here

   * 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);     
        }
      }
    }   
View Full Code Here

   * Get information about a computer.
   * @param computerName
   * @return Domain or workgroup name.
   */
  public static String getDomainName(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);     
      }   
      // type of domain: bufferType.getValue()
      return lpNameBuffer.getValue().getString(0, true);
    } finally {
      if (lpNameBuffer.getPointer() != null) {
        int rc = Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue());
        if (LMErr.NERR_Success != rc) {
          throw new Win32Exception(rc);     
        }
      }
    }
View Full Code Here

   * Get the names of local groups on a computer.
   * @param serverName Name of the computer.
   * @return An array of local group names.
   */
  public static LocalGroup[] getLocalGroups(String serverName) {
    PointerByReference bufptr = new PointerByReference();
    IntByReference entriesRead = new IntByReference();
    IntByReference totalEntries = new IntByReference();   
    try {
      int rc = Netapi32.INSTANCE.NetLocalGroupEnum(serverName, 1, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesRead, totalEntries, null);
      if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
        throw new Win32Exception(rc);
      }
      LMAccess.LOCALGROUP_INFO_1 group = new LMAccess.LOCALGROUP_INFO_1(bufptr.getValue());
      LMAccess.LOCALGROUP_INFO_1[] groups = (LOCALGROUP_INFO_1[]) group.toArray(entriesRead.getValue());
     
      ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
      for(LOCALGROUP_INFO_1 lgpi : groups) {
        LocalGroup lgp = new LocalGroup();
        lgp.name = lgpi.lgrui1_name.toString();     
        lgp.comment = lgpi.lgrui1_comment.toString();;
        result.add(lgp);
      }
      return result.toArray(new LocalGroup[0]);
    } finally {     
      if (bufptr.getValue() != Pointer.NULL) {
        int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
        if (LMErr.NERR_Success != rc) {
          throw new Win32Exception(rc);
        }
      }
    }
View Full Code Here

   * Get the names of global groups on a computer.
   * @param serverName Name of the computer.
   * @return An array of group names.
   */
  public static Group[] getGlobalGroups(String serverName) {
    PointerByReference bufptr = new PointerByReference();
    IntByReference entriesRead = new IntByReference();
    IntByReference totalEntries = new IntByReference();   
    try {
      int rc = Netapi32.INSTANCE.NetGroupEnum(serverName, 1, bufptr,
          LMCons.MAX_PREFERRED_LENGTH, entriesRead,
          totalEntries, null);
      if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
        throw new Win32Exception(rc);
      }
      LMAccess.GROUP_INFO_1 group = new LMAccess.GROUP_INFO_1(bufptr.getValue());
      LMAccess.GROUP_INFO_1[] groups = (LMAccess.GROUP_INFO_1[]) group.toArray(entriesRead.getValue());
     
      ArrayList<LocalGroup> result = new ArrayList<LocalGroup>();
      for(LMAccess.GROUP_INFO_1 lgpi : groups) {
        LocalGroup lgp = new LocalGroup();
        lgp.name = lgpi.grpi1_name.toString();     
        lgp.comment = lgpi.grpi1_comment.toString();;
        result.add(lgp);
      }
      return result.toArray(new LocalGroup[0]);
    } finally {     
      if (bufptr.getValue() != Pointer.NULL) {
        int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
        if (LMErr.NERR_Success != rc) {
          throw new Win32Exception(rc);
        }
      }
    }
View Full Code Here

   * Get the names of users on a computer.
   * @param serverName Name of the computer.
   * @return An array of users.
   */
  public static User[] getUsers(String serverName) {
    PointerByReference bufptr = new PointerByReference();
    IntByReference entriesRead = new IntByReference();
    IntByReference totalEntries = new IntByReference();   
    try {
      int rc = Netapi32.INSTANCE.NetUserEnum(serverName, 1, 0, bufptr,
          LMCons.MAX_PREFERRED_LENGTH, entriesRead,
          totalEntries, null);
      if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
        throw new Win32Exception(rc);
      }
      LMAccess.USER_INFO_1 user = new LMAccess.USER_INFO_1(bufptr.getValue());
      LMAccess.USER_INFO_1[] users = (LMAccess.USER_INFO_1[]) user.toArray(entriesRead.getValue());
     
      ArrayList<User> result = new ArrayList<User>();
      for(LMAccess.USER_INFO_1 lu : users) {
        User auser = new User();
        auser.name = lu.usri1_name.toString();
        result.add(auser);
      }
      return result.toArray(new User[0]);
    } finally {     
      if (bufptr.getValue() != Pointer.NULL) {
        int rc = Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue());
        if (LMErr.NERR_Success != rc) {
          throw new Win32Exception(rc);
        }
      }
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.ptr.PointerByReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.