DosSetVerify: Difference between revisions
Appearance
m Ak120 moved page OS2 API:CPI:DosSetVerify to DosSetVerify |
mNo edit summary |
||
Line 1: | Line 1: | ||
Sets write verification. | Sets write verification. | ||
Line 7: | Line 6: | ||
#include <os2.h> | #include <os2.h> | ||
BOOL32 fVerifySetting; | BOOL32 fVerifySetting; | ||
APIRET ulrc; | APIRET ulrc; | ||
ulrc = DosSetVerify(fVerifySetting); | ulrc = DosSetVerify(fVerifySetting); | ||
</PRE> | |||
==Parameters== | ==Parameters== | ||
; fVerifySetting (BOOL32) - input : The state of verify mode. | ;fVerifySetting (BOOL32) - input : The state of verify mode. | ||
:Possible values are shown in the list below: | |||
Possible values are shown in the list below: | :FALSE Verify mode is not active. | ||
:TRUE Verify mode is active. | |||
==Return Code== | ==Return Code== | ||
ulrc (APIRET) - returns | ulrc (APIRET) - returns | ||
DosSetVerify returns one of the following values: | DosSetVerify returns one of the following values: | ||
* 0 NO_ERROR | * 0 NO_ERROR | ||
* 118 ERROR_INVALID_VERIFY_SWITCH | * 118 ERROR_INVALID_VERIFY_SWITCH | ||
Line 95: | Line 87: | ||
return NO_ERROR; | return NO_ERROR; | ||
} | } | ||
</PRE> | |||
==Related Functions== | ==Related Functions== | ||
* [[ | * [[DosQueryVerify]] | ||
[[Category: | [[Category:Dos]] |
Revision as of 04:26, 9 January 2017
Sets write verification.
Syntax
#define INCL_DOSFILEMGR #include <os2.h> BOOL32 fVerifySetting; APIRET ulrc; ulrc = DosSetVerify(fVerifySetting);
Parameters
- fVerifySetting (BOOL32) - input
- The state of verify mode.
- Possible values are shown in the list below:
- FALSE Verify mode is not active.
- TRUE Verify mode is active.
Return Code
ulrc (APIRET) - returns
DosSetVerify returns one of the following values:
- 0 NO_ERROR
- 118 ERROR_INVALID_VERIFY_SWITCH
Remarks
When verify mode is active, the operating system verifies that data written to the disk is recorded correctly, even though disk recording errors are rare.
Example Code
This example enables disk write verification. It creates a file named "VERIFY.DAT" and writes the critical data to it. After this is done, it restores the original settings.
#define INCL_DOSFILEMGR /* File Manager values */ #define INCL_DOSERRORS /* DOS Error values */ #include <os2.h> #include <stdio.h> #include <string.h> int main(VOID) { UCHAR uchFileName[20] = "VERIFY.DAT", /* Name of file to use */ uchFileData[10] = "SampleData"; /* Stuff to put in file */ HFILE hfFileHandle = 0L; /* Handle for user file */ BOOL32 fUserVerify = 0; /* User Verify flag setting */ ULONG ulAction = 0, /* Action done by DosOpen */ ulWritten = 0; /* Number of bytes written */ APIRET rc = NO_ERROR; /* Return code */ rc = DosQueryVerify(&fUserVerify); /* Get current setting of VERIFY */ if (rc != NO_ERROR) { printf("DosQueryVerify error: return code = %u\n", rc); return 1; } else { printf ("Original setting of Verify=%s\n",(fUserVerify) ? "On" : "Off"); } /* endif */ rc = DosSetVerify(1); /* Set VERIFY=ON */ if (rc != NO_ERROR) { printf("DosSetVerify error: return code = %u\n", rc); return 1; } /* Open the file VERIFY.DAT for read/write. Create it if necessary */ rc = DosOpen(uchFileName, &hfFileHandle, &ulAction, 10L, FILE_NORMAL, OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS, OPEN_SHARE_DENYNONE | OPEN_ACCESS_READWRITE, 0L); if (rc != NO_ERROR) { printf("DosOpen error: return code = %u\n", rc); return 1; } /* Write critical data to the file */ rc = DosWrite (hfFileHandle, (PVOID) uchFileData, sizeof(uchFileData), &ulWritten); if (rc == NO_ERROR) { printf ("%u bytes written to file %s with Verify=On\n", ulWritten,uchFileName); } rc = DosSetVerify(fUserVerify); /* Restore user's verify value */ if (rc != NO_ERROR) { printf("DosSetVerify error: return code = %u\n", rc); return 1; } rc = DosClose(hfFileHandle); /* Close the file */ return NO_ERROR; }