Package com.sun.jna.platform.win32.WinDef

Examples of com.sun.jna.platform.win32.WinDef.HWND


      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

                null, 1, null, 0, pcbNeeded, pcReturned);
        if (pcbNeeded.getValue() <= 0) {
            return new PRINTER_INFO_1[0];
        }

        PRINTER_INFO_1 pPrinterEnum = new PRINTER_INFO_1(pcbNeeded.getValue());
        if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
                null, 1, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
            throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }

        pPrinterEnum.read();

        return (PRINTER_INFO_1[]) pPrinterEnum.toArray(pcReturned.getValue());
    }
View Full Code Here

                null, 4, null, 0, pcbNeeded, pcReturned);
        if (pcbNeeded.getValue() <= 0) {
            return new PRINTER_INFO_4[0];
        }

        PRINTER_INFO_4 pPrinterEnum = new PRINTER_INFO_4(pcbNeeded.getValue());
        if (!Winspool.INSTANCE.EnumPrinters(Winspool.PRINTER_ENUM_LOCAL,
                null, 4, pPrinterEnum.getPointer(), pcbNeeded.getValue(), pcbNeeded, pcReturned)) {
            throw new Win32Exception(Kernel32.INSTANCE.GetLastError());
        }

        pPrinterEnum.read();

        return (PRINTER_INFO_4[]) pPrinterEnum.toArray(pcReturned.getValue());
    }
View Full Code Here

TOP

Related Classes of com.sun.jna.platform.win32.WinDef.HWND

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.