Results 1 to 4 of 4

Thread: Error handling

  1. #1

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827

    Error handling

    I am using "ShellExecute" to open a file but I want to show an error message whenever the path or file is invalid or some other error occurs. How do I do that?

    I have tried the following line of code but even if the specific path is valid, it still shows the error message:

    Code:
    if(ShellExecute(hwnd, "open",combotext,NULL,NULL, SW_NORMAL)==(HINSTANCE)ERROR_FILE_NOT_FOUND || (HINSTANCE)ERROR_PATH_NOT_FOUND || (HINSTANCE)ERROR_PATH_NOT_FOUND)
    			   {
    				   MessageBox(hwnd, "The specified file name or path was not found, or there is not enough memory to run this program. Please try again"
    					   , "Error!!", MB_OK | MB_ICONERROR);
    			   }
    When I type "C:\" as the path, it opened The contents of C: but still showed me the message box. How do you fix that?
    Baaaaaaaaah

  2. #2
    Sc0rp
    Guest
    Try this:
    PHP Code:
    HINSTANCE tempRes ShellExecute(hwnd"open",combotext,NULL,NULLSW_NORMAL);

    if ((
    long)tempRes <= 32// Validate file
    {
        
    // Error!!!
        
    MessageBox(hwnd"An error occured while trying to access this file.""Error"MB_OK MB_ICONERROR);


  3. #3

    Thread Starter
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Thanks a lot!! It is working now
    Baaaaaaaaah

  4. #4
    Sc0rp
    Guest
    No problem.

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