ShellExecute() doesn't work

This is a discussion on ShellExecute() doesn't work within the Windows Programming forums, part of the Platform Specific Boards category; Hi, I'm trying to open a URL in a browser with ShellExecute, but nothing happens- just nothing. Code: ShellExecute(NULL, "open", ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102

    ShellExecute() doesn't work

    Hi,
    I'm trying to open a URL in a browser with ShellExecute, but nothing happens- just nothing.
    Code:
    ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL);
    What could be the problem?
    Thanks.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    MSND -- ShellExecute

    I doubt Google's URL would be interpreted as being a file on your computer. Check the return value. It's probably telling you it can't find the file.
    Last edited by MacGyver; 04-22-2007 at 03:24 AM. Reason: Fixed bad URL.

  3. #3
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    What would you use to open an URL in the default browser then? This used to work for me some time ago.

    edit: it returns 1.

  4. #4
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    I tried looking through the return values to find which one was 1, and I got the following table:

    Code:
    ERROR_FILE_NOT_FOUND     = 2
    ERROR_PATH_NOT_FOUND     = 3
    ERROR_DDE_FAIL           = 1156
    ERROR_NO_ASSOCIATION     = 1155
    ERROR_ACCESS_DENIED      = 5
    ERROR_DLL_NOT_FOUND      = 1157
    ERROR_CANCELLED          = 1223
    ERROR_NOT_ENOUGH_MEMORY  = 8
    ERROR_SHARING_VIOLATION  = 32
    ERROR_BAD_FORMAT         = 11
    SE_ERR_ACCESSDENIED      = 5
    SE_ERR_ASSOCINCOMPLETE   = 27
    SE_ERR_DDEBUSY           = 30
    SE_ERR_DDEFAIL           = 29
    SE_ERR_DDETIMEOUT        = 28
    SE_ERR_DLLNOTFOUND       = 32
    SE_ERR_FNF               = 2
    SE_ERR_NOASSOC           = 31
    SE_ERR_OOM               = 8
    SE_ERR_PNF               = 3
    SE_ERR_SHARE             = 26
    I don't see 1 in there. Doublecheck the return value or find out what a return value of 1 means. A value less than or equal to 32 means an error occurred.

    Apparently you're right; it will open a URL in the default browser. If you can't figure out what the problem is, you could try something like this:

    Code:
    system("start http://www.google.com");
    Last edited by MacGyver; 04-22-2007 at 03:39 AM.

  5. #5
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Oh, the value was 5, sorry.

    ERROR_ACCESS_DENIED = 5

    Hmm, why?

  6. #6
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Here's a discussion on the subject that may or may not be helpful:

    http://www.codeguru.com/forum/showth...hreadid=317498

  7. #7
    Registered User
    Join Date
    Jan 2006
    Location
    Latvia
    Posts
    102
    Thanks, that WAS helpful.

    Code:
    ShellExecute(NULL, "open", "rundll32.exe", "url.dll,FileProtocolHandler http://www.google.com",NULL,SW_SHOWNORMAL);

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 11:50 AM
  2. Why don't the tutorials on this site work on my computer?
    By jsrig88 in forum C++ Programming
    Replies: 3
    Last Post: 05-15-2006, 11:39 PM
  3. Problems in getting OpenGL to work
    By zonf in forum C Programming
    Replies: 5
    Last Post: 02-13-2006, 04:48 AM
  4. DLL __cdecl doesnt seem to work?
    By Xei in forum C++ Programming
    Replies: 6
    Last Post: 08-21-2002, 05:36 PM
  5. ShellExecute doesn't seem to work in Borland
    By sundeeptuteja in forum C++ Programming
    Replies: 4
    Last Post: 08-06-2002, 04:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21