Examples of Advapi32


Examples of jnacontrib.jna.Advapi32

   *            key type
   * @return root key
   */
  private static int getRegistryRootKey(REGISTRY_ROOT_KEY key)
  {
    Advapi32 advapi32;
    IntByReference pHandle;
    int handle = 0;

    advapi32 = Advapi32.INSTANCE;
    pHandle = new IntByReference();

    if (advapi32.RegOpenKeyEx(rootKeyMap.get(key), null, 0, 0, pHandle) == WINERROR.ERROR_SUCCESS)
    {
      handle = pHandle.getValue();
    }
    return (handle);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *            access mode
   * @return handle to the key or 0
   */
  private static int openKey(REGISTRY_ROOT_KEY rootKey, String subKeyName, int access)
  {
    Advapi32 advapi32;
    IntByReference pHandle;
    int rootKeyHandle;

    advapi32 = Advapi32.INSTANCE;
    rootKeyHandle = getRegistryRootKey(rootKey);
    pHandle = new IntByReference();

    if (advapi32.RegOpenKeyEx(rootKeyHandle, subKeyName, 0, access, pHandle) == WINERROR.ERROR_SUCCESS)
    {
      return (pHandle.getValue());

    }
    else
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *             on error
   * @return String or null
   */
  public static String getStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name) throws UnsupportedEncodingException
  {
    Advapi32 advapi32;
    IntByReference pType, lpcbData;
    byte[] lpData = new byte[1];
    int handle = 0;
    String ret = null;

    advapi32 = Advapi32.INSTANCE;
    pType = new IntByReference();
    lpcbData = new IntByReference();
    handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);

    if (handle != 0)
    {

      if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA)
      {
        lpData = new byte[lpcbData.getValue()];

        if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS)
        {
          ret = convertBufferToString(lpData);
        }
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   * @param name
   *            value name
   */
  public static int getIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name)
  {
    Advapi32 advapi32;
    IntByReference pType, lpcbData;
    byte[] lpData = new byte[1];
    int handle = 0;
    int ret = 0;

    advapi32 = Advapi32.INSTANCE;
    pType = new IntByReference();
    lpcbData = new IntByReference();
    handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);

    if (handle != 0)
    {

      if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_MORE_DATA)
      {
        lpData = new byte[lpcbData.getValue()];

        if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) == WINERROR.ERROR_SUCCESS)
        {
          ret = convertBufferToInt(lpData);
        }
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *            value name
   * @return true on success
   */
  public static boolean deleteValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name)
  {
    Advapi32 advapi32;
    int handle;
    boolean ret = true;

    advapi32 = Advapi32.INSTANCE;

    handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);

    if (handle != 0)
    {
      if (advapi32.RegDeleteValue(handle, name) == WINERROR.ERROR_SUCCESS)
      {
        ret = true;
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *             on error
   * @return true on success
   */
  public static boolean setStringValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, String value) throws UnsupportedEncodingException
  {
    Advapi32 advapi32;
    int handle;
    byte[] data;
    boolean ret = false;

    data = Arrays.copyOf(value.getBytes("UTF-16LE"), value.length() * 2 + 2);
    advapi32 = Advapi32.INSTANCE;
    handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);

    if (handle != 0)
    {
      if (advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_SZ, data, data.length) == WINERROR.ERROR_SUCCESS)
      {
        ret = true;
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   * @param value
   *            value
   */
  public static boolean setIntValue(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name, int value)
  {
    Advapi32 advapi32;
    int handle;
    byte[] data;
    boolean ret = false;

    data = new byte[4];
    data[0] = (byte) (value & 0xff);
    data[1] = (byte) ((value >> 8) & 0xff);
    data[2] = (byte) ((value >> 16) & 0xff);
    data[3] = (byte) ((value >> 24) & 0xff);
    advapi32 = Advapi32.INSTANCE;
    handle = openKey(rootKey, subKeyName, WINNT.KEY_READ | WINNT.KEY_WRITE);

    if (handle != 0)
    {

      if (advapi32.RegSetValueEx(handle, name, 0, WINNT.REG_DWORD, data, data.length) == WINERROR.ERROR_SUCCESS)
      {
        ret = true;
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *            value name
   * @return true if exists
   */
  public static boolean valueExists(REGISTRY_ROOT_KEY rootKey, String subKeyName, String name)
  {
    Advapi32 advapi32;
    IntByReference pType, lpcbData;
    byte[] lpData = new byte[1];
    int handle = 0;
    boolean ret = false;

    advapi32 = Advapi32.INSTANCE;
    pType = new IntByReference();
    lpcbData = new IntByReference();
    handle = openKey(rootKey, subKeyName, WINNT.KEY_READ);

    if (handle != 0)
    {

      if (advapi32.RegQueryValueEx(handle, name, null, pType, lpData, lpcbData) != WINERROR.ERROR_FILE_NOT_FOUND)
      {
        ret = true;

      }
      else
      {
        ret = false;
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *            key name
   * @return true on success
   */
  public static boolean createKey(REGISTRY_ROOT_KEY rootKey, String parent, String name)
  {
    Advapi32 advapi32;
    IntByReference hkResult, dwDisposition;
    int handle = 0;
    boolean ret = false;

    advapi32 = Advapi32.INSTANCE;
    hkResult = new IntByReference();
    dwDisposition = new IntByReference();
    handle = openKey(rootKey, parent, WINNT.KEY_READ);

    if (handle != 0)
    {

      if (advapi32.RegCreateKeyEx(handle, name, 0, null, WINNT.REG_OPTION_NON_VOLATILE, WINNT.KEY_READ, null, hkResult, dwDisposition) == WINERROR.ERROR_SUCCESS)
      {
        ret = true;
        advapi32.RegCloseKey(hkResult.getValue());

      }
      else
      {
        ret = false;
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here

Examples of jnacontrib.jna.Advapi32

   *            key name
   * @return true on success
   */
  public static boolean deleteKey(REGISTRY_ROOT_KEY rootKey, String parent, String name)
  {
    Advapi32 advapi32;
    int handle = 0;
    boolean ret = false;

    advapi32 = Advapi32.INSTANCE;
    handle = openKey(rootKey, parent, WINNT.KEY_READ);

    if (handle != 0)
    {

      if (advapi32.RegDeleteKey(handle, name) == WINERROR.ERROR_SUCCESS)
      {
        ret = true;

      }
      else
      {
        ret = false;
      }
      advapi32.RegCloseKey(handle);
    }
    return (ret);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.