Java 类com.sun.jna.platform.win32.WinDef.DWORDByReference 实例源码

项目:MonitorBrightness    文件:MonitorJna.java   
/**
 * @param hPhysicalMonitor Handle to the physical monitor.
 * @param szPhysicalMonitorDescription 
 */
public MonitorJna(HANDLE hPhysicalMonitor, String szPhysicalMonitorDescription)
{
    this.handle = hPhysicalMonitor;
    this.name = szPhysicalMonitorDescription;

    DWORDByReference minBrightness = new DWORDByReference();
    DWORDByReference curBrightness = new DWORDByReference();
    DWORDByReference maxBrightness = new DWORDByReference();

    check(Dxva2.INSTANCE.GetMonitorBrightness(handle, minBrightness, curBrightness, maxBrightness));

    minBright = minBrightness.getValue().intValue();
    maxBright = maxBrightness.getValue().intValue();

    curBright = curBrightness.getValue().intValue();

}
项目:MonitorBrightness    文件:MonitorJna.java   
@Override
    public int getBrightness() throws Win32Exception
    {
        DWORDByReference minBrightness = new DWORDByReference();
        DWORDByReference curBrightness = new DWORDByReference();
        DWORDByReference maxBrightness = new DWORDByReference();

        check(Dxva2.INSTANCE.GetMonitorBrightness(handle, minBrightness, curBrightness, maxBrightness));

//      return curBright;
        return curBrightness.getValue().intValue();
    }
项目:MonitorBrightness    文件:MonitorControllerJna.java   
public MonitorControllerJna()
{
    System.out.println("Monitors: " + User32.INSTANCE.GetSystemMetrics(User32.SM_CMONITORS));

    User32.INSTANCE.EnumDisplayMonitors(null, null, new MONITORENUMPROC() {

        @Override
        public int apply(HMONITOR hMonitor, HDC hdc, RECT rect, LPARAM lparam)
        {
            System.out.println("Monitor handle: " + hMonitor);

            MONITORINFOEX info = new MONITORINFOEX();
            User32.INSTANCE.GetMonitorInfo(hMonitor, info);
            System.out.println(info.rcMonitor);

            DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
            Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors);
            int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();

            System.out.println("Physical monitors for " + hMonitor + ": " + monitorCount);

            PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
            Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);

            for (PHYSICAL_MONITOR mon : physMons)
            {
                String desc = new String(mon.szPhysicalMonitorDescription);
                monitors.add(new MonitorJna(mon.hPhysicalMonitor, desc));
            }

            return 1;
        }
    }, new LPARAM(0));
}
项目:MonitorBrightness    文件:MonitorInfoDemo.java   
static void enumerate(HMONITOR hMonitor)
{
    System.out.println("Found HMONITOR: " + hMonitor.getPointer().toString());

    MONITORINFOEX info = new MONITORINFOEX();
    User32.INSTANCE.GetMonitorInfo(hMonitor, info);
    System.out.println("Screen " + info.rcMonitor);
    System.out.println("Work area " + info.rcWork);
    boolean isPrimary = (info.dwFlags & WinUser.MONITORINFOF_PRIMARY) != 0;
    System.out.println("Primary? " + (isPrimary ? "yes" : "no"));
    System.out.println("Device " + new String(info.szDevice));

    DWORDByReference pdwNumberOfPhysicalMonitors = new DWORDByReference();
    Dxva2.INSTANCE.GetNumberOfPhysicalMonitorsFromHMONITOR(hMonitor, pdwNumberOfPhysicalMonitors);
    int monitorCount = pdwNumberOfPhysicalMonitors.getValue().intValue();

    System.out.println("HMONITOR is linked to " + monitorCount + " physical monitors");

    PHYSICAL_MONITOR[] physMons = new PHYSICAL_MONITOR[monitorCount];
    Dxva2.INSTANCE.GetPhysicalMonitorsFromHMONITOR(hMonitor, monitorCount, physMons);

    for (int i = 0; i < monitorCount; i++)
    {
        HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
        System.out.println("Monitor " + i + " - " + new String(physMons[i].szPhysicalMonitorDescription));

        enumeratePhysicalMonitor(hPhysicalMonitor);
    }
}
项目:yajsw    文件:Advapi32.java   
/**
 * Check if the if the security descriptor grants access to the given client token.
 *
 * @param pSecurityDescriptor [in] A pointer to a SECURITY_DESCRIPTOR structure against which access is checked.
 * @param ClientToken [in] A handle to an impersonation token that represents the client that is attempting to gain access. The handle must have TOKEN_QUERY access to the token; otherwise, the function fails with ERROR_ACCESS_DENIED.
 * @param DesiredAccess [in] Access mask that specifies the access rights to check. This mask must have been mapped by the MapGenericMask function to contain no generic access rights.<br>
 *                      If this parameter is MAXIMUM_ALLOWED, the function sets the GrantedAccess access mask to indicate the maximum access rights the security descriptor allows the client.
 * @param GenericMapping [in] A pointer to the GENERIC_MAPPING structure associated with the object for which access is being checked.
 * @param PrivilegeSet [out, optional] A pointer to a PRIVILEGE_SET structure that receives the privileges used to perform the access validation. If no privileges were used, the function sets the PrivilegeCount member to zero.
 * @param PrivilegeSetLength [in, out] Specifies the size, in bytes, of the buffer pointed to by the PrivilegeSet parameter.
 * @param GrantedAccess [out] A pointer to an access mask that receives the granted access rights. If AccessStatus is set to FALSE, the function sets the access mask to zero. If the function fails, it does not set the access mask.
 * @param AccessStatus [out] A pointer to a variable that receives the results of the access check. If the security descriptor allows the requested access rights to the client identified by the access token, AccessStatus is set to TRUE. Otherwise, AccessStatus is set to FALSE, and you can call GetLastError to get extended error information.
 * @return true on success; false on failure (use GetLastError to get extended error information)
 */
public boolean AccessCheck(Pointer pSecurityDescriptor,
                           HANDLE ClientToken, DWORD DesiredAccess,
                           GENERIC_MAPPING GenericMapping,
                           PRIVILEGE_SET PrivilegeSet,
                           DWORDByReference PrivilegeSetLength,
                           DWORDByReference GrantedAccess, BOOLByReference AccessStatus);
项目:Mem-Eater-Bug    文件:User32Util.java   
/**
 * Sends the specified message to one or more windows.
 * 
 * @see <a href=
 *      "https://msdn.microsoft.com/en-us/library/ms644952(v=vs.85).aspx">
 *      MSDN webpage#SendMessageTimeout function</a>
 * @param hWnd
 *            A handle to the window whose window procedure will receive the
 *            message.
 * @param msg
 *            The message to be sent.
 * @param wParam
 *            Any additional message-specific information.
 * @param lParam
 *            Any additional message-specific information.
 * @param fuFlags
 *            The behavior of this function.
 * @param uTimeout
 *            The duration of the time-out period, in milliseconds. If the
 *            message is a broadcast message, each window can use the full
 *            time-out period. For example, if you specify a five second
 *            time-out period and there are three top-level windows that
 *            fail to process the message, you could have up to a 15 second
 *            delay.
 * @return The result of the message processing. The value of this parameter
 *         depends on the message that is specified.
 * @throws Win32Exception
 *             If the operation was not successful
 */
private static Pointer sendMessageTimeoutA(final HWND hWnd, final int msg, final int wParam, final int lParam,
        final int fuFlags, final int uTimeout) throws Win32Exception {
    final DWORDByReference lpdwResult = new DWORDByReference();
    final long ret = User32.INSTANCE.SendMessageTimeout(hWnd, msg, wParam, lParam, fuFlags, uTimeout, lpdwResult);
    if (ret == 0) {
        throw new Win32Exception(Native.getLastError());
    }
    return Pointer.createConstant(lpdwResult.getValue().longValue());
}
项目:yajsw    文件:Advapi32.java   
/**
 * Applies the given mapping of generic access rights to the given access mask.
 * @param AccessMask [in, out] A pointer to an access mask.
 * @param GenericMapping [in] A pointer to a GENERIC_MAPPING structure specifying a mapping of generic access types to specific and standard access types.
 */
public void MapGenericMask(DWORDByReference AccessMask, GENERIC_MAPPING GenericMapping);
项目:NanoUI    文件:DWMapiExt.java   
public HRESULT DwmGetColorizationColor(DWORDByReference color, BOOLByReference pfOpaqueBlend);