Thread: ShellExecute error handling

  1. #1
    Registered User
    Join Date
    Mar 2004
    Posts
    161

    Talking ShellExecute error handling

    Hi, here there is the description:

    http://msdn.microsoft.com/library/de...ellexecute.asp

    and in particular:

    Code:
    Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise.
    but..

    Code:
    int Popup (void){
        char popupPath[] = "C:\\.....\test.exe";
    
        if(32 > (ShellExecute(NULL, "open",
                     popupPath,
                     NULL, NULL, SW_SHOWNORMAL))) {
             printf("Error...\n");
        } else printf("Ok..\n");        
        return 0;
    }
    274 [Warning] comparison between pointer and integer.

    It looks like devcpp thinks that shellexecute will return a string (one of those written in the documentation maybe) instead an integer from 0 to 32.

    Any hints? thanx!
    This forum is the best one I've ever seen. Great ppl, great coders

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Quote Originally Posted by MSDN
    Returns a value greater than 32 if successful, or an error value that is less than or equal to 32 otherwise. The following table lists the error values. The return value is cast as an HINSTANCE for backward compatibility with 16-bit Windows applications. It is not a true HINSTANCE, however. The only thing that can be done with the returned HINSTANCE is to cast it to an int and compare it with the value 32 or one of the error codes below.
    You need to cast the return value to an int before doing the comparison. In addition, your comparison returns success for the error value of 32.
    Code:
        if( (int) ShellExecute(NULL, "open",
                     popupPath,
                     NULL, NULL, SW_SHOWNORMAL) <= 32)
        {
             printf("Error...\n");
        }
        else
        {
            printf("Ok..\n");
        }

  3. #3
    Registered User
    Join Date
    Mar 2004
    Posts
    161
    oh great, thanx
    This forum is the best one I've ever seen. Great ppl, great coders

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Retrieving the handle of shellexecute
    By cloudy in forum Windows Programming
    Replies: 2
    Last Post: 08-21-2006, 09:01 AM
  2. ShellExecute, strange !!
    By BianConiglio in forum C Programming
    Replies: 2
    Last Post: 05-05-2004, 04:41 AM
  3. ShellExecute() string problem
    By henrikstolpe in forum Windows Programming
    Replies: 2
    Last Post: 05-21-2003, 09:54 AM
  4. ShellExecute and popups or MessageSending
    By Unregistered in forum Windows Programming
    Replies: 0
    Last Post: 01-03-2002, 09:50 AM