home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / open.zip / open.c next >
C/C++ Source or Header  |  1995-03-30  |  806b  |  35 lines

  1. #define INCL_DOS
  2. #include <os2.h>
  3. #include <stdio.h>
  4.  
  5. void DisplayHelp(void);
  6.  
  7. main(int argc, char *argv[]) {
  8.     char    filename[2048];
  9.     HOBJECT    hobj;
  10.  
  11.     if (argc < 2) {
  12.         DisplayHelp();
  13.         return 0;
  14.     }
  15.  
  16. // Get the fully qualified path name of the file specified in argument 1
  17.     DosQueryPathInfo(argv[1], FIL_QUERYFULLNAME, filename, 2048);
  18.  
  19. // Open the file
  20.     hobj = WinQueryObject(filename);
  21.     WinSetObjectData(hobj, "OPEN=DEFAULT");
  22.     return 1;
  23. }
  24.  
  25. void DisplayHelp(void) {
  26.     printf("Usage:\n");
  27.     printf("  open filename\n");
  28.     printf("\nwhere\n\n");
  29.     printf("  filename is the name of the file to open.\n");
  30.     printf("\nThe specified file will be opened by the application\n");
  31.     printf("that would run if you double-clicked on the file's icon\n");
  32.     printf("from the WPS.\n");
  33. }
  34.  
  35.