use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class Kernel32Test method testMoveFileEx.
public void testMoveFileEx() throws IOException {
File source = File.createTempFile("testMoveFileEx", "jna");
source.deleteOnExit();
File destination = File.createTempFile("testCopyFile", "jna");
destination.deleteOnExit();
Kernel32.INSTANCE.MoveFileEx(source.getCanonicalPath(), destination.getCanonicalPath(), new DWORD(WinBase.MOVEFILE_REPLACE_EXISTING));
assertTrue(destination.exists());
assertFalse(source.exists());
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class Dxva2Test method testCapabilitiesRequestAndCapabilitiesReply.
@Test
public void testCapabilitiesRequestAndCapabilitiesReply() {
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 pdwCapabilitiesStringLengthInCharacters = new DWORDByReference();
BOOL success = Dxva2.INSTANCE.GetCapabilitiesStringLength(hPhysicalMonitor, pdwCapabilitiesStringLengthInCharacters);
if (success.booleanValue()) {
// VirtualBox is known to report an empty string
DWORD capStrLen = pdwCapabilitiesStringLengthInCharacters.getValue();
LPSTR pszASCIICapabilitiesString = new LPSTR(new Memory(capStrLen.intValue()));
Dxva2.INSTANCE.CapabilitiesRequestAndCapabilitiesReply(hPhysicalMonitor, pszASCIICapabilitiesString, capStrLen);
} else {
System.err.println("GetCapabilitiesStringLength failed with errorcode: " + Kernel32.INSTANCE.GetLastError());
}
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class RunningObjectTable_Test method Register.
@Test
public void Register() {
PointerByReference pprot = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new DWORD(0), pprot);
COMUtils.checkRC(hr);
IRunningObjectTable rot = new RunningObjectTable(pprot.getValue());
//Can't yet be tested as IMoniker is not fully implemented
//rot.Register(grfFlags, punkObject, pmkObjectName, pdwRegister);
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class WinDefTest method testWordExtractionFromDword.
@Test
public void testWordExtractionFromDword() {
DWORD dword = new DWORD(0x12345678);
assertEquals(new WORD(0x5678), dword.getLow());
assertEquals(new WORD(0x1234), dword.getHigh());
DWORD dword2 = new DWORD(0xFFFFFFFF);
assertEquals(new WORD(0xFFFF), dword2.getLow());
assertEquals(new WORD(0xFFFF), dword2.getHigh());
DWORD dword3 = new DWORD(0x00000001);
assertEquals(new WORD(0x0001), dword3.getLow());
assertEquals(new WORD(0x0000), dword3.getHigh());
DWORD dword4 = new DWORD(0x00010000);
assertEquals(new WORD(0x0000), dword4.getLow());
assertEquals(new WORD(0x0001), dword4.getHigh());
DWORD dword5 = new DWORD(0x0000FFFF);
assertEquals(new WORD(0xFFFF), dword5.getLow());
assertEquals(new WORD(0x0000), dword5.getHigh());
DWORD dword6 = new DWORD(0xFFFF0000);
assertEquals(new WORD(0x0000), dword6.getLow());
assertEquals(new WORD(0xFFFF), dword6.getHigh());
}
use of com.sun.jna.platform.win32.WinDef.DWORD 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("--------------------------------------");
}
Aggregations