Package com.sun.jna.ptr

Examples of com.sun.jna.ptr.IntByReference


  {
    if (_indexes != null)
      return;
    _indexes = new HashMap();
    int ret = 0;
    IntByReference hkey = new IntByReference();

    ret = Advapi32.INSTANCE.RegOpenKeyExA(Advapi32.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009", 0,
        Advapi32.KEY_READ, hkey);
    // System.out.println(">> "+ret + " " +
    // Integer.toHexString(hkey.getValue()));

    int BufferSize = 1;
    int BYTEINCREMENT = 1024;
    Memory PerfData = new Memory(BufferSize);
    PerfData.clear();
    IntByReference PBufferSize = new IntByReference();

    PBufferSize.setValue(BufferSize);

    // System.out.println("Allocating memory...");
    for (ret = Advapi32.INSTANCE.RegQueryValueExA(hkey.getValue(), "Counter", null, null, PerfData, PBufferSize); ret == Advapi32.ERROR_MORE_DATA; ret = Advapi32.INSTANCE
        .RegQueryValueExA(hkey.getValue(), "Counter", null, null, PerfData, PBufferSize))
    {

      // Get a buffer that is big enough.

      BufferSize += BYTEINCREMENT;
      PBufferSize = new IntByReference();
      PBufferSize.setValue(BufferSize);
      PerfData = new Memory(BufferSize);
      PerfData.clear();
    }
    // System.out.println("Final buffer size is " +PBufferSize.getValue());
    if (ret != Pdhdll.ERROR_SUCCESS)
      System.out.println(Integer.toHexString(ret));
    else
    {
      String key;
      String counter;
      int i = 0;
      while (i < PBufferSize.getValue())
      {
        key = PerfData.getString(i);
        i += key.length() + 1;
        counter = PerfData.getString(i);
        i += counter.length() + 1;
View Full Code Here


    readIndexMap();
    Integer index = (Integer) _indexes.get(name);
    if (index == null)
      return name;
    Memory buff = new Memory(256);
    IntByReference buffSize = new IntByReference();
    buffSize.setValue(256);
    if (Pdhdll.INSTANCE.PdhLookupPerfNameByIndexA(null, index.intValue(), buff, buffSize) == Pdhdll.ERROR_SUCCESS)
      return buff.getString(0);
    return name;
  }
View Full Code Here

    try
    {
      Pointer cluster = Clusapi.INSTANCE.OpenCluster(null);
      Pointer hEnum = Clusapi.INSTANCE.ClusterOpenEnum(cluster, Clusapi.CLUSTER_ENUM_GROUP);
      int dwIndex = 0;
      IntByReference lpdwType = new IntByReference();
      IntByReference lpcchName = new IntByReference();
      Memory lpszName = new Memory(256);
      lpszName.clear();
      lpcchName.setValue(256);
      int result = 0;
      do
      {
        result = Clusapi.INSTANCE.ClusterEnum(hEnum, dwIndex, lpdwType, lpszName, lpcchName);
        if (result == Clusapi.ERROR_SUCCESS)
View Full Code Here

      Pointer hGroup = Clusapi.INSTANCE.OpenClusterGroup(cluster, new WString(groupName));

      if (hGroup == null)
        throw new RuntimeException("Clusapi call to OpenClusterGroup returned err code " + MyKernel32.INSTANCE.GetLastError());

      IntByReference lpcchNodeName = new IntByReference();
      Memory lpszNodeName = new Memory(256);
      lpszNodeName.clear();
      lpcchNodeName.setValue(256);

      int state = Clusapi.INSTANCE.GetClusterGroupState(hGroup, lpszNodeName, lpcchNodeName);
      String location = lpszNodeName.getString(0, true);

      if (state == Clusapi.CLUSTER_GROUP_STATE_UNKNOWN)
View Full Code Here

    Set<ClusterGroupInfo> result = new LinkedHashSet<ClusterGroupInfo>();

    try
    {
      IntByReference lpdwType = new IntByReference();
      IntByReference lpcchName = new IntByReference(0);
      Memory lpszName = new Memory(256);

      int dwIndex = 0;

      int returnValue = 0;
      do
      {
        lpdwType.setValue(0);
        lpcchName.setValue(0);
        lpszName.clear();
        lpcchName.setValue(256);

        returnValue = Clusapi.INSTANCE.ClusterEnum(hEnum, dwIndex, lpdwType, lpszName, lpcchName);

        if (returnValue == Clusapi.ERROR_SUCCESS)
        {
View Full Code Here

      {
        check = new Runnable()
        {
          public void run()
          {
            IntByReference lpdwNotifyKey = new IntByReference();
            IntByReference lpdwFilterType = new IntByReference();
            IntByReference lpcchName = new IntByReference();
            IntByReference dwNotifyKey = new IntByReference();
            Memory lpszName = new Memory(256);
            Pointer minusOne = Pointer.createConstant(-1);
            int dwMilliseconds = 300 * 1000;
            final int dwFilter = Clusapi.CLUSTER_CHANGE_GROUP_STATE | Clusapi.CLUSTER_CHANGE_HANDLE_CLOSE
                | Clusapi.CLUSTER_CHANGE_GROUP_DELETED | Clusapi.CLUSTER_CHANGE_CLUSTER_STATE
                | Clusapi.CLUSTER_CHANGE_CLUSTER_RECONNECT | Clusapi.CLUSTER_CHANGE_GROUP_ADDED;

            while (!_stopped)
            {
              Pointer hCluster = null;
              Pointer hChange = null;

              long started = System.currentTimeMillis();

              try
              {
                lpdwNotifyKey.setValue(0);
                lpdwFilterType.setValue(0);
                lpcchName.setValue(0);
                dwNotifyKey.setValue(0);
                lpszName.clear();
                lpcchName.setValue(256);

                hCluster = Clusapi.INSTANCE.OpenCluster(null);
                if (hCluster == null)
View Full Code Here

   * @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

   * @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
    {
      return (0);
View Full Code Here

   * @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)
    {

View Full Code Here

   *            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)
    {

View Full Code Here

TOP

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

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.