DosOpen

DosOpen

#define INCL_DOSFILEMGR

USHORT  rc = DosOpen(FileName, FileHandle, ActionTaken, FileSize,
                             FileAttribute, OpenFlag, OpenMode, Reserved);

PSZ              FileName;      /* File path name string */
PHFILE           FileHandle;    /* File handle (returned) */
PUSHORT          ActionTaken;   /* Action taken (returned) */
ULONG            FileSize;      /* File primary allocation */
USHORT           FileAttribute; /* File Attribute */
USHORT           OpenFlag;      /* Open function type */
USHORT           OpenMode;      /* Open mode of the file */
ULONG            0;             /* Reserved (must be zero) */

USHORT           rc;            /* return code */

Example

This example opens a file.

#define INCL_DOSFILEMGR

#define OPEN_FILE 0x01
#define CREATE_FILE 0x10
#define FILE_ARCHIVE 0x20
#define FILE_EXISTS OPEN_FILE
#define FILE_NOEXISTS CREATE_FILE
#define DASD_FLAG 0
#define INHERIT 0x80
#define WRITE_THRU 0
#define FAIL_FLAG 0
#define SHARE_FLAG 0x10
#define ACCESS_FLAG 0x02

#define FILE_NAME "test.dat"
#define FILE_SIZE 800L
#define FILE_ATTRIBUTE FILE_ARCHIVE
#define RESERVED 0L

HFILE   FileHandle;
USHORT  Wrote;
USHORT  Action;
PSZ     FileData[100];
USHORT  rc;

   Action = 2;
   strcpy(FileData, "Data...");
   rc = DosOpen(FILE_NAME,                /* File path name */
                &FileHandle,             /* File handle */
                &Action,                 /* Action taken */
                FILE_SIZE,               /* File primary allocation */
                FILE_ATTRIBUTE,          /* File attribute */
                FILE_EXISTS | FILE_NOEXISTS,           /* Open function
                                                                 type */
                DASD_FLAG | INHERIT |            /* Open mode of the file */
                WRITE_THRU | FAIL_FLAG |
                SHARE_FLAG | ACCESS_FLAG,
                RESERVED);               /* Reserved (must be zero) */


[Back: DosNewSize]
[Next: DosOpen2]