Re: Invoking Application based on UID.

"Christophe Bouhier (MC/ECM)" <[email protected]>
Newsgroups gmane.comp.windows.devel.jawin
Message-ID <6BA346EB59B2D51194E200508B046FE107DFE93E@emyklnt151.ao.ericsson.se>
Thanks, can you point to some documentation do ShellExecute API?
Is some .dll functions I can invoke ? (Or as you mention using JNI?)

Cheers / Christophe

-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]]
Sent: Wednesday, March 09, 2005 3:16 PM
To: [email protected]
Subject: Re: [JAWIN] Invoking Application based on UID.


One normally does this with the ShellExecute API, which is not COM callable.
Since there is no requirement that web browsers expose COM objects, and not
all do, there is no standard way of doing this with COM.

Is there a Java interface to ShellExecute? It wouldn't be hard to write one
with the native interface.

Now if you're willing to use Internet Explorer all the time, you can do that
with COM.

    ++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 10:28 PM
To: [email protected]
Subject: Re: [JAWIN] Invoking Application based on UID.

Hi,

I am not surprise you don't get it, as I don't understand myself what I am
doing ;-)

The objective is to get the default web browser from the registry and launch
it.
My thinking is that I should look at file extensions like .htt .htm or html

I have no specific reason to use the PersistentHandler. It looked like a
CLSid in the registry so I tried to invoke it, but I am sure I am on the
wrong path here.

I now figured out that the [.extension] actually contains the progid , which
I can invoke and works. I tried it out for .doc returning "Word.Document.8"
which I can access.
For the .htm I get progid "htmlfile", I tried to create a Dispatch point on
this, but it doesn't launch internet explorer.

Am I getting closer?
Cheers / Christophe



-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]]
Sent: Wednesday, March 09, 2005 1:08 PM
To: [email protected]
Subject: Re: [JAWIN] Invoking Application based on UID.


I don't get it. Why do you want the PersistentHandler for a the file? Are
you writing your own version of the indexing service?

What exactly are you trying to accomplish? Maybe I can give better answers
with a higher level description of the problem.

The most likely reason for your exception is that the Ifilter interface that
GUID represents isn't a descendant of IDispatch.  It's a custom interface.

    ++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 9:24 PM
To: [email protected]
Subject: Re: [JAWIN] Invoking Application based on UID.

Hi,

Objective: Detect the default browser and open it with some URL.
Approach: Read all I can grab and try stuff out..
Efficiency: Not very good, trial and error...Struggling to understand COM,
back to the basics...

I tried something else with more success. (This code works).
        try {
            Ole32.CoInitialize();
                GUID guid = new
GUID("{91493441-5A91-11CF-8700-00AA0060263B}");
            DispatchPtr powerpoint = new DispatchPtr(guid);
              powerpoint.put("Visible", true);
            Ole32.CoUninitialize();

        } catch (COMException e) {
            e.printStackTrace();
            System.out.println(e.getMessage());
        }

So OK, I can use the Clsid instead of the ProgID to access COM, but the
thing is I don't know the CLsid, so I look it up in the registry.

HKEY_LOCAL_MACHINE\SOFTWARE\\Classes\\.htt\\PersistentHandler

PersistentHandler key return an ID which returns the message:

- 80040154: Class not registered

So I guess I am trying to invoke on a non-valid Clsid.
I am really confused on how the PersistenHandler key relates to the valid
application CLsid...

It would be great if someone can enlight me here....


Cheers / Christophe




-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]]
Sent: Wednesday, March 09, 2005 12:01 PM
To: [email protected]
Subject: Re: [JAWIN] Invoking Application based on UID.


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.