use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class Advapi32Test method testDecryptFile.
public void testDecryptFile() throws Exception {
// create an encrypted file
File file = createTempFile();
String lpFileName = file.getAbsolutePath();
assertTrue(Advapi32.INSTANCE.EncryptFile(lpFileName));
// decrypt a read only file
file.setWritable(false);
assertFalse(Advapi32.INSTANCE.DecryptFile(lpFileName, new DWORD(0)));
assertEquals(WinError.ERROR_FILE_READ_ONLY, Kernel32.INSTANCE.GetLastError());
// decrypt
file.setWritable(true);
assertTrue(Advapi32.INSTANCE.DecryptFile(lpFileName, new DWORD(0)));
file.delete();
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class RunningObjectTable_Test method IsRunning.
@Test
public void IsRunning() {
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.IsRunning(pmkObjectName);
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class RunningObjectTable_Test method EnumRunning.
@Test
public void EnumRunning() {
PointerByReference pprot = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new DWORD(0), pprot);
COMUtils.checkRC(hr);
IRunningObjectTable rot = new RunningObjectTable(pprot.getValue());
PointerByReference ppenumMoniker = new PointerByReference();
hr = rot.EnumRunning(ppenumMoniker);
COMUtils.checkRC(hr);
assertNotNull(ppenumMoniker.getValue());
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class EnumMoniker_Test method Skip.
@Test
public void Skip() {
// GetRunningObjectTable
PointerByReference pprot = new PointerByReference();
HRESULT hr = Ole32.INSTANCE.GetRunningObjectTable(new DWORD(0), pprot);
COMUtils.checkRC(hr);
IRunningObjectTable rot = new RunningObjectTable(pprot.getValue());
// EnumRunning
PointerByReference ppenumMoniker = new PointerByReference();
hr = rot.EnumRunning(ppenumMoniker);
COMUtils.checkRC(hr);
IEnumMoniker iterator = new EnumMoniker(ppenumMoniker.getValue());
// Reset
hr = iterator.Reset();
COMUtils.checkRC(hr);
// Next
PointerByReference rgelt1 = new PointerByReference();
ULONGByReference pceltFetched1 = new ULONGByReference();
hr = iterator.Next(new ULONG(1), rgelt1, pceltFetched1);
COMUtils.checkRC(hr);
// Reset
hr = iterator.Reset();
COMUtils.checkRC(hr);
// Skip
hr = iterator.Skip(new ULONG(1));
COMUtils.checkRC(hr);
// Next
PointerByReference rgelt2 = new PointerByReference();
ULONGByReference pceltFetched2 = new ULONGByReference();
hr = iterator.Next(new ULONG(1), rgelt2, pceltFetched2);
COMUtils.checkRC(hr);
assertNotEquals(rgelt1.getValue(), rgelt2.getValue());
}
use of com.sun.jna.platform.win32.WinDef.DWORD in project jna by java-native-access.
the class RunningObjectTable_Test method GetTimeOfLastChange.
@Test
public void GetTimeOfLastChange() {
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,
// so we can't register an object, and hence can't get a registration key
//rot.GetTimeOfLastChange(pmkObjectName, pfiletime);
}
Aggregations