home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / k95source / se.c < prev    next >
C/C++ Source or Header  |  2020-01-01  |  3KB  |  89 lines

  1. //SE.CPP
  2. #include <windows.h>
  3. /*
  4. typedef struct _SHELLEXECUTEINFO {    
  5.     DWORD cbSize;     
  6.     ULONG fMask;
  7.     HWND hwnd;     
  8.     LPCTSTR lpVerb;     
  9.     LPCTSTR lpFile;
  10.     LPCTSTR lpParameters;     
  11.     LPCTSTR lpDirectory;     
  12.     int nShow;
  13.     HINSTANCE hInstApp;      // Optional members     
  14.     LPVOID lpIDList;
  15.     LPCSTR lpClass;     
  16.     HKEY hkeyClass;
  17.     DWORD dwHotKey;     
  18.     union {
  19.         HANDLE hIcon;        
  20.         HANDLE hMonitor;    
  21.     };    
  22.     HANDLE hProcess;
  23. } SHELLEXECUTEINFO, FAR *LPSHELLEXECUTEINFO;  
  24.  
  25. BOOL ShellExecuteEx(LPSHELLEXECUTEINFO lpExecInfo);
  26.  
  27. */
  28.  
  29. int 
  30. main( int argc, char * argv[] )
  31. {
  32.     HINSTANCE error = ShellExecute(NULL, "open", argv[1],
  33.                                     (argc > 2) ? argv[2] : NULL,
  34.                                     (argc > 3) ? argv[3] : NULL,
  35.                                     SW_SHOW);
  36.  
  37.     if ( ((DWORD) error) <= 32 ) {
  38.         switch ( (DWORD) error ) {
  39.         case 0:    
  40.             printf("The operating system is out of memory or resources.\n");
  41.             break;
  42.         case ERROR_BAD_FORMAT:
  43.             printf("The .EXE file is invalid (non-Win32 .EXE or error in .EXE image).\n");
  44.             break;
  45.         case SE_ERR_ACCESSDENIED:
  46.             printf("The operating system denied access to the specified file.\n");
  47.             break;
  48.         case SE_ERR_ASSOCINCOMPLETE:
  49.             printf("The filename association is incomplete or invalid.\n");
  50.             break;
  51.         case SE_ERR_DDEBUSY:
  52.             printf("The DDE transaction could not be completed because other DDE transactions were being processed.\n");
  53.             break;
  54.         case SE_ERR_DDEFAIL:
  55.             printf("The DDE transaction failed.\n");
  56.             break;
  57.         case SE_ERR_DDETIMEOUT:
  58.             printf("The DDE transaction could not be completed because the request timed out.\n");
  59.             break;
  60.         case SE_ERR_DLLNOTFOUND:
  61.             printf("The specified dynamic-link library was not found.\n");
  62.             break;
  63.         case SE_ERR_FNF:
  64.             printf("The specified file was not found.\n");
  65.             break;
  66.         case SE_ERR_NOASSOC:
  67.             printf("There is no application associated with the given filename extension.\n");
  68.             break;
  69.         case SE_ERR_OOM:
  70.             printf("There was not enough memory to complete the operation.\n");
  71.             break;
  72.         case SE_ERR_PNF:
  73.             printf("The specified path was not found.\n");
  74.             break;
  75.         case SE_ERR_SHARE:
  76.             printf("A sharing violation occurred.\n");
  77.             break;
  78.         default:
  79.             printf("Unknown error\n");
  80.         }
  81.         return 1;
  82.     }
  83.     else {
  84.         CloseHandle((HINSTANCE)error);
  85.         return 0;
  86.     }
  87. }
  88.  
  89.