DOS Environment Variables

sherif el kassas elkassas at ebg.eb.ele.tue.nl
Wed May 8 23:37:04 AEST 1991


In article <42119 at cup.portal.com>, robc at cup.portal.com (Rob X Cowan) writes:
=> [stuff deleted]
=>      I forgot to mention that int 2Eh (command.com interface) also has a
=> way to actually access its own SET command.  Can't remember how right now,
=> but it should be easier than direct access, if your not up to that.
=> 
=> -Rob
=> robc at cup.portal.com

Well, that's how i'd do it ! any better ideas ?
Sherif

#include <standard_disclaimer>
----8<--------------------------------------
/*
 * file: test2e.c
 * demo for changing environment vars ...etc
 * compile with:
 *   TCC  test2e.c
 * note that u'll need tasm or masm !
 */

#include <dos.h>
#include <string.h>

char *command = " set t=this is a test \r";

void int2e(char far *command_line)
{
  unsigned seg, ofs;

  seg = FP_SEG(command_line);
  ofs = FP_OFF(command_line);

  asm      jmp start
  asm      my_ss dw 00
  asm      my_sp dw 00
  start:
  asm      push bp
  asm      push ds
  asm      mov  ax, ss
  asm      mov  cs:my_ss, ax
  asm      mov  cs:my_sp, sp
  asm      mov  si, ofs
  asm      mov  ax, seg
  asm      mov  ds, ax
  asm      int  2Eh
  asm      cli
  asm      mov  sp, cs:my_sp
  asm      mov  ax, cs:my_ss
  asm      mov  ss, ax
  asm      sti
  asm      pop  ds
  asm      pop  bp
}

main()
{
  command[0] = strlen(command)-1;
  int2e(command);
}



More information about the Comp.lang.c mailing list