Search in sources :

Example 1 with WString

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());
}
Also used : WString(com.sun.jna.WString) LCID(com.sun.jna.platform.win32.WinDef.LCID) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) CLSID(com.sun.jna.platform.win32.Guid.CLSID) PointerByReference(com.sun.jna.ptr.PointerByReference) PointerByReference(com.sun.jna.ptr.PointerByReference) USHORTByReference(com.sun.jna.platform.win32.WinDef.USHORTByReference)

Example 2 with WString

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);
}
Also used : WString(com.sun.jna.WString) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) PointerByReference(com.sun.jna.ptr.PointerByReference) REFIID(com.sun.jna.platform.win32.Guid.REFIID) Before(org.junit.Before)

Example 3 with WString

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());
}
Also used : WString(com.sun.jna.WString) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) DISPIDByReference(com.sun.jna.platform.win32.OaIdl.DISPIDByReference) REFIID(com.sun.jna.platform.win32.Guid.REFIID)

Example 4 with WString

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

Example 5 with WString

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());
}
Also used : WString(com.sun.jna.WString) LCID(com.sun.jna.platform.win32.WinDef.LCID) HRESULT(com.sun.jna.platform.win32.WinNT.HRESULT) CLSID(com.sun.jna.platform.win32.Guid.CLSID) PointerByReference(com.sun.jna.ptr.PointerByReference) PointerByReference(com.sun.jna.ptr.PointerByReference)

Aggregations

WString (com.sun.jna.WString)12 HRESULT (com.sun.jna.platform.win32.WinNT.HRESULT)7 REFIID (com.sun.jna.platform.win32.Guid.REFIID)4 PointerByReference (com.sun.jna.ptr.PointerByReference)4 DISPIDByReference (com.sun.jna.platform.win32.OaIdl.DISPIDByReference)3 CLSID (com.sun.jna.platform.win32.Guid.CLSID)2 LCID (com.sun.jna.platform.win32.WinDef.LCID)2 StringArray (com.sun.jna.StringArray)1 COMException (com.sun.jna.platform.win32.COM.COMException)1 USHORTByReference (com.sun.jna.platform.win32.WinDef.USHORTByReference)1 IntByReference (com.sun.jna.ptr.IntByReference)1 LongByReference (com.sun.jna.ptr.LongByReference)1 SplashScreen (java.awt.SplashScreen)1 File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 JFrame (javax.swing.JFrame)1 Shell32Ex (org.jumpmind.symmetric.wrapper.jna.Shell32Ex)1 Before (org.junit.Before)1