Package com.sun.jna.examples.win32.WinNT

Examples of com.sun.jna.examples.win32.WinNT.HANDLEByReference


        return Holder.INSTANCE;
    }

    private static class W32WindowUtils extends NativeWindowUtils {
        private HWND getHWnd(Component w) {
            HWND hwnd = new HWND();
            hwnd.setPointer(Native.getComponentPointer(w));
            return hwnd;
        }
View Full Code Here


            if (!isWindowAlphaSupported()) {
                throw new UnsupportedOperationException("Set sun.java2d.noddraw=true to enable transparent windows");
            }
            whenDisplayable(w, new Runnable() {
                public void run() {
                    HWND hWnd = getHWnd(w);
                    User32 user = User32.INSTANCE;
                    int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
                    byte level = (byte)((int)(255 * alpha) & 0xFF);
                    if (usingUpdateLayeredWindow(w)) {
                        // If already using UpdateLayeredWindow, continue to
View Full Code Here

            if (transparent == isTransparent)
                return;
            whenDisplayable(w, new Runnable() {
                public void run() {
                    User32 user = User32.INSTANCE;
                    HWND hWnd = getHWnd(w);
                    int flags = user.GetWindowLong(hWnd, User32.GWL_EXSTYLE);
                    JRootPane root = ((RootPaneContainer)w).getRootPane();
                    JLayeredPane lp = root.getLayeredPane();
                    Container content = root.getContentPane();
                    if (content instanceof W32TransparentContentPane) {
View Full Code Here

        private void setWindowRegion(final Component w, final HRGN hrgn) {
            whenDisplayable(w, new Runnable() {
                public void run() {
                    GDI32 gdi = GDI32.INSTANCE;
                    User32 user = User32.INSTANCE;
                    HWND hWnd = getHWnd(w);
                    try {
                        user.SetWindowRgn(hWnd, hrgn, true);
                        setForceHeavyweightPopups(getWindow(w), hrgn != null);
                    }
                    finally {
View Full Code Here

                    POINT winLoc = new POINT();
                    winLoc.x = win.getX();
                    winLoc.y = win.getY();
                    POINT srcLoc = new POINT();
                    BLENDFUNCTION blend = new BLENDFUNCTION();
                    HWND hWnd = getHWnd(win);
                    // extract current constant alpha setting, if possible
                    ByteByReference bref = new ByteByReference();
                    IntByReference iref = new IntByReference();
                    byte level = getAlpha(win);
                    try {
View Full Code Here

        HANDLE hFile = null;
        try {
            hFile = Kernel32.INSTANCE.CreateFile(fileName, WinNT.GENERIC_READ,
                    WinNT.FILE_SHARE_READ, new WinBase.SECURITY_ATTRIBUTES(),
                    WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL,
                    new HANDLEByReference().getValue());

            if (WinBase.INVALID_HANDLE_VALUE.equals(hFile)) {
                throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
            }
View Full Code Here

   * Return the group memberships of the currently logged on user.
   *
   * @return An array of groups.
   */
  public static Account[] getCurrentUserGroups() {
    HANDLEByReference phToken = new HANDLEByReference();
    try {
      // open thread or process token
      HANDLE threadHandle = Kernel32.INSTANCE.GetCurrentThread();
      if (!Advapi32.INSTANCE.OpenThreadToken(threadHandle,
          WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, true, phToken)) {
        if (W32Errors.ERROR_NO_TOKEN != Kernel32.INSTANCE
            .GetLastError()) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }
        HANDLE processHandle = Kernel32.INSTANCE.GetCurrentProcess();
        if (!Advapi32.INSTANCE.OpenProcessToken(processHandle,
            WinNT.TOKEN_DUPLICATE | WinNT.TOKEN_QUERY, phToken)) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }
      }
      return getTokenGroups(phToken.getValue());
    } finally {
      if (phToken.getValue() != WinBase.INVALID_HANDLE_VALUE) {
        if (!Kernel32.INSTANCE.CloseHandle(phToken.getValue())) {
          throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }
      }
    }
  }
View Full Code Here

        HANDLE hFile = null;
        try {
            hFile = Kernel32.INSTANCE.CreateFile(fileName, WinNT.GENERIC_READ,
                    WinNT.FILE_SHARE_READ, new WinBase.SECURITY_ATTRIBUTES(),
                    WinNT.OPEN_EXISTING, WinNT.FILE_ATTRIBUTE_NORMAL,
                    new HANDLEByReference().getValue());

            if (WinBase.INVALID_HANDLE_VALUE.equals(hFile)) {
                throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
            }
View Full Code Here

        // ignore test if not able to add user (need to be administrator to do this).
        if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
            return;
        }
        try {
            HANDLEByReference phUser = new HANDLEByReference();
            try {
                assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(),
                                                       null, userInfo.usri1_password.toString(), WinBase.LOGON32_LOGON_NETWORK,
                                                       WinBase.LOGON32_PROVIDER_DEFAULT, phUser));
                Account[] groups = Advapi32Util.getTokenGroups(phUser.getValue());
                assertTrue(groups.length > 0);
                for(Account group : groups) {
                    assertTrue(group.name.length() > 0);
                    assertTrue(group.sidString.length() > 0);
                    assertTrue(group.sid.length > 0);
                }
            } finally {
                if (phUser.getValue() != WinBase.INVALID_HANDLE_VALUE) {
                    Kernel32.INSTANCE.CloseHandle(phUser.getValue());
                }       
            }
        } finally {
            assertEquals("Error in NetUserDel",
                         LMErr.NERR_Success,
View Full Code Here

        // ignore test if not able to add user (need to be administrator to do this).
        if (LMErr.NERR_Success != Netapi32.INSTANCE.NetUserAdd(null, 1, userInfo, null)) {
            return;
        }
        try {
            HANDLEByReference phUser = new HANDLEByReference();
            try {
                assertTrue(Advapi32.INSTANCE.LogonUser(userInfo.usri1_name.toString(),
                                                       null, userInfo.usri1_password.toString(), WinBase.LOGON32_LOGON_NETWORK,
                                                       WinBase.LOGON32_PROVIDER_DEFAULT, phUser));
                Advapi32Util.Account account = Advapi32Util.getTokenAccount(phUser.getValue());
                assertTrue(account.name.length() > 0);
                assertEquals(userInfo.usri1_name.toString(), account.name);
            } finally {
                if (phUser.getValue() != WinBase.INVALID_HANDLE_VALUE) {
                    Kernel32.INSTANCE.CloseHandle(phUser.getValue());
                }
            }
        } finally {
            assertEquals(LMErr.NERR_Success, Netapi32.INSTANCE.NetUserDel(
                                                                          null, userInfo.usri1_name.toString()));     
View Full Code Here

TOP

Related Classes of com.sun.jna.examples.win32.WinNT.HANDLEByReference

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.