Package com.sun.jna.platform.win32.WinNT

Examples of com.sun.jna.platform.win32.WinNT.PSID


        assertTrue(Kernel32.INSTANCE.CloseHandle(phToken.getValue()));
    }  
   
    public void testGetTokenGroupsInformation() {
      HANDLEByReference phToken = new HANDLEByReference();
      HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        assertTrue(Advapi32.INSTANCE.OpenProcessToken(processHandle,
            WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken));
        IntByReference tokenInformationLength = new IntByReference();
        assertFalse(Advapi32.INSTANCE.GetTokenInformation(phToken.getValue(),
            WinNT.TOKEN_INFORMATION_CLASS.TokenGroups, null, 0, tokenInformationLength));
View Full Code Here


      String convertedSidString = convertedSidStringPtr.getValue().getWideString(0);
      assertEquals(EVERYONE, convertedSidString);
    }
   
    public void testOpenEventLog() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      assertNotNull(h);
      assertFalse(h.equals(WinBase.INVALID_HANDLE_VALUE));
      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
View Full Code Here

      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
   
    public void testRegisterEventSource() {
      // the Security event log is reserved
      HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, "Security");
      assertNull(h);
      assertEquals(W32Errors.ERROR_ACCESS_DENIED, Kernel32.INSTANCE.GetLastError());
    }
View Full Code Here

            }
        } catch (Win32Exception e) {
            return;
        }

      HANDLE h = Advapi32.INSTANCE.RegisterEventSource(null, jnaEventSource);     
      IntByReference before = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, before));
      assertNotNull(h);
      String s[] = { "JNA", "Event" };
      Memory m = new Memory(4);
      m.setByte(0, (byte) 1);
      m.setByte(1, (byte) 2);
      m.setByte(2, (byte) 3);
      m.setByte(3, (byte) 4);
      assertTrue(Advapi32.INSTANCE.ReportEvent(h, WinNT.EVENTLOG_ERROR_TYPE, 0, 0, null, 2, 4, s, m));
      IntByReference after = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, after));
      assertTrue(before.getValue() < after.getValue());
      assertFalse(h.equals(WinBase.INVALID_HANDLE_VALUE));
      assertTrue(Advapi32.INSTANCE.DeregisterEventSource(h));
      Advapi32Util.registryDeleteKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
    }
View Full Code Here

      assertTrue(Advapi32.INSTANCE.DeregisterEventSource(h));
      Advapi32Util.registryDeleteKey(WinReg.HKEY_LOCAL_MACHINE, jnaEventSourceRegistryPath);
    }
   
    public void testGetNumberOfEventLogRecords() {
      HANDLE h = Advapi32.INSTANCE.OpenEventLog(null, "Application");
      assertFalse(h.equals(WinBase.INVALID_HANDLE_VALUE));
      IntByReference n = new IntByReference();
      assertTrue(Advapi32.INSTANCE.GetNumberOfEventLogRecords(h, n));
      assertTrue(n.getValue() >= 0);
      assertTrue(Advapi32.INSTANCE.CloseEventLog(h));
    }
View Full Code Here

        enableButton = new JButton("Enable");
        enableButton.setMnemonic('e');
        enableButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                HRESULT hResult;
                hResult = LibDwmApi.INSTANCE.DwmEnableComposition(LibDwmApi.DWM_EC_ENABLECOMPOSITION);
                System.out.println("DwmEnableComposition hResult=" + hResult.intValue());
                dumpStatus();
            }
        });

        disableButton = new JButton("Disable");
        disableButton.setMnemonic('d');
        disableButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                HRESULT hResult;
                hResult = LibDwmApi.INSTANCE.DwmEnableComposition(LibDwmApi.DWM_EC_DISABLECOMPOSITION);
                System.out.println("DwmEnableComposition hResult=" + hResult.intValue());
                dumpStatus();
            }
        });

        contentPane = new JPanel();
View Full Code Here

        frame.setVisible(true);
    }

    private void dumpStatus() {
        IntByReference pfEnabled = new IntByReference();
        HRESULT hResult = LibDwmApi.INSTANCE.DwmIsCompositionEnabled(pfEnabled);
        System.out.println("DwmIsCompositionEnabled hResult=" + hResult.intValue());
        if(hResult.intValue() == LibDwmApi.S_OK) {
            System.out.println("Desktop composition is " + (pfEnabled.getValue() != 0 ? "enabled" : "disabled"));
        }
    }
View Full Code Here

  }

  public void testLoadRegTypeLib() {
    CLSID.ByReference clsid = new CLSID.ByReference();
    // get CLSID from string, Microsoft Scripting Engine
    HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(
        "{420B2830-E718-11CF-893D-00A0C9054228}"), clsid);
    COMUtils.checkRC(hr);
    assertEquals(0, hr.intValue());

    // get user default lcid
    LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
    PointerByReference pWordTypeLib = new PointerByReference();
    // get typelib version 1.0
    hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, 1, 0, lcid, pWordTypeLib);
    COMUtils.checkRC(hr);
    assertEquals(0, hr.intValue());
  }
View Full Code Here

    assertEquals("{00000000-0000-0000-0000-000000000000}",
        Native.toString(lpsz));
  }

  public void testCoInitializeEx() {
    HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, 0);
    assertTrue(W32Errors.SUCCEEDED(hr.intValue())
        || hr.intValue() == W32Errors.RPC_E_CHANGED_MODE);
    if (W32Errors.SUCCEEDED(hr.intValue()))
      Ole32.INSTANCE.CoUninitialize();
  }
View Full Code Here

    if (W32Errors.SUCCEEDED(hr.intValue()))
      Ole32.INSTANCE.CoUninitialize();
  }

  public void testCoCreateInstance() {
    HRESULT hrCI = Ole32.INSTANCE.CoInitializeEx(null, 0);

    GUID guid = Ole32Util
        .getGUIDFromString("{00021401-0000-0000-C000-000000000046}"); // Shell object
    GUID riid = Ole32Util
        .getGUIDFromString("{000214EE-0000-0000-C000-000000000046}"); // IShellLinkA

    PointerByReference pDispatch = new PointerByReference();

    HRESULT hr = Ole32.INSTANCE.CoCreateInstance(guid, null, // pOuter =
                                  // null, no
                                  // aggregation
        WTypes.CLSCTX_LOCAL_SERVER, riid, pDispatch);
    assertTrue(W32Errors.SUCCEEDED(hr.intValue()));
    assertTrue(!pDispatch.equals(Pointer.NULL));
    // We leak this iUnknown reference because we don't have the JNACOM lib
    // here to wrap the native iUnknown pointer and call iUnknown.release()
    if (W32Errors.SUCCEEDED(hrCI.intValue()))
      Ole32.INSTANCE.CoUninitialize();
View Full Code Here

TOP

Related Classes of com.sun.jna.platform.win32.WinNT.PSID

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.