CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12

Thread: ShellExecute

  1. #1
    Join Date
    Aug 2008
    Posts
    373

    ShellExecute

    Hi all

    I have stranger problem, ShellExecute is working on Vista but problem on XP.
    Code:
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "http://www.abctest.com", SW_SHOWDEFAULT);
    
    or
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "", SW_SHOW);
    Both code working on only Vista.Can any one help me where i am wrong?

  2. #2
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: ShellExecute

    I have tested under Windows XP and both worked well.
    However, anytime ShellExecute fails, you can see what's going wrong by taking a look at the error code (see return value in the ShellExecute function documentation.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  3. #3
    Join Date
    Aug 2008
    Posts
    373

    Re: ShellExecute

    Quote Originally Posted by ovidiucucu View Post
    I have tested under Windows XP and both worked well.
    However, anytime ShellExecute fails, you can see what's going wrong by taking a look at the error code (see return value in the ShellExecute function documentation.
    Thanks for reply
    Now i change something in code like this

    Code:
    ShellExecute( NULL, "open","iexplore.exe","http://www.abctest.com","iexplore.exe", SW_SHOW);
    ShellExecute( NULL, "open","OUTLOOK.EXE","mailto:[email protected]","OUTLOOK.EXE",SW_SHOW);
    Code is working on XP.So Expert can i use this code or not.
    I want to know why this one is not working.
    Code:
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "", SW_SHOW);
    Generally this code working fine.
    Please help me.

  4. #4
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: ShellExecute

    May be in your XP there is no default browser set. So putting iexplore.exe and settings its parameter to desired site opens it in IE.

  5. #5
    Join Date
    Aug 2008
    Posts
    373

    Re: ShellExecute

    Quote Originally Posted by hypheni View Post
    May be in your XP there is no default browser set. So putting iexplore.exe and settings its parameter to desired site opens it in IE.
    ok any one tell me there is any alternate option of shellexecute.

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: ShellExecute

    Quote Originally Posted by Msm View Post
    ok any one tell me there is any alternate option of shellexecute.
    Could you very precisely define for whatpurpose you need an "any alternate option of shellexecute"?
    Just to be able to open some internet browser which was not set as the default one and which name you don't know of?
    Or something else?
    Victor Nijegorodov

  7. #7
    Join Date
    Aug 2008
    Posts
    373

    Re: ShellExecute

    Quote Originally Posted by VictorN View Post
    Could you very precisely define for whatpurpose you need an "any alternate option of shellexecute"?
    Just to be able to open some internet browser which was not set as the default one and which name you don't know of?
    Or something else?
    Thanks for reply sir
    I try to open url and Send mail through shellexecute .

  8. #8
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: ShellExecute

    Quote Originally Posted by Msm View Post
    Quote Originally Posted by VictorN View Post
    Could you very precisely define for what purpose you need an "any alternate option of shellexecute"?
    Just to be able to open some internet browser which was not set as the default one and which name you don't know of?
    Or something else?
    Thanks for reply sir
    I try to open url and Send mail through shellexecute .

    Again:
    [QUOTE=Msm;1975008]
    Quote Originally Posted by VictorN View Post

    Just to be able to open some internet browser which was not set as the default one and which name you don't know of?
    Or something else?
    Or you don't know what "default browser" mean?
    Or you don't know how ShellExecute works?

    Perhaps, you first must read MSDN about ShellExecute and Object Verbs
    Victor Nijegorodov

  9. #9
    Join Date
    Aug 2008
    Posts
    373

    Re: ShellExecute

    [QUOTE=VictorN;1975012]
    Again:
    Quote Originally Posted by Msm View Post
    Or you don't know what "default browser" mean?
    Or you don't know how ShellExecute works?

    Perhaps, you first must read MSDN about ShellExecute and Object Verbs
    Both thing i know and if you look my 1 and 3rd post there i show some code.Problem is code not work on XP.
    Code:
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "http://www.abctest.com", SW_SHOWDEFAULT);
    
    or
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "", SW_SHOW);

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: ShellExecute

    [QUOTE=Msm;1975014]
    Quote Originally Posted by VictorN View Post

    Again:

    Both thing i know and if you look my 1 and 3rd post there i show some code.Problem is code not work on XP.
    Code:
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "http://www.abctest.com", SW_SHOWDEFAULT);
    
    or
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "", SW_SHOW);
    You seem to not!
    Please, look at the post#4 (hypheni)
    And then check in your XP machine whether key HKEY_CLASSES_ROOT\http\shell\open\command exists...
    And the same - for HKEY_CLASSES_ROOT\mailto\shell\open\command
    Victor Nijegorodov

  11. #11
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: ShellExecute

    or simply set default browser from IE Tools > Programs

    And hit Make Default button

  12. #12
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: ShellExecute

    [QUOTE=Msm;1975014]
    Quote Originally Posted by VictorN View Post

    Again:

    Both thing i know and if you look my 1 and 3rd post there i show some code.Problem is code not work on XP.
    Code:
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "http://www.abctest.com", SW_SHOWDEFAULT);
    
    or
    ShellExecute( NULL, "open","http://www.abctest.com",NULL, "", SW_SHOW);
    You don't seem to understand the mechanism which ShellExecute uses to open data files. ShellExecute uses file associations to map file extensions to a program. For example, on most systems an extension of .txt maps to Notepad.exe.

    Why this matters for your situation is because users can change or remove these extensions (which is probably why you are seeing failures on XP).

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured