|
-
Aug 31st, 2001, 08:24 PM
#1
Thread Starter
PowerPoster
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?
-
Aug 31st, 2001, 10:30 PM
#2
Try this:
PHP Code:
HINSTANCE tempRes = ShellExecute(hwnd, "open",combotext,NULL,NULL, SW_NORMAL);
if ((long)tempRes <= 32) // Validate file
{
// Error!!!
MessageBox(hwnd, "An error occured while trying to access this file.", "Error", MB_OK | MB_ICONERROR);
}
-
Aug 31st, 2001, 11:23 PM
#3
Thread Starter
PowerPoster
Thanks a lot!! It is working now
-
Aug 31st, 2001, 11:57 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|