Board index » delphi » ShellExecute

ShellExecute

I would like to open an "html" page from an application with the default
browser.
If there is already an "html" page opened in the default browser,
I would like to open a new browser window for the newly requested page.

I cannot achieve this - any ideas?
Here is my present code:

ShellExecute(Application.Handle,
                    Pchar(Nil),
                    Pointer(Address),
                    Pchar(Nil),
                    Pchar(Nil),
                    SW_SHOWNORMAL)

 

Re:ShellExecute


hi,
i might be terribly wrong, but doesn't that sound like making a DDE connection to the program and sending it a command for opening a new page? I have done it like that, but it should have the browser name and path specified.
dimo

Quote
"Robin Twiggs" <rstwi...@global.co.za> wrote:
>I would like to open an "html" page from an application with the default
>browser.
>If there is already an "html" page opened in the default browser,
>I would like to open a new browser window for the newly requested page.

>I cannot achieve this - any ideas?
>Here is my present code:

>ShellExecute(Application.Handle,
>                    Pchar(Nil),
>                    Pointer(Address),
>                    Pchar(Nil),
>                    Pchar(Nil),
>                    SW_SHOWNORMAL)

Re:ShellExecute


You can use DDE to do this with IE, Nav and Opera + others I'm sure.  IE
also supports OLE as Application.InternetExplorer which can also achieve
this.

Bryan Ashby

Quote
"Robin Twiggs" <rstwi...@global.co.za> wrote in message

news:3bbc5ebf_1@dnews...
Quote
> I would like to open an "html" page from an application with the default
> browser.
> If there is already an "html" page opened in the default browser,
> I would like to open a new browser window for the newly requested page.

> I cannot achieve this - any ideas?
> Here is my present code:

> ShellExecute(Application.Handle,
>                     Pchar(Nil),
>                     Pointer(Address),
>                     Pchar(Nil),
>                     Pchar(Nil),
>                     SW_SHOWNORMAL)

Re:ShellExecute


ShellExecute( Handle, 'open', 'http://www.site.com/', nil, nil,
SW_SHOWNORMAL );

or

ShellExecute( Handle, 'open', website, nil, nil, SW_SHOWNORMAL );
    if website is pchar or array of char

or

ShellExecute( Handle, 'open', PChar(website), nil, nil, SW_SHOWNORMAL );
    if website is string

Lucian

Re:ShellExecute


forgot this "Handle" is Application.Handle or some Form.Handle

Lucian

Re:ShellExecute


Quote
> ShellExecute( Handle, 'open', 'http://www.site.com/', nil, nil,
> SW_SHOWNORMAL );

> or

> ShellExecute( Handle, 'open', website, nil, nil, SW_SHOWNORMAL );
>     if website is pchar or array of char

> or

> ShellExecute( Handle, 'open', PChar(website), nil, nil, SW_SHOWNORMAL );
>     if website is string

Lucian,
 That is exactly what he is currently doing. He now wants to open the
URL in a NEW browser window.

I'm working on a sloution now that uses this as the URL:

'javascript:window.open('''+URL+''')';

if my url is http://www.borland.com,

javascript:window.open('http://www'borland.com')

will open borland.com in a new window. The only problem
I see with that is that an extra window opens with the title
"javascript:window.open('http://www'borland.com')"

Re:ShellExecute


oops, missed the "new" thingies
Sorry,
Quote
>  That is exactly what he is currently doing. He now wants to open the
> URL in a NEW browser window.

Re:ShellExecute


Eddie:

Great idea, but I can''t get it to work on D3 with Netscape 4.7 as the
default browser. Nothing happens at all. Any ideas?

Presumably this approach would NOT work if the user had JavaScript
disabled in their browser?

Here's my code...

procedure ShowWebPage (URL : string);
begin
  URL:= 'javascript:window.open(''' + URL + ''')';
  ShellExecute(0, 'open', pChar(URL), '', '', SW_NORMAL);
end;

Quote
Eddie Shipman wrote:

> > ShellExecute( Handle, 'open', 'http://www.site.com/', nil, nil,
> > SW_SHOWNORMAL );

> > or

> > ShellExecute( Handle, 'open', website, nil, nil, SW_SHOWNORMAL );
> >     if website is pchar or array of char

> > or

> > ShellExecute( Handle, 'open', PChar(website), nil, nil, SW_SHOWNORMAL );
> >     if website is string

> Lucian,
>  That is exactly what he is currently doing. He now wants to open the
> URL in a NEW browser window.

> I'm working on a sloution now that uses this as the URL:

> 'javascript:window.open('''+URL+''')';

> if my url is http://www.borland.com,

> javascript:window.open('http://www'borland.com')

> will open borland.com in a new window. The only problem
> I see with that is that an extra window opens with the title
> "javascript:window.open('http://www'borland.com')"

--
============================================
Work with RTF files? Visit the new group at:
http://groups.yahoo.com/group/richtextformat
============================================

Re:ShellExecute


The action for opening in a new window is called opennew. You might have to
look up ShellExecuteEX and ID_Item_List if ShellExecute does not work.

Plus : PChar(nil) is quite indefinite to me. You should:

ShellExecute(0,nil,PChar(Path),'','',sw_Show), as the '' (empty string)
means different things then NIL. There was a discussion not so log ago about
this.

If you fail to do this, please let me know and I will provide an example on
how to use SEEx.

--
Ndi
BrainBench MVP for Windows 95
www.Brainbench.com

Re:ShellExecute


Quote
On Sat, 6 Oct 2001 03:16:58 +0200, "Ndi" <N...@Ndi.ro> wrote:
>Plus : PChar(nil) is quite indefinite to me. You should:

>ShellExecute(0,nil,PChar(Path),'','',sw_Show), as the '' (empty string)
>means different things then NIL. There was a discussion not so log ago about
>this.

Wished I had followed it. From my experience, whenever an API function
expects a PChar you always need to do first

  if aString='' then
    aPchar=Nil
  else
    aPchar:= Pchar(aString);

as PChar('') fails miserably.

Manuel Algora
m...@encomix.es

Other Threads