🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.os2.programmer
1 messages
1 total messages Started by Mikael Wahlgren Tue, 07 Apr 1992 23:31
DOS Commands
#633
Author: Mikael Wahlgren
Date: Tue, 07 Apr 1992 23:31
30 lines
1577 bytes
Following is an example program of how to use the DOS.SYS driver to execute
a command in the OS/2 1.3 DOS compatibility box (I haven't tested how it
works in OS/2 2.0, as there are better means to do this in 2.0).  Note, that
you will need to  switch to the DOS box, before the command is actually
executed.  This could be done automaticly by using the WinQuerySwitchList and
WinSwitchToProgram API, or manually.  If you need an example on how to do
this, I can post this too, but in that case you will have to accept Modula-2
code instead.  The following example is written in C and compiled with
JPI TopSpeed C++ (but there shouldn't be any specific for that compiler:-)

#include <stdio.h>
#include <string.h>

void dosCmd(char *cmd) {
  FILE          *dosdrv;

  if ((dosdrv = fopen("DOS$", "w")) != NULL) {
    fprintf(dosdrv, "%c%c%s%c%c", 128, 32, cmd, 13, 0);
    fclose(dosdrv);
  } else {
    printf("Failed to access DOS box!\n");
    printf("Check that DOS.SYS is loaded and PROTECTONLY=NO in your CONFIG.SYS!\n");
  }
}

void main(void) {
  dosCmd("DIR");
}

Mikael Wahlgren      d9mikael@dtek.chalmers.se
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads