Search in sources :

Example 6 with DWORD

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();
}
Also used : DWORD(com.sun.jna.platform.win32.WinDef.DWORD) File(java.io.File)

Example 7 with DWORD

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);
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) Test(org.junit.Test)

Example 8 with DWORD

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());
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) Test(org.junit.Test)

Example 9 with DWORD

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());
}
Also used : ULONG(com.sun.jna.platform.win32.WinDef.ULONG) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) ULONGByReference(com.sun.jna.platform.win32.WinDef.ULONGByReference) Test(org.junit.Test)

Example 10 with DWORD

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);
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) DWORD(com.sun.jna.platform.win32.WinDef.DWORD) Test(org.junit.Test)

Aggregations

DWORD (com.sun.jna.platform.win32.WinDef.DWORD)56 PointerByReference (com.sun.jna.ptr.PointerByReference)23 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)17 File (java.io.File)17 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)16 Test (org.junit.Test)15 DWORDByReference (com.sun.jna.platform.win32.WinDef.DWORDByReference)11 Memory (com.sun.jna.Memory)9 ULONG (com.sun.jna.platform.win32.WinDef.ULONG)9 ULONGByReference (com.sun.jna.platform.win32.WinDef.ULONGByReference)7 HANDLEByReference (com.sun.jna.platform.win32.WinNT.HANDLEByReference)7 GENERIC_MAPPING (com.sun.jna.platform.win32.WinNT.GENERIC_MAPPING)6 UINT_PTR (com.sun.jna.platform.win32.WinDef.UINT_PTR)5 TOKEN_PRIVILEGES (com.sun.jna.platform.win32.WinNT.TOKEN_PRIVILEGES)5 IntByReference (com.sun.jna.ptr.IntByReference)5 APPBARDATA (com.sun.jna.platform.win32.ShellAPI.APPBARDATA)4 WinNT (com.sun.jna.platform.win32.WinNT)4 Pointer (com.sun.jna.Pointer)3 SC_HANDLE (com.sun.jna.platform.win32.Winsvc.SC_HANDLE)3 BufferedWriter (java.io.BufferedWriter)3