Re: Invoking Application based on UID.

Paul Schauble <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <[email protected]>
I may be a Java newbie, but I know COM.

Doesn't COMException contain the HRESULT of the failing operation?
What is it?

    ++PLS

-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]] On Behalf Of Christophe Bouhier (MC/ECM)
Sent: Tuesday, March 08, 2005 8:11 PM
To: [email protected]
Subject: [JAWIN] Invoking Application based on UID.

Hi,

I have been using jawin succesfully in my application, accessing COM through
the Dispatch interface. This easy to do, minding a well documented API (Like
iTunes).

Now I try to access COM through the GUID of an application, as retrieved
from the registry.
I have the feeling that I am close to the solution, but I think I am
overlooking something.

Specifically I query the Registry to retrieve a file extension's
'PersistentHandler'.
Here is the code below. I can create the extend Dispatch class named
"ipBrowser" but invoking a method on it throws a COMexception.

Can someone tell me what I am doing wrong?

        ///// GET A KEY METHOD

        public static String getStringValue(int area, String keyString,
String valueString) {
        int key;
        try {
                key = Registry.OpenKey(area,
                    keyString);
            String value = Registry.QueryStringValue(key, valueString);
            Registry.CloseKey(key);
            return value;
                return value;
        } catch (IOException e) {
            e.printStackTrace();
        } catch (COMException e) {
            e.printStackTrace();
        }


        ////////////////////////////////////////
        //  CREATE A
        ///////////////////////////////////////

        String id = ipRegistry.getStringValue(
                RegistryConstants.HKEY_LOCAL_MACHINE,
                "SOFTWARE\\Classes\\.htt\\PersistentHandler", "");
        try {
            Ole32.CoInitialize();
            ipBrowser browser = new ipBrowser(id);
                browser.invoke("Open","www.yahoo.com"); <<<-----------COM
EXCEPTION.
            Ole32.CoUninitialize();

        } catch (COMException e) {
            e.printStackTrace();
        }

        ///////////////////////////////////////////
        // EXTEND DISPATH TO register the GUID
        //////////////////////////////////////////
        public class ipBrowser extends DispatchPtr {

        public GUID DIID;

        public int iidToken;

        public ipBrowser(String guid) {
            DIID = new GUID(guid);
            iidToken = IdentityManager.registerProxy(DIID,
                    ipLaunchBrowser.class);
        }

        /**
         * @see org.jawin.IUnknown#getIIDToken()
         */
        public int getIIDToken() {
            return iidToken;
        }

    }

Thank / Christophe
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.