At any time during normal system operation, data destined for a disk might be in a cache. If this information is not written to disk before the system powered-off, the disk can become corrupted. To prevent this, applications call DosShutdown to ensure that the operating system writes the data in the cache to the disk and prevents any further data from being cached. The user can then safely power-off the system.
Note: This call prepares all file systems and device drivers for system shutdown. Therefore, it must be called only when system shutdown is about to occur. The user and applications will no longer have access to their storage devices.
The following code fragment locks out changes to all file systems, and writes system buffers to the disk in preparation for turning off power to the system.
#define INCL_DOSFILEMGR /* File System values */ #include <os2.h> #include <stdio.h> ULONG ulReserved; /* Reserved, must be zero */ APIRET ulrc; /* Return code */ ulReserved = 0; /* Reserved, must be set to zero */ ulrc = DosShutdown(ulReserved); if (ulrc != 0) { printf("DosShutdown error: return code = %ld", ulrc); return; }