use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.
the class Advapi32Test method testFileEncryptionStatus.
public void testFileEncryptionStatus() throws Exception {
DWORDByReference lpStatus = new DWORDByReference();
// create a temp file
File file = createTempFile();
String lpFileName = file.getAbsolutePath();
// unencrypted file
assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(lpFileName, lpStatus));
assertEquals(FILE_ENCRYPTABLE, lpStatus.getValue().intValue());
// read only file
file.setWritable(false);
assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(lpFileName, lpStatus));
assertEquals(FILE_READ_ONLY, lpStatus.getValue().intValue());
// encrypted file
file.setWritable(true);
assertTrue(Advapi32.INSTANCE.EncryptFile(lpFileName));
assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(lpFileName, lpStatus));
assertEquals(FILE_IS_ENCRYPTED, lpStatus.getValue().intValue());
file.delete();
}
use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.
the class Advapi32Test method testMapGenericAllMask.
public void testMapGenericAllMask() {
final GENERIC_MAPPING mapping = new GENERIC_MAPPING();
mapping.genericRead = new DWORD(FILE_GENERIC_READ);
mapping.genericWrite = new DWORD(FILE_GENERIC_WRITE);
mapping.genericExecute = new DWORD(FILE_GENERIC_EXECUTE);
mapping.genericAll = new DWORD(FILE_ALL_ACCESS);
final DWORDByReference rights = new DWORDByReference(new DWORD(GENERIC_ALL));
Advapi32.INSTANCE.MapGenericMask(rights, mapping);
assertEquals(FILE_ALL_ACCESS, rights.getValue().intValue());
assertTrue(GENERIC_ALL != (rights.getValue().intValue() & GENERIC_ALL));
}
use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.
the class Advapi32Test method testEncryptionDisable.
public void testEncryptionDisable() throws Exception {
DWORDByReference lpStatus = new DWORDByReference();
// create a temp dir
String filePath = System.getProperty("java.io.tmpdir") + File.separator + System.nanoTime();
String DirPath = filePath;
File dir = new File(filePath);
dir.mkdir();
// check status
assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(DirPath, lpStatus));
assertEquals(FILE_ENCRYPTABLE, lpStatus.getValue().intValue());
// disable encryption
assertTrue(Advapi32.INSTANCE.EncryptionDisable(DirPath, true));
assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(DirPath, lpStatus));
assertEquals(FILE_DIR_DISALOWED, lpStatus.getValue().intValue());
// enable encryption
assertTrue(Advapi32.INSTANCE.EncryptionDisable(DirPath, false));
assertTrue(Advapi32.INSTANCE.FileEncryptionStatus(DirPath, lpStatus));
assertEquals(FILE_ENCRYPTABLE, lpStatus.getValue().intValue());
// clean up
for (File file : dir.listFiles()) {
file.delete();
}
dir.delete();
}
use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.
the class ITypeInfoTest method testGetDocumentation.
@Test
public void testGetDocumentation() {
ITypeInfo[] typeInfos = getTypeInfos();
MEMBERID memid = new MEMBERID(0);
BSTRByReference pBstrName = new BSTRByReference();
BSTRByReference pBstrDocString = new BSTRByReference();
DWORDByReference pdwHelpContext = new DWORDByReference();
BSTRByReference pBstrHelpFile = new BSTRByReference();
for (ITypeInfo typeInfo : typeInfos) {
HRESULT hr = typeInfo.GetDocumentation(memid, pBstrName, pBstrDocString, pdwHelpContext, pBstrHelpFile);
if (COMUtils.SUCCEEDED(hr)) {
//System.out.println("pBstrHelpFile: " + pBstrHelpFile.getValue());
return;
}
}
throw new RuntimeException("Didn't find documentation in any of the type infos");
}
use of com.sun.jna.platform.win32.WinDef.DWORDByReference in project jna by java-native-access.
the class User32Test method testSendMessageTimeout.
@Test
public void testSendMessageTimeout() {
DesktopWindow explorerProc = getWindowByProcessPath("explorer.exe");
assertNotNull(explorerProc);
final DWORDByReference hIconNumber = new DWORDByReference();
LRESULT result = User32.INSTANCE.SendMessageTimeout(explorerProc.getHWND(), WinUser.WM_GETICON, new WPARAM(WinUser.ICON_BIG), new LPARAM(0), WinUser.SMTO_ABORTIFHUNG, 500, hIconNumber);
assertNotEquals(0, result);
}
Aggregations