use of com.sun.jna.WString in project jna by java-native-access.
the class ITypeLibTest method loadShellTypeLib.
private ITypeLib loadShellTypeLib() {
CLSID.ByReference clsid = new CLSID.ByReference();
// get CLSID from string
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString(SHELL_CLSID), clsid);
assertTrue(COMUtils.SUCCEEDED(hr));
// get user default lcid
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
PointerByReference pShellTypeLib = new PointerByReference();
// load typelib
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, SHELL_MAJOR, SHELL_MINOR, lcid, pShellTypeLib);
assertTrue(COMUtils.SUCCEEDED(hr));
return new TypeLib(pShellTypeLib.getValue());
}
use of com.sun.jna.WString in project jna by java-native-access.
the class ComEventCallbacks_Test method before.
@Before
public void before() {
AbstractWin32TestSupport.killProcessByName("iexplore.exe");
try {
Thread.sleep(5 * 1000);
} catch (InterruptedException ex) {
}
HRESULT hr = Ole32.INSTANCE.CoInitializeEx(null, Ole32.COINIT_MULTITHREADED);
COMUtils.checkRC(hr);
// Create InternetExplorer object
ieApp = new PointerByReference();
hr = Ole32.INSTANCE.CoCreateInstance(CLSID_InternetExplorer, null, WTypes.CLSCTX_SERVER, IDispatch.IID_IDISPATCH, ieApp);
COMUtils.checkRC(hr);
ieDispatch = new Dispatch(ieApp.getValue());
ieDispatch.AddRef();
hr = ieDispatch.GetIDsOfNames(new REFIID(Guid.IID_NULL), new WString[] { new WString("Quit") }, 1, lcid, dispIdQuit);
COMUtils.checkRC(hr);
hr = ieDispatch.GetIDsOfNames(new REFIID(Guid.IID_NULL), new WString[] { new WString("Visible") }, 1, lcid, dispIdVisible);
COMUtils.checkRC(hr);
hr = ieDispatch.GetIDsOfNames(new REFIID(Guid.IID_NULL), new WString[] { new WString("Navigate") }, 1, lcid, dispIdNavigate);
COMUtils.checkRC(hr);
}
use of com.sun.jna.WString in project jna by java-native-access.
the class IDispatchTest method testGetIDsOfNames.
public void testGetIDsOfNames() {
Dispatch dispatch = this.createIDispatch();
WString[] ptName = new WString[] { new WString("Application") };
DISPIDByReference pdispID = new DISPIDByReference();
HRESULT hr = dispatch.GetIDsOfNames(new REFIID(Guid.IID_NULL), ptName, 1, LOCALE_SYSTEM_DEFAULT, pdispID);
COMUtils.checkRC(hr);
assertEquals(0, hr.intValue());
}
use of com.sun.jna.WString in project jna by java-native-access.
the class Shell32Test method testCurrentProcessExplicitAppUserModelID.
public void testCurrentProcessExplicitAppUserModelID() {
String appUserModelID = "com.sun.jna.platform.win32.Shell32Test";
HRESULT r1 = Shell32.INSTANCE.SetCurrentProcessExplicitAppUserModelID(new WString(appUserModelID));
assertEquals(WinError.S_OK, r1);
PointerByReference ppszAppID = new PointerByReference();
HRESULT r2 = Shell32.INSTANCE.GetCurrentProcessExplicitAppUserModelID(ppszAppID);
assertEquals(WinError.S_OK, r2);
assertEquals(appUserModelID, ppszAppID.getValue().getWideString(0));
Ole32.INSTANCE.CoTaskMemFree(ppszAppID.getValue());
}
use of com.sun.jna.WString in project jna by java-native-access.
the class OleAutoTest method testLoadRegTypeLib.
public void testLoadRegTypeLib() {
CLSID.ByReference clsid = new CLSID.ByReference();
// get CLSID from string, Microsoft Scripting Engine
HRESULT hr = Ole32.INSTANCE.CLSIDFromString(new WString("{420B2830-E718-11CF-893D-00A0C9054228}"), clsid);
COMUtils.checkRC(hr);
assertEquals(0, hr.intValue());
// get user default lcid
LCID lcid = Kernel32.INSTANCE.GetUserDefaultLCID();
PointerByReference pWordTypeLib = new PointerByReference();
// get typelib version 1.0
hr = OleAuto.INSTANCE.LoadRegTypeLib(clsid, 1, 0, lcid, pWordTypeLib);
COMUtils.checkRC(hr);
assertEquals(0, hr.intValue());
}
Aggregations