Search in sources :

Example 11 with DWORDByReference

use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.

the class Dxva2Test method testGetMonitorDisplayAreaPosition.

@Test
public void testGetMonitorDisplayAreaPosition() {
    HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
    // the method returns FALSE if the monitor driver doesn't support it,
    // but verifies that the JNA mapping is correct (no exception)
    MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION;
    DWORDByReference pdwMinimumPosition = new DWORDByReference();
    DWORDByReference pdwCurrentPosition = new DWORDByReference();
    DWORDByReference pdwMaximumPosition = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition);
}
Also used : DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) HANDLE(com.sun.jna.platform.win32.WinNT.HANDLE) MC_POSITION_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_POSITION_TYPE)

Example 12 with DWORDByReference

use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.

the class Dxva2Test method testGetMonitorCapabilities.

@Test
public void testGetMonitorCapabilities() {
    HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
    // the method returns FALSE if the monitor driver doesn't support it,
    // but verifies that the JNA mapping is correct (no exception)
    DWORDByReference temps = new DWORDByReference();
    DWORDByReference caps = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps);
}
Also used : DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) HANDLE(com.sun.jna.platform.win32.WinNT.HANDLE)

Example 13 with DWORDByReference

use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.

the class Dxva2Test method testGetMonitorDisplayAreaSize.

@Test
public void testGetMonitorDisplayAreaSize() {
    HANDLE hPhysicalMonitor = physMons[0].hPhysicalMonitor;
    // the method returns FALSE if the monitor driver doesn't support it,
    // but verifies that the JNA mapping is correct (no exception)
    MC_SIZE_TYPE ptSizeType = MC_SIZE_TYPE.MC_WIDTH;
    DWORDByReference pdwMinimumSize = new DWORDByReference();
    DWORDByReference pdwCurrentSize = new DWORDByReference();
    DWORDByReference pdwMaximumSize = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize);
}
Also used : DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) HANDLE(com.sun.jna.platform.win32.WinNT.HANDLE) MC_SIZE_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_SIZE_TYPE)

Example 14 with DWORDByReference

use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.

the class ProxyObject method advise.

public IComEventCallbackCookie advise(Class<?> comEventCallbackInterface, final IComEventCallbackListener comEventCallbackListener) {
    assert COMUtils.comIsInitialized() : "COM not initialized";
    try {
        ComInterface comInterfaceAnnotation = comEventCallbackInterface.getAnnotation(ComInterface.class);
        if (null == comInterfaceAnnotation) {
            throw new COMException("advise: Interface must define a value for either iid via the ComInterface annotation");
        }
        final IID iid = this.getIID(comInterfaceAnnotation);
        final ConnectionPoint rawCp = this.fetchRawConnectionPoint(iid);
        // create the dispatch listener
        final IDispatchCallback rawListener = factory.createDispatchCallback(comEventCallbackInterface, comEventCallbackListener);
        // store it the comEventCallback argument, so it is not garbage
        // collected.
        comEventCallbackListener.setDispatchCallbackListener(rawListener);
        // set the dispatch listener to listen to events from the connection
        // point
        final DWORDByReference pdwCookie = new DWORDByReference();
        HRESULT hr = rawCp.Advise(rawListener, pdwCookie);
        // release before check in case check
        int n = rawCp.Release();
        // throws exception
        COMUtils.checkRC(hr);
        // return the cookie so that a call to stop listening can be made
        return new ComEventCallbackCookie(pdwCookie.getValue());
    } catch (Exception e) {
        throw new COMException("Error occured in advise when trying to connect the listener " + comEventCallbackListener, e);
    }
}
Also used : COMException(com.sun.jna.platform.win32.COM.COMException) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) IID(com.sun.jna.platform.win32.Guid.IID) REFIID(com.sun.jna.platform.win32.Guid.REFIID) IDispatchCallback(com.sun.jna.platform.win32.COM.IDispatchCallback) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) ComInterface(com.sun.jna.platform.win32.COM.util.annotation.ComInterface) ConnectionPoint(com.sun.jna.platform.win32.COM.ConnectionPoint) ConnectionPoint(com.sun.jna.platform.win32.COM.ConnectionPoint) TimeoutException(java.util.concurrent.TimeoutException) COMException(com.sun.jna.platform.win32.COM.COMException) InvocationTargetException(java.lang.reflect.InvocationTargetException) ExecutionException(java.util.concurrent.ExecutionException)

Example 15 with DWORDByReference

use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.

the class MonitorInfoDemo method enumeratePhysicalMonitor.

/**
	 * @param hPhysicalMonitor
	 */
private static void enumeratePhysicalMonitor(HANDLE hPhysicalMonitor) {
    MC_DISPLAY_TECHNOLOGY_TYPE.ByReference techType = new MC_DISPLAY_TECHNOLOGY_TYPE.ByReference();
    Dxva2.INSTANCE.GetMonitorTechnologyType(hPhysicalMonitor, techType);
    System.out.println("TECHTYPE: " + techType.getValue());
    DWORDByReference temps = new DWORDByReference();
    DWORDByReference caps = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorCapabilities(hPhysicalMonitor, caps, temps);
    System.out.println("CAPS " + EnumUtils.setFromInteger(caps.getValue().intValue(), HighLevelMonitorConfigurationAPI.MC_CAPS.class));
    System.out.println("Temps " + temps.getValue());
    // Brightness
    DWORDByReference pdwMinimumBrightness = new DWORDByReference();
    DWORDByReference pdwCurrentBrightness = new DWORDByReference();
    DWORDByReference pdwMaximumBrightness = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorBrightness(hPhysicalMonitor, pdwMinimumBrightness, pdwCurrentBrightness, pdwMaximumBrightness);
    System.out.println("Brightness Min: " + pdwMinimumBrightness.getValue());
    System.out.println("Brightness Current: " + pdwCurrentBrightness.getValue());
    System.out.println("Brightness Max: " + pdwMaximumBrightness.getValue());
    // Contrast
    DWORDByReference pdwMinimumContrast = new DWORDByReference();
    DWORDByReference pdwCurrentContrast = new DWORDByReference();
    DWORDByReference pdwMaximumContrast = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorContrast(hPhysicalMonitor, pdwMinimumContrast, pdwCurrentContrast, pdwMaximumContrast);
    System.out.println("Contrast Min: " + pdwMinimumContrast.getValue());
    System.out.println("Contrast Current: " + pdwCurrentContrast.getValue());
    System.out.println("Contrast Max: " + pdwMaximumContrast.getValue());
    // Temperature
    MC_COLOR_TEMPERATURE.ByReference pctCurrentColorTemperature = new MC_COLOR_TEMPERATURE.ByReference();
    Dxva2.INSTANCE.GetMonitorColorTemperature(hPhysicalMonitor, pctCurrentColorTemperature);
    System.out.println("Current Temp: " + pctCurrentColorTemperature.getValue());
    // Capabilities string
    DWORDByReference pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
    Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);
    DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue();
    LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue()));
    Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
    System.out.println("Cap-String:" + new String(pszASCIICapabilitiesString.getPointer().getString(0)));
    // Position
    MC_POSITION_TYPE ptPositionType = MC_POSITION_TYPE.MC_HORIZONTAL_POSITION;
    DWORDByReference pdwMinimumPosition = new DWORDByReference();
    DWORDByReference pdwCurrentPosition = new DWORDByReference();
    DWORDByReference pdwMaximumPosition = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorDisplayAreaPosition(hPhysicalMonitor, ptPositionType, pdwMinimumPosition, pdwCurrentPosition, pdwMaximumPosition);
    System.out.println("Position (horz) Min: " + pdwMinimumPosition.getValue());
    System.out.println("Position (horz) Current: " + pdwCurrentPosition.getValue());
    System.out.println("Position (horz) Max: " + pdwMaximumPosition.getValue());
    // Size
    MC_SIZE_TYPE ptSizeType = MC_SIZE_TYPE.MC_WIDTH;
    DWORDByReference pdwMinimumSize = new DWORDByReference();
    DWORDByReference pdwCurrentSize = new DWORDByReference();
    DWORDByReference pdwMaximumSize = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorDisplayAreaSize(hPhysicalMonitor, ptSizeType, pdwMinimumSize, pdwCurrentSize, pdwMaximumSize);
    System.out.println("Width Min: " + pdwMinimumSize.getValue());
    System.out.println("Width Current: " + pdwCurrentSize.getValue());
    System.out.println("Width Max: " + pdwMaximumSize.getValue());
    // Gain
    MC_GAIN_TYPE ptGainType = MC_GAIN_TYPE.MC_RED_GAIN;
    DWORDByReference pdwMinimumGain = new DWORDByReference();
    DWORDByReference pdwCurrentGain = new DWORDByReference();
    DWORDByReference pdwMaximumGain = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorRedGreenOrBlueGain(hPhysicalMonitor, ptGainType, pdwMinimumGain, pdwCurrentGain, pdwMaximumGain);
    System.out.println("Red Gain Min: " + pdwMinimumSize.getValue());
    System.out.println("Red Gain Current: " + pdwCurrentSize.getValue());
    System.out.println("Red Gain Max: " + pdwMaximumSize.getValue());
    // Drive
    MC_DRIVE_TYPE ptDriveType = MC_DRIVE_TYPE.MC_RED_DRIVE;
    DWORDByReference pdwMinimumDrive = new DWORDByReference();
    DWORDByReference pdwCurrentDrive = new DWORDByReference();
    DWORDByReference pdwMaximumDrive = new DWORDByReference();
    Dxva2.INSTANCE.GetMonitorRedGreenOrBlueDrive(hPhysicalMonitor, ptDriveType, pdwMinimumDrive, pdwCurrentDrive, pdwMaximumDrive);
    System.out.println("Red Drive Min: " + pdwMinimumSize.getValue());
    System.out.println("Red Drive Current: " + pdwCurrentSize.getValue());
    System.out.println("Red Drive Max: " + pdwMaximumSize.getValue());
    // Timing Report
    MC_TIMING_REPORT pmtrMonitorTimingReport = new MC_TIMING_REPORT();
    Dxva2.INSTANCE.GetTimingReport(hPhysicalMonitor, pmtrMonitorTimingReport);
    System.out.println("HorizontalFrequencyInHZ " + pmtrMonitorTimingReport.dwHorizontalFrequencyInHZ);
    System.out.println("VerticalFrequencyInHZ " + pmtrMonitorTimingReport.dwVerticalFrequencyInHZ);
    System.out.println("--------------------------------------");
}
Also used : HighLevelMonitorConfigurationAPI(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) MC_GAIN_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_GAIN_TYPE) Memory(com.sun.jna.Memory) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) DWORDByReference(com.sun.jna.platform.win32.WinDef.DWORDByReference) MC_SIZE_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_SIZE_TYPE) MC_DISPLAY_TECHNOLOGY_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DISPLAY_TECHNOLOGY_TYPE) MC_POSITION_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_POSITION_TYPE) MC_COLOR_TEMPERATURE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_COLOR_TEMPERATURE) MC_TIMING_REPORT(com.sun.jna.platform.win32.LowLevelMonitorConfigurationAPI.MC_TIMING_REPORT) LPSTR(com.sun.jna.platform.win32.WTypes.LPSTR) MC_DRIVE_TYPE(com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DRIVE_TYPE)

Aggregations

DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)34 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)12 DWORD (com.sun.jna.platform.win32.WinDef.DWORD)11 Test (org.junit.Test)8 Memory (com.sun.jna.Memory)6 GENERIC_MAPPING (com.sun.jna.platform.win32.WinNT.GENERIC_MAPPING)6 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)6 DdeCallback (com.sun.jna.platform.win32.Ddeml.DdeCallback)3 HDDEDATA (com.sun.jna.platform.win32.Ddeml.HDDEDATA)3 HSZ (com.sun.jna.platform.win32.Ddeml.HSZ)3 BSTRByReference (com.sun.jna.platform.win32.WTypes.BSTRByReference)3 PVOID (com.sun.jna.platform.win32.WinDef.PVOID)3 HANDLEByReference (com.sun.jna.platform.win32.WinNT.HANDLEByReference)3 Pointer (com.sun.jna.Pointer)2 IID (com.sun.jna.platform.win32.Guid.IID)2 REFIID (com.sun.jna.platform.win32.Guid.REFIID)2 MC_DRIVE_TYPE (com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_DRIVE_TYPE)2 MC_GAIN_TYPE (com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_GAIN_TYPE)2 MC_POSITION_TYPE (com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_POSITION_TYPE)2 MC_SIZE_TYPE (com.sun.jna.platform.win32.HighLevelMonitorConfigurationAPI.MC_SIZE_TYPE)2