Search in sources :

Example 16 with GUID

use of com.sun.jna.platform.win32.Guid.GUID in project jna by java-native-access.

the class Ole32Util method generateGUID.

/**
	 * Generate a new GUID.
	 * @return
	 *  New GUID.
	 */
public static GUID generateGUID() {
    GUID pguid = new GUID();
    HRESULT hr = Ole32.INSTANCE.CoCreateGuid(pguid);
    if (!hr.equals(W32Errors.S_OK)) {
        throw new RuntimeException(hr.toString());
    }
    return pguid;
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) GUID(com.sun.jna.platform.win32.Guid.GUID)

Example 17 with GUID

use of com.sun.jna.platform.win32.Guid.GUID in project jna by java-native-access.

the class ITypeLibTest method testGetTypeInfoOfGuid.

public void testGetTypeInfoOfGuid() {
    ITypeLib shellTypeLib = loadShellTypeLib();
    // GUID for dispinterface IFolderViewOC
    GUID iFolderViewOC = new GUID("{9BA05970-F6A8-11CF-A442-00A0C90A8F39}");
    PointerByReference pbr = new PointerByReference();
    HRESULT hr = shellTypeLib.GetTypeInfoOfGuid(iFolderViewOC, pbr);
    assertTrue(COMUtils.SUCCEEDED(hr));
}
Also used : HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) GUID(com.sun.jna.platform.win32.Guid.GUID)

Example 18 with GUID

use of com.sun.jna.platform.win32.Guid.GUID in project jna by java-native-access.

the class GuidTest method testGUIDFromBinary2.

/**
	 * Loads a GUID from a byte array via the constructor and verify that the
	 * guid returned has the expected values in each byte.
	 */
public void testGUIDFromBinary2() {
    byte[] sourceGuidBArr = new byte[] { (byte) 0xA5, (byte) 0xDC, (byte) 0xBF, (byte) 0x10, (byte) 0x65, (byte) 0x30, (byte) 0x11, (byte) 0xD2, (byte) 0x90, (byte) 0x1F, (byte) 0x00, (byte) 0xC0, (byte) 0x4F, (byte) 0xB9, (byte) 0x51, (byte) 0xED };
    // test loading via constructor
    GUID targetGuid = new GUID(sourceGuidBArr);
    byte[] targetGuidBArr = targetGuid.toByteArray();
    for (int i = 0; i < sourceGuidBArr.length; i++) {
        assertEquals(targetGuidBArr[i], sourceGuidBArr[i]);
    }
}
Also used : GUID(com.sun.jna.platform.win32.Guid.GUID)

Example 19 with GUID

use of com.sun.jna.platform.win32.Guid.GUID in project jna by java-native-access.

the class GuidTest method testGuidByValue.

/**
	 * Tests the GUID.ByValue.
	 */
public void testGuidByValue() {
    GUID newGuid = GUID.newGuid();
    String guidString = newGuid.toGuidString();
    GUID.ByValue bv = new GUID.ByValue(newGuid);
    String guidBV = bv.toGuidString();
    assertEquals(guidBV, guidString);
}
Also used : GUID(com.sun.jna.platform.win32.Guid.GUID)

Example 20 with GUID

use of com.sun.jna.platform.win32.Guid.GUID in project jna by java-native-access.

the class GuidTest method testNewGuid.

/**
	 * Tests the new guid with the build-in function coming with windows.
	 */
public void testNewGuid() {
    GUID newGuid = GUID.newGuid();
    String guidString = newGuid.toGuidString();
    GUID guidFromString = Ole32Util.getGUIDFromString(guidString);
    assertEquals(guidFromString.toGuidString(), guidString);
}
Also used : GUID(com.sun.jna.platform.win32.Guid.GUID)

Aggregations

GUID (com.sun.jna.platform.win32.Guid.GUID)20 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)10 PointerByReference (com.sun.jna.ptr.PointerByReference)7 COMException (com.sun.jna.platform.win32.COM.COMException)3 Dispatch (com.sun.jna.platform.win32.COM.Dispatch)2 IDispatch (com.sun.jna.platform.win32.COM.IDispatch)2 ComObject (com.sun.jna.platform.win32.COM.util.annotation.ComObject)2 WinNT (com.sun.jna.platform.win32.WinNT)2 HANDLE (com.sun.jna.platform.win32.WinNT.HANDLE)2 Memory (com.sun.jna.Memory)1 CLSID (com.sun.jna.platform.win32.Guid.CLSID)1 REFIID (com.sun.jna.platform.win32.Guid.REFIID)1 DomainController (com.sun.jna.platform.win32.Netapi32Util.DomainController)1 DomainTrust (com.sun.jna.platform.win32.Netapi32Util.DomainTrust)1 EVT_HANDLE (com.sun.jna.platform.win32.Winevt.EVT_HANDLE)1 IntByReference (com.sun.jna.ptr.IntByReference)1 File (java.io.File)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1