Package com.sun.jna

Examples of com.sun.jna.Memory


        public PRINTER_INFO_1() {
        }

        public PRINTER_INFO_1(int size) {
            super(new Memory(size));
        }
View Full Code Here


        public PRINTER_INFO_4() {
        }

        public PRINTER_INFO_4(int size) {
            super(new Memory(size));
        }
View Full Code Here

        public JOB_INFO_1() {
        }

        public JOB_INFO_1(int size) {
            super(new Memory(size));
        }
View Full Code Here

    // Capabilities string
    DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
    Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);
    DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue();
   
    LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue()));
    Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
    System.out.println("Cap-String:" + new String(pszASCIICapabilitiesString.getPointer().getString(0)));

    // Position
    MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION;
View Full Code Here

    int rc = Kernel32.INSTANCE.GetLastError();
    if (pSid.getValue() == 0 || rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
      throw new Win32Exception(rc);
    }

    Memory sidMemory = new Memory(pSid.getValue());
    PSID result = new PSID(sidMemory);
    char[] referencedDomainName = new char[cchDomainName.getValue() + 1];

    if (!Advapi32.INSTANCE.LookupAccountName(systemName, accountName,
        result, pSid, referencedDomainName, cchDomainName, peUse)) {
View Full Code Here

    }
    if (lpType.getValue() != WinNT.REG_MULTI_SZ) {
      throw new RuntimeException("Unexpected registry type "
          + lpType.getValue() + ", expected REG_SZ");
    }
    Memory data = new Memory(lpcbData.getValue());
    rc = Advapi32.INSTANCE.RegQueryValueEx(hKey, value, 0,
        lpType, data, lpcbData);
    if (rc != W32Errors.ERROR_SUCCESS
        && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
      throw new Win32Exception(rc);
    }
    ArrayList<String> result = new ArrayList<String>();
    int offset = 0;
    while (offset < data.size()) {
      String s = data.getWideString(offset);
      offset += s.length() * Native.WCHAR_SIZE;
      offset += Native.WCHAR_SIZE;
      if (s.length() == 0 && offset == data.size()) {
        // skip the final NULL
      } else {
        result.add(s);
      }
    }
View Full Code Here

    if (rc != W32Errors.ERROR_SUCCESS
        && rc != W32Errors.ERROR_INSUFFICIENT_BUFFER) {
      throw new Win32Exception(rc);
    }

    Memory byteData = new Memory(lpcbData.getValue());
    byteData.write(0, lpData, 0, lpcbData.getValue());

    if (lpType.getValue() == WinNT.REG_DWORD) {
      result = new Integer(byteData.getInt(0));
    } else if (lpType.getValue() == WinNT.REG_QWORD) {
      result = new Long(byteData.getLong(0));
    } else if (lpType.getValue() == WinNT.REG_BINARY) {
      result = byteData.getByteArray(0, lpcbData.getValue());
    } else if ((lpType.getValue() == WinNT.REG_SZ)
        || (lpType.getValue() == WinNT.REG_EXPAND_SZ)) {
      result = byteData.getWideString(0);
    }

    return result;
  }
View Full Code Here

      size += Native.WCHAR_SIZE;
    }
    size += Native.WCHAR_SIZE;

    int offset = 0;
    Memory data = new Memory(size);
    for (String s : arr) {
      data.setWideString(offset, s);
      offset += s.length() * Native.WCHAR_SIZE;
      offset += Native.WCHAR_SIZE;
    }
    for (int i = 0; i < Native.WCHAR_SIZE; i++) {
      data.setByte(offset++, (byte) 0);
    }

    int rc = Advapi32.INSTANCE.RegSetValueEx(hKey, name, 0,
        WinNT.REG_MULTI_SZ, data.getByteArray(0, size), size);

    if (rc != W32Errors.ERROR_SUCCESS) {
      throw new Win32Exception(rc);
    }
  }
View Full Code Here

              + lpType.getValue());
        }
        continue;
      }

      Memory byteData = new Memory(lpcbData.getValue());
      byteData.write(0, data, 0, lpcbData.getValue());

      switch (lpType.getValue()) {
      case WinNT.REG_QWORD: {
        keyValues.put(nameString, byteData.getLong(0));
        break;
      }
      case WinNT.REG_DWORD: {
        keyValues.put(nameString, byteData.getInt(0));
        break;
      }
      case WinNT.REG_SZ:
      case WinNT.REG_EXPAND_SZ: {
        keyValues.put(nameString, byteData.getWideString(0));
        break;
      }
      case WinNT.REG_BINARY: {
        keyValues.put(nameString,
            byteData.getByteArray(0, lpcbData.getValue()));
        break;
      }
      case WinNT.REG_MULTI_SZ: {
        Memory stringData = new Memory(lpcbData.getValue());
        stringData.write(0, data, 0, lpcbData.getValue());
        ArrayList<String> result = new ArrayList<String>();
        int offset = 0;
        while (offset < stringData.size()) {
          String s = stringData.getWideString(offset);
          offset += s.length() * Native.WCHAR_SIZE;
          offset += Native.WCHAR_SIZE;
          if (s.length() == 0 && offset == stringData.size()) {
            // skip the final NULL
          } else {
            result.add(s);
          }
        }
View Full Code Here

  public static ACCESS_ACEStructure[] getFileSecurity(String fileName,
      boolean compact) {
    int infoType = WinNT.DACL_SECURITY_INFORMATION;
    int nLength = 1024;
    boolean repeat = false;
    Memory memory = null;

    do {
      repeat = false;
      memory = new Memory(nLength);
      IntByReference lpnSize = new IntByReference();
      boolean succeded = Advapi32.INSTANCE.GetFileSecurity(new WString(
          fileName), infoType, memory, nLength, lpnSize);

      if (!succeded) {
        int lastError = Kernel32.INSTANCE.GetLastError();
        memory.clear();
        if (W32Errors.ERROR_INSUFFICIENT_BUFFER != lastError) {
          throw new Win32Exception(lastError);
        }
      }
      int lengthNeeded = lpnSize.getValue();
      if (nLength < lengthNeeded) {
        repeat = true;
        nLength = lengthNeeded;
        memory.clear();
      }
    } while (repeat);

    SECURITY_DESCRIPTOR_RELATIVE sdr = new WinNT.SECURITY_DESCRIPTOR_RELATIVE(
        memory);
    memory.clear();
    ACL dacl = sdr.getDiscretionaryACL();
    ACCESS_ACEStructure[] aceStructures = dacl.getACEStructures();

    if (compact) {
      Map<String, ACCESS_ACEStructure> aceMap = new HashMap<String, ACCESS_ACEStructure>();
View Full Code Here

TOP

Related Classes of com.sun.jna.Memory

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.