home *** CD-ROM | disk | FTP | other *** search
/ High Voltage Shareware / high1.zip / high1 / DIR2 / 4DEMS.ZIP / EMSFREE.C < prev    next >
Text File  |  1993-11-13  |  2KB  |  58 lines

  1. /*--------------------------------------------------------------------------+
  2. | Module: EMSFREE                                                           |
  3. | Project: TOOLS                                                            |
  4. | Author: Paul A. Penrose                                                   |
  5. |         (c) 1992, 4D Interactive Systems, Inc.  All rights reserved.      |
  6. | Start Date: 19 Nov 92                                                     |
  7. | Last Revised: 19 Nov 92                                                   |
  8. | Purpose:                                                                  |
  9. |   This module contains code to free an EMS handle by name.                |
  10. +--------------------------------------------------------------------------*/
  11.  
  12. #include <stdio.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include "ems.h"
  16.  
  17. char copyright[] = "(c) 1992 4D Interactive Systems, Inc.  All rights reserved.";
  18.  
  19. void main(int argc, char **argv)
  20. {
  21.    int handle;
  22.  
  23.    if (argc > 1) {
  24.       printf("+---------------------------------------+\n");
  25.       printf("| EMS-Free Program  Ver 1.0             |\n");
  26.       printf("| (c) 1992 4D Interactive Systems, Inc. |\n");
  27.       printf("+---------------------------------------+\n");
  28.       if (ems_init()) {
  29.          if (ems_version >= 0x40) {
  30.             strupr(argv[1]);
  31.             handle = ems_find_handle(argv[1]);
  32.             if (handle > 0) {
  33.                ems_restore_mapping_context(handle);
  34.                if (ems_free(handle) == 0) {
  35.                   printf("EMS handle with name '%s' freed.\n",argv[1]);
  36.                }
  37.                else {
  38.                   printf("**Error: Unable to free handle %i, error=%X.\n",handle,ems_errnum);
  39.                }
  40.             }
  41.             else {
  42.                printf("No EMS handle found with the name '%s'\n",argv[1]);
  43.             }
  44.          }
  45.          else {
  46.             printf("**Error: Unsupported EMS version (%i.%i)\n",ems_version >> 4,ems_version & 0x0F);
  47.          }
  48.       }
  49.       else {
  50.          printf("**Error: Unable to Initialize EMS functions.\n");
  51.       }
  52.    }
  53.    else {
  54.       printf("Usage is:\n");
  55.       printf("  EMSFREE handle_name\n");
  56.    }
  57. }
  58.