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;
}
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));
}
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]);
}
}
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);
}
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);
}
Aggregations