wpLockDrive
Appearance
This method is specific to version 2.1, or higher, of the OS/2 operating system.
This instance method is used to lock or unlock removable media in drives that support this feature.
Syntax
_wpLockDrive(somSelf, fLock)
Parameters
- somSelf (WPDisk *) - input
- Pointer to the object on which the method is being invoked.
- Points to an object of class WPDisk.
- fLock (BOOL) - input
- Lock flag.
- TRUE Increment the lock count.
- FALSE Decrement the lock count.
Returns
- ulReturnCall (ULONG) - returns
- Return code from **DosDevIOCtl** category **8** Function **40**. A return value of **NO_ERROR** indicates that the drive does not support lock and eject.
How to Override
This method should not be overridden.
Usage
This method can be called at any time to lock or unlock a drive.
Example Code
Declaration.
#define INCL_WINWORKPLACE #include <os2.h> WPDisk *somSelf; /* Pointer to the object on which the method is being invoked. */ BOOL fLock; /* Lock flag. */ ULONG ulReturnCall; /* Return code from DosDevIOCtl category 8 Function 40. */ ulReturnCall = _wpLockDrive(somSelf, fLock);
Example:
ULONG ulStatus = 0; /* Status returned from _wpLockDrive */
ULONG ulLockCount = 0; /* Number of times drive is locked */
/* Lock the target drive */
ulStatus = _wpLockDrive( self, TRUE );
if (ulStatus & DRIVE_LOCK_NO_SUPPORT) {
somPrintf("Drive does not support lock/unlock.\n");
} else {
/* Query the target drive */
rc = _wpQueryDriveLockStatus( self /* Self pointer */
, &ulStatus /* Lock status */
, &ulLockCount ); /* Lock count */
if (rc == NO_ERROR) {
somPrintf("_wpQueryDriveLockStatus reports:\n");
if (ulStatus & DRIVE_LOCKED) {
somLPrintf(1, "Drive is locked.\n");
somLPrintf(1, "Lock count = %u\n", ulLockCount);
}
}
/* Unlock the target drive */
ulStatus = _wpLockDrive( self, FALSE );
} /* endif */