home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / DOS_HELP / UNDOC2E.ZIP / UNDOC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-05-17  |  1.7 KB  |  86 lines

  1. /*
  2. * Program Description:
  3. *     This programs shows the usage of the undocumented DOS interrupt
  4. *     2eh. By executing this interrupt, you can permanently modify the
  5. *     DOS environment variables.
  6. *
  7. * Compilation:
  8. *     CL /c /Ox /Zp /Gs /AS undoc.c
  9. *
  10. * Linking:
  11. *     LINK undoc+int2e;
  12. *
  13. * Execution:
  14. *     UNDOC env-variable=new-value
  15. *           where env-variable is the variable to set
  16. *                 new-value    is the new value of the environment variable
  17. *
  18. *     Example: UNDOC PATH=C:\DOS
  19. */
  20.  
  21. /*
  22. * make sure we use the standard functions properly
  23. * by including function prototypes for common routines
  24. */
  25. #include <stdio.h>
  26. #include <stdlib.h>
  27. #include <string.h>
  28.  
  29. /*
  30. * make a prototype for int_2e()
  31. */
  32. extern void int_2e(char *);
  33.  
  34. /*
  35. * this string holds the command to execute via int 2eh
  36. */
  37. static char command_to_execute[129];
  38.  
  39. /*
  40. * main program entry point
  41. */
  42. main(int argc, char *argv[])
  43. {
  44.  
  45. /*
  46. * if the user doesn't know how to use this utility, tough shit . . .
  47. */
  48.    if (argc != 2)
  49.    {
  50.       printf("Syntax error\n");
  51.       exit(1);
  52.    }
  53.  
  54. /*
  55. * see if we are running under small model
  56. */
  57.    if (sizeof(char *) != sizeof(int))
  58.    {
  59.       printf("Only works under small model!\n");
  60.       exit(1);
  61.    }
  62.  
  63. /* 
  64. * byte zero needs the string length of the command
  65. */
  66.    command_to_execute[0] = strlen(argv[1]) + 5;
  67.    strcpy(&command_to_execute[1],"SET ");
  68.    strcat(command_to_execute,argv[1]);
  69.  
  70. /*
  71. * we need to terminate the string with a <CR>
  72. */
  73.    command_to_execute[command_to_execute[0]+1] = 0x0d;
  74.  
  75. /*
  76. * call the undocumented interrupt
  77. */
  78.    int_2e(command_to_execute);
  79.  
  80. /*
  81. * terminate program
  82. */
  83.    exit(0);
  84.  
  85. }
  86.