use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class PdhTest method testQueryOneCounter.
@Test
public void testQueryOneCounter() {
PDH_COUNTER_PATH_ELEMENTS elems = new PDH_COUNTER_PATH_ELEMENTS();
elems.szObjectName = "Processor";
elems.szInstanceName = "_Total";
elems.szCounterName = "% Processor Time";
String counterName = makeCounterPath(pdh, elems);
HANDLEByReference ref = new HANDLEByReference();
assertErrorSuccess("PdhOpenQuery", pdh.PdhOpenQuery(null, null, ref), true);
HANDLE hQuery = ref.getValue();
try {
ref.setValue(null);
assertErrorSuccess("PdhAddEnglishCounter", pdh.PdhAddEnglishCounter(hQuery, counterName, null, ref), true);
HANDLE hCounter = ref.getValue();
try {
assertErrorSuccess("PdhCollectQueryData", pdh.PdhCollectQueryData(hQuery), true);
DWORDByReference lpdwType = new DWORDByReference();
PDH_RAW_COUNTER rawCounter = new PDH_RAW_COUNTER();
assertErrorSuccess("PdhGetRawCounterValue", pdh.PdhGetRawCounterValue(hCounter, lpdwType, rawCounter), true);
assertEquals("Bad counter data status", PdhMsg.PDH_CSTATUS_VALID_DATA, rawCounter.CStatus);
DWORD dwType = lpdwType.getValue();
int typeValue = dwType.intValue();
// see https://technet.microsoft.com/en-us/library/cc786359(v=ws.10).aspx
assertEquals("Mismatched counter type", WinPerf.PERF_100NSEC_TIMER_INV, typeValue);
showRawCounterData(System.out, counterName, rawCounter);
} finally {
assertErrorSuccess("PdhRemoveCounter", pdh.PdhRemoveCounter(hCounter), true);
}
} finally {
assertErrorSuccess("PdhCloseQuery", pdh.PdhCloseQuery(hQuery), true);
}
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class PdhTest method makeCounterPath.
private static String makeCounterPath(Pdh pdh, PDH_COUNTER_PATH_ELEMENTS pathElements) {
DWORDByReference pcchBufferSize = new DWORDByReference();
int status = pdh.PdhMakeCounterPath(pathElements, null, pcchBufferSize, 0);
assertEquals("Unexpected status code: 0x" + Integer.toHexString(status), PdhMsg.PDH_MORE_DATA, status);
DWORD bufSize = pcchBufferSize.getValue();
int numChars = bufSize.intValue();
assertTrue("Bad required buffer size: " + numChars, numChars > 0);
char[] szFullPathBuffer = new char[numChars + 1];
pcchBufferSize.setValue(new DWORD(szFullPathBuffer.length));
assertErrorSuccess("PdhMakeCounterPath", pdh.PdhMakeCounterPath(pathElements, szFullPathBuffer, pcchBufferSize, 0), true);
return Native.toString(szFullPathBuffer);
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class Shell32Test method newAppBar.
private void newAppBar() {
APPBARDATA data = new APPBARDATA.ByReference();
data.cbSize.setValue(data.size());
data.uCallbackMessage.setValue(WM_USER + 1);
UINT_PTR result = Shell32.INSTANCE.SHAppBarMessage(new DWORD(ShellAPI.ABM_NEW), data);
assertNotNull(result);
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class Shell32Test method testResizeDesktopFromTop.
public void testResizeDesktopFromTop() throws InterruptedException {
newAppBar();
APPBARDATA data = new APPBARDATA.ByReference();
data.uEdge.setValue(ShellAPI.ABE_TOP);
data.rc.top = 0;
data.rc.left = 0;
data.rc.bottom = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN) - RESIZE_DELTA;
data.rc.right = User32.INSTANCE.GetSystemMetrics(User32.SM_CXFULLSCREEN);
queryPos(data);
UINT_PTR h = Shell32.INSTANCE.SHAppBarMessage(new DWORD(ShellAPI.ABM_SETPOS), data);
assertNotNull(h);
assertTrue(h.intValue() >= 0);
removeAppBar();
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class User32Test method testAdjustWindowRect.
@Test
public final void testAdjustWindowRect() {
RECT lpRect = new RECT();
lpRect.left = 100;
lpRect.top = 200;
lpRect.bottom = 300;
lpRect.right = 500;
assertTrue(User32.INSTANCE.AdjustWindowRect(lpRect, new DWORD(WinUser.WS_THICKFRAME), new BOOL(1)).booleanValue());
assertTrue(lpRect.left < 100);
assertTrue(lpRect.top < 200);
assertTrue(lpRect.bottom > 300);
assertTrue(lpRect.right > 500);
}
Aggregations