Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Volume locking

Posted on 1997-03-04
1
Medium Priority
?
1,118 Views
Last Modified: 2013-12-26
How is it possible to lock/unlock a volume (Harddisk)? It is not possible with the RedEdit "Get File/Folder Info". Is there a command in C to lock/unlock a volume, or to safe files on a locked volume?
0
Comment
Question by:MacJon
1 Comment
 
LVL 4

Accepted Solution

by:
Alex Curylo earned 100 total points
ID: 1291385
You use PBSetVInfo(). Of course, that only works if it's a software lock, there's obviously nothing code can do about a hardware lock (like the tab on a floppy).

Here's code which is untested but I imagine should work:

OSErr      VolLock(ConstStr255Param pathname, short vRefNum, bool lockIt)
{
      HParamBlockRec pb;
      OSErr error;

      error = GetVolumeInfoNoName(pathname,vRefNum, &pb);
      if ( error == noErr )
      {
            if ( (pb.volumeParam.ioVAtrb & 0x0080) != 0 )
            {
                  error = wPrErr;            /* volume locked by hardware */
            }
            else
  {
     bool swLocked = ( (pb.volumeParam.ioVAtrb & 0x8000) != 0 );
     if (swLocked != lockIt)
     {
        pb.volumeParam.ioVAtrb ^= 0x8000;
        error = PBSetVInfoSync(&pb);
     }
   }
 }
      
      return ( error );
}

GetVolumeInfoNoName() is part of the fine, fine MoreFiles source, available from

<ftp://members.aol.com/JumpLong/MoreFiles_1.4.6.sea.hqx


0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question