home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vdmutils.zip / VDMUTILS.PAS < prev   
Pascal/Delphi Source File  |  1997-10-21  |  11KB  |  212 lines

  1. {  Library of functions that can be called only from within an
  2.    an OS/2 Virtual DOS Machine (VDM).
  3.  
  4.    These Pascal declarations were tested using IBM Pascal/2 in
  5.    DOS mode. Any problems when using a more mainstream compiler
  6.    should be reported, preferably with resolutions.
  7.  
  8.    Some Pascal/2 idiosyncrasies are:
  9.       Pointer variables:
  10.       ADS OF xxxx     means a far pointer to type xxxx
  11.       ADR OF xxxx     means a near pointer to type xxxx
  12.       ADSMEM          means a far pointer to general bytes
  13.       ADRMEM          means a near pointer to general bytes
  14.  
  15.       Formal parameters of PROCEDURE and FUNCTION declarations:
  16.       VARS            means a variable passed by far pointer
  17.       CONSTS          means a constant passed by far pointer
  18.       CONST           means a constant passed by near pointer
  19.  
  20.    Since this is the only Pascal compiler I have, I must put up
  21.    with this crap. Alas, it means you will have to fix these
  22.    declarations to suit your compiler yourself.
  23.  
  24.    Copyright (C) 1996, 1997, David W. Noon }
  25.  
  26. CONST
  27.       NULLSHANDLE               =       0;
  28.       NULLHANDLE                =       0;
  29.  
  30.       DC_SEM_SHARED             =       1;
  31.       DCMW_WAIT_ANY             =       2;
  32.       DCMW_WAIT_ALL             =       4;
  33.       SEM_INDEFINITE_WAIT       =      -1;
  34.       SEM_IMMEDIATE_RETURN      =       0;
  35.  
  36.       FIL_STANDARD              =       1;
  37.       FIL_QUERYEASIZE           =       2;
  38.       FIL_QUERYEASFROMLIST      =       3;
  39.       FIL_QUERYALLEAS           =       4;
  40.       FIL_QUERYFULLNAME         =       5;
  41.  
  42.       { Since these are bit mask options we'll do them in hex. }
  43.       FEA_NEEDEA                =   16#80;
  44.  
  45.       EAT_BINARY                = 16#FFFE;
  46.       EAT_ASCII                 = 16#FFFD;
  47.       EAT_BITMAP                = 16#FFFB;
  48.       EAT_METAFILE              = 16#FFFA;
  49.       EAT_ICON                  = 16#FFF9;
  50.       EAT_EA                    = 16#FFEE;
  51.       EAT_MVMT                  = 16#FFDF;
  52.       EAT_MVST                  = 16#FFDE;
  53.       EAT_ASN1                  = 16#FFDD;
  54.  
  55.       SSF_RELATED_INDEPENDENT   = 16#0000;
  56.       SSF_RELATED_CHILD         = 16#0001;
  57.  
  58.       SSF_FGBG_FORE             = 16#0000;
  59.       SSF_FGBG_BACK             = 16#0001;
  60.  
  61.       SSF_TRACEOPT_NONE         = 16#0000;
  62.       SSF_TRACEOPT_TRACE        = 16#0001;
  63.       SSF_TRACEOPT_TRACEALL     = 16#0002;
  64.  
  65.       SSF_INHERTOPT_SHELL       = 16#0000;
  66.       SSF_INHERTOPT_PARENT      = 16#0001;
  67.  
  68.       SSF_TYPE_DEFAULT          = 16#0000;
  69.       SSF_TYPE_FULLSCREEN       = 16#0001;
  70.       SSF_TYPE_WINDOWABLEVIO    = 16#0002;
  71.       SSF_TYPE_PM               = 16#0003;
  72.       SSF_TYPE_VDM              = 16#0004;
  73.       SSF_TYPE_WINDOWEDVDM      = 16#0007;
  74.  
  75.       SSF_CONTROL_SETPOS        = 16#8000;
  76.       SSF_CONTROL_NOAUTOCLOSE   = 16#0008;
  77.       SSF_CONTROL_MINIMIZE      = 16#0004;
  78.       SSF_CONTROL_MAXIMIZE      = 16#0002;
  79.       SSF_CONTROL_INVISIBLE     = 16#0001;
  80.       SSF_CONTROL_VISIBLE       = 16#0000;
  81.  
  82. TYPE SHANDLE = WORD;
  83.      LHANDLE = INTEGER4;
  84.      HFILE = SHANDLE;
  85.      HEV = LHANDLE;
  86.      HMTX = LHANDLE;
  87.      HMUX = LHANDLE;
  88.      PID = LHANDLE;
  89.      TID = LHANDLE;
  90.      PCSZ = ADS OF STRING;
  91.  
  92.      {  The following types have been translated from the
  93.         OS/2 Developer's Toolkit 1.3 documentation. }
  94.  
  95.      FDATE = WORD;
  96.      {
  97.         unsigned day   : 5;     /* binary day for directory entry */
  98.         unsigned month : 4;     /* binary month for directory entry */
  99.         unsigned year  : 7;     /* binary year for directory entry, offset from 1980 */
  100.      }
  101.  
  102.      FTIME = WORD;
  103.      {
  104.         unsigned twosecs : 5;       /* binary number of two-second increments */
  105.         unsigned minutes : 6;       /* binary number of minutes */
  106.         unsigned hours   : 5;       /* binary number of hours */
  107.      }
  108.  
  109.      { Note that this structure needs to be byte packed!! }
  110.      FILESTATUS = PACKED RECORD
  111.         fdateCreation   : FDATE;     { date of file creation }
  112.         ftimeCreation   : FTIME;     { time of file creation }
  113.         fdateLastAccess : FDATE;     { date of last access }
  114.         ftimeLastAccess : FTIME;     { time of last access }
  115.         fdateLastWrite  : FDATE;     { date of last write }
  116.         ftimeLastWrite  : FTIME;     { time of last write }
  117.         cbFile          : INTEGER4;  { file size (end of data) }
  118.         cbFileAlloc     : INTEGER4;  { file allocated size }
  119.         attrFile        : WORD;      { attributes of the file }
  120.         cbList          : INTEGER4;  { file EA structure size }
  121.      END;
  122.  
  123.      {  Since the next four structures are self-defining, they cannot be readily
  124.         declared in Pascal. [Or C/C++ for that matter!]
  125.      GEA = RECORD
  126.         cbName          : BYTE;                     /* name length not including NULL */
  127.         szName          : STRING(cbName);           /* attribute name */
  128.         filler          : CHAR;                     /* must be CHR(0) */
  129.      END;
  130.  
  131.      FEA = RECORD
  132.         fEAflag         : BYTE;                     /* flags */
  133.         cbName          : BYTE;                     /* name length not including NULL */
  134.         cbValue         : WORD;                     /* value length */
  135.         szName          : STRING(cbName);           /* attribute name */
  136.         filler          : CHAR;                     /* must be CHR(0) */
  137.         aValue          : STRING(cbValue);          /* attribute value -- offset varies with cbName */
  138.      END;
  139.  
  140.      GEALIST = RECORD
  141.         cbList          : INTEGER4;                 /* total bytes of structure including full list */
  142.         list            : STRING(cbList);           /* variable length GEA structures */
  143.      END;
  144.  
  145.      FEALIST = RECORD
  146.         cbList          : INTEGER4;                 /* total bytes of structure including full list */
  147.         list            : STRING(cbList);           /* variable length FEA structures */
  148.      END;
  149.      { End of self-defining structures }
  150.  
  151.      EAOP = RECORD
  152.         fpGEAList       : ADSMEM;                   { general EA list }
  153.         fpFEAList       : ADSMEM;                   { full EA list }
  154.         oError          : INTEGER4;
  155.      END;
  156.  
  157.      { The following type has been translated from the OS/2 Warp Developer's Toolkit 4.0 }
  158.      STARTDATA = RECORD
  159.         Length           : WORD;     { The length of the data structure, in bytes, including Length itself. }
  160.         Related          : WORD;     { An indicator which specifies whether the session created is related to the calling session. }
  161.         FgBg             : WORD;     { An indicator which specifies whether the new session should be started in the foreground or background. }
  162.         TraceOpt         : WORD;     { An indicator which specifies whether the program started in the new session should be executed under conditions for tracing. }
  163.         PgmTitle         : PCSZ;     { Address of an ASCIIZ string that contains the program title. }
  164.         PgmName          : PCSZ;     { The address of an ASCIIZ string that contains the file specification of the program to be loaded. }
  165.         PgmInputs        : PCSZ;     { Either 0 or the address of an ASCIIZ string that contains the input arguments to be passed to the program. }
  166.         TermQ            : PCSZ;     { Either 0 or the address of an ASCIIZ string that contains the file specification of a system queue. }
  167.         Environment      : PCSZ;     { The address of an environment string to be passed to the program started in the new session. }
  168.         InheritOpt       : WORD;     { Specifies whether the program started in the new session should inherit the calling program's environment and open file handles. }
  169.         SessionType      : WORD;     { The type of session that should be created for this program. }
  170.         IconFile         : PCSZ;     { Either 0 or the address of an ASCIIZ string that contains the file specification of an icon definition. }
  171.         PgmHandle        : INTEGER4; { Either 0 or the program handle. }
  172.         PgmControl       : WORD;     { An indicator which specifies the initial state for a windowed application. }
  173.         InitXPos         : WORD;     { The initial x-coordinate, in pels, for the initial session window. }
  174.         InitYPos         : WORD;     { The initial y-coordinate, in pels, for the initial session window. }
  175.         InitXSize        : WORD;     { The initial x extent, in pels, for the initial session window. }
  176.         InitYSize        : WORD;     { The initial y extent, in pels, for the initial session window. }
  177.         Reserved         : WORD;     { Reserved; must be zero. }
  178.         ObjectBuffer     : ADSMEM;   { Buffer in which the name of the object that contributed to the failure of DosExecPgm is returned. }
  179.         ObjectBuffLen    : INTEGER4; { The length, in bytes, of the buffer pointed to by ObjectBuffer. }
  180.      END;
  181.  
  182. FUNCTION DwnExitVDM : WORD; EXTERN;
  183.  
  184. PROCEDURE DwnReleaseTimeSlice; EXTERN;
  185.  
  186. PROCEDURE DwnSetSessionTitle(CONSTS Session_title : STRING); EXTERN;
  187. PROCEDURE DwnQuerySessionTitle(VARS Session_title : STRING); EXTERN;
  188.  
  189. FUNCTION DwnQFileInfo(FileHandle : HFILE; FileInfoLevel : WORD; FileInfoBuf : ADSMEM; FileInfoBufSize : WORD) : WORD; EXTERN;
  190. FUNCTION DwnQPathInfo(CONSTS PathName : STRING; PathInfoLevel : WORD; PathInfoBuf : ADSMEM; PathInfoBufSize : WORD) : WORD; EXTERN;
  191. FUNCTION DwnSetFileInfo(FileHandle : HFILE; FileInfoLevel : WORD; FileInfoBuf : ADSMEM; FileInfoBufSize : WORD) : WORD; EXTERN;
  192. FUNCTION DwnSetPathInfo(CONSTS PathName : STRING; PathInfoLevel : WORD; PathInfoBuf : ADSMEM; PathInfoBufSize : WORD) : WORD; EXTERN;
  193.  
  194. FUNCTION DwnCreateEventSem(CONSTS SemName : STRING; VARS SemHandle : HEV; Attr : WORD; State : WORD) : WORD; EXTERN;
  195. FUNCTION DwnOpenEventSem(CONSTS SemName : STRING; VARS SemHandle : HEV) : WORD; EXTERN;
  196. FUNCTION DwnCloseEventSem(SemHandle : HEV) : WORD; EXTERN;
  197. FUNCTION DwnResetEventSem(SemHandle : HEV; VARS PostCount : INTEGER4) : WORD; EXTERN;
  198. FUNCTION DwnPostEventSem(SemHandle : HEV) : WORD; EXTERN;
  199. FUNCTION DwnWaitEventSem(SemHandle : HEV; Timeout : INTEGER4) : WORD; EXTERN;
  200. FUNCTION DwnQueryEventSem(SemHandle : HEV; VARS PostCount : INTEGER4) : WORD; EXTERN;
  201.  
  202. FUNCTION DwnCreateMutexSem(CONSTS SemName : STRING; VARS SemHandle : HMTX; Attr : WORD; State : WORD) : WORD; EXTERN;
  203. FUNCTION DwnOpenMutexSem(CONSTS SemName : STRING; VARS SemHandle : HMTX) : WORD; EXTERN;
  204. FUNCTION DwnCloseMutexSem(SemHandle : HMTX) : WORD; EXTERN;
  205. FUNCTION DwnRequestMutexSem(SemHandle : HMTX; TimeOut : INTEGER4) : WORD; EXTERN;
  206. FUNCTION DwnReleaseMutexSem(SemHandle : HMTX) : WORD; EXTERN;
  207. { Dos32QueryMutexSem() isn't supported at the moment, courtesy of IBM.
  208. FUNCTION DwnQueryMutexSem(SemHandle : HMTX; VARS OwnerProcess : PID; VARS OwnerThread : TID; VARS RequestCount : INTEGER4) : WORD; EXTERN;
  209. }
  210.  
  211. FUNCTION DwnStartSession(VARS StrtData : STARTDATA) : WORD; EXTERN;
  212.