Package com.sun.jna.ptr

Examples of com.sun.jna.ptr.PointerByReference


            bufptr.getValue()));
      }
    }
   
    public void testNetGetDCName() {
      PointerByReference lpNameBuffer = new PointerByReference();
      IntByReference BufferType = new IntByReference();
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetJoinInformation(null, lpNameBuffer, BufferType));     
      if (BufferType.getValue() == LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName) {
        PointerByReference bufptr = new PointerByReference();
        assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGetDCName(null, null, bufptr));
        String dc = bufptr.getValue().getString(0);
        assertTrue(dc.length() > 0);
        assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
      }
      assertEquals(W32Errors.ERROR_SUCCESS, Netapi32.INSTANCE.NetApiBufferFree(lpNameBuffer.getValue()));
    }
View Full Code Here


    }
   
    public void testNetUserGetGroups() {
      User[] users = Netapi32Util.getUsers();
      assertTrue(users.length >= 1);
      PointerByReference bufptr = new PointerByReference();
      IntByReference entriesread = new IntByReference();
      IntByReference totalentries = new IntByReference();
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetGroups(
          null, users[0].name, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH,
          entriesread, totalentries));
      GROUP_USERS_INFO_0 lgroup = new GROUP_USERS_INFO_0(bufptr.getValue());     
      GROUP_USERS_INFO_0[] lgroups = (GROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
        for (GROUP_USERS_INFO_0 localGroupInfo : lgroups) {
          assertTrue(localGroupInfo.grui0_name.length() > 0);
        }
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    }
View Full Code Here

    }
   
    public void testNetUserGetLocalGroups() {
      String currentUser = Secur32Util.getUserNameEx(
        EXTENDED_NAME_FORMAT.NameSamCompatible);
      PointerByReference bufptr = new PointerByReference();
      IntByReference entriesread = new IntByReference();
      IntByReference totalentries = new IntByReference();
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserGetLocalGroups(
          null, currentUser, 0, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH,
          entriesread, totalentries));
      LOCALGROUP_USERS_INFO_0 lgroup = new LOCALGROUP_USERS_INFO_0(bufptr.getValue());     
      LOCALGROUP_USERS_INFO_0[] lgroups = (LOCALGROUP_USERS_INFO_0[]) lgroup.toArray(entriesread.getValue());
        for (LOCALGROUP_USERS_INFO_0 localGroupInfo : lgroups) {
          assertTrue(localGroupInfo.lgrui0_name.length() > 0);
        }
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    }   
View Full Code Here

        }
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    }   
   
    public void testNetGroupEnum() {
      PointerByReference bufptr = new PointerByReference();
      IntByReference entriesread = new IntByReference();
      IntByReference totalentries = new IntByReference();
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetGroupEnum(
          null, 2, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));     
      GROUP_INFO_2 group = new GROUP_INFO_2(bufptr.getValue());     
      GROUP_INFO_2[] groups = (GROUP_INFO_2[]) group.toArray(entriesread.getValue());
        for (GROUP_INFO_2 grpi : groups) {
          assertTrue(grpi.grpi2_name.length() > 0);
        }
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    }
View Full Code Here

        }
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    }
   
    public void testNetUserEnum() {
      PointerByReference bufptr = new PointerByReference();
      IntByReference entriesread = new IntByReference();
      IntByReference totalentries = new IntByReference();
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserEnum(         
          null, 1, 0, bufptr, LMCons.MAX_PREFERRED_LENGTH, entriesread, totalentries, null));     
      USER_INFO_1 userinfo = new USER_INFO_1(bufptr.getValue());     
      USER_INFO_1[] userinfos = (USER_INFO_1[]) userinfo.toArray(entriesread.getValue());
        for (USER_INFO_1 ui : userinfos) {
          assertTrue(ui.usri1_name.length() > 0);
        }
      assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetApiBufferFree(bufptr.getValue()));
    }   
View Full Code Here

    public void testDsEnumerateDomainTrusts() {
      if (Netapi32Util.getJoinStatus() != LMJoin.NETSETUP_JOIN_STATUS.NetSetupDomainName)
        return;

      IntByReference domainTrustCount = new IntByReference();
        PointerByReference domainsPointerRef = new PointerByReference();
        assertEquals(W32Errors.NO_ERROR, Netapi32.INSTANCE.DsEnumerateDomainTrusts(null,
                DsGetDC.DS_DOMAIN_VALID_FLAGS, domainsPointerRef, domainTrustCount));
      assertTrue(domainTrustCount.getValue() >= 0);
     
        DS_DOMAIN_TRUSTS domainTrustRefs = new DS_DOMAIN_TRUSTS(domainsPointerRef.getValue());
        DS_DOMAIN_TRUSTS[] domainTrusts = (DS_DOMAIN_TRUSTS[]) domainTrustRefs.toArray(new DS_DOMAIN_TRUSTS[domainTrustCount.getValue()]);

      for(DS_DOMAIN_TRUSTS trust : domainTrusts) {
      assertTrue(trust.DnsDomainName.length() > 0);
      assertTrue(Advapi32.INSTANCE.IsValidSid(trust.DomainSid));
View Full Code Here

  super(msg+"\n"+toErrorString(code));
  this.code = code;
    }
   
    private static String toErrorString(int code) {
        PointerByReference pMsg=new PointerByReference();
        Pointer msg;
        String out;
        if(null!=win32MlOsMainDll){
            win32MlOsMainDll.err_Msg(code, pMsg);
            msg=pMsg.getValue();
            out=msg.getString(0);
        }else{
            out="Could not retrieve error description, MLOSMAIN Dll not loaded.\nError code="+code;
        }
        return out;
View Full Code Here

         */
        public List<String> suggest(String word) throws CharacterCodingException {
            List<String> res = new ArrayList<>();
            try {   
                int suggestionsCount = 0;
                PointerByReference suggestions = new PointerByReference();
                final byte[] wordAsBytes = stringToBytes(word);
                if (wordAsBytes.length == 0 && word.length() > 0) {
                    return res;
                }
                suggestionsCount = hsl.Hunspell_suggest(
                        hunspellDict, suggestions, stringToBytes(word));
                if (suggestionsCount == 0) {
                    return res;
                }

                // Get each of the suggestions out of the pointer array.
                Pointer[] pointerArray = suggestions.getValue().
                        getPointerArray(0, suggestionsCount);

                for (int i=0; i<suggestionsCount; i++) {
                    long len = pointerArray[i].indexOf(0, (byte)0);
                    if (len != -1) {
View Full Code Here

    /**
     * Based on {@link Netapi32Util#getUsers}, but returns more information.
     */
    static void enumerateUserInfo(String serverName, UserInfoRecipient recipient) {
        PointerByReference bufptr = new PointerByReference();
        IntByReference entriesRead = new IntByReference();
        IntByReference totalEntries = new IntByReference();
        try {
            int rc = Netapi32.INSTANCE.NetUserEnum(
                    serverName, 10, LMAccess.FILTER_NORMAL_ACCOUNT, bufptr,
                    LMCons.MAX_PREFERRED_LENGTH, entriesRead,
                    totalEntries, null);
            if (LMErr.NERR_Success != rc || bufptr.getValue() == Pointer.NULL) {
                throw new Win32Exception(rc);
            }
            USER_INFO_10 user = new USER_INFO_10(bufptr.getValue());
            USER_INFO_10[] users = (USER_INFO_10[]) user.toArray(entriesRead.getValue());
            for (USER_INFO_10 lu : users) {
                recipient.receiveUserInfo(lu.usri10_name.toString(), lu.usri10_full_name.toString());
            }
        } 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

        }

        public X11WindowReference parent() {
            X11.WindowByReference root_return = new X11.WindowByReference();
            X11.WindowByReference parent_return = new X11.WindowByReference();
            PointerByReference ptr = new PointerByReference();
            X.XQueryTree(display, window, root_return, parent_return, ptr, new IntByReference());
            if(ptr.getValue() != null && ptr.getValue() != Pointer.NULL)
                X.XFree(ptr.getValue());
            return new X11WindowReference(display, parent_return.getValue());
        }
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.