title: How Can I Get Exclusive Lock On Drive / Partition Win-Api 32?
body: <p>How to lock lock on specific drive till i perform some operation(read/write) on that drive.
  When i have captured lock on drive, no other process should able to write on that drive unitl I release lock on that drive, I have found one API i.e. <code>DeviceIoControl()</code>,
  but I want access on drive for my process only, but the above API 'MAY' block access of all the processes. I'm not quite sure how <code>lockfile()</code> and <code>lockfileex()</code> works. Please help me find some way / API/ Logic to do this!
  ...
  ...
  UPDATED :-</p>
  
  <p>with referrance to your answer i have tried this :--></p>
  
  <pre><code>   HANDLE hdest,hf;
     DWORD b,write;
     hdest = CreateFile("\\\\?\\E:",
          GENERIC_READ | GENERIC_WRITE,
          FILE_SHARE_READ | FILE_SHARE_WRITE,
          NULL,
          OPEN_EXISTING,
          NULL,
          NULL);
  
      if (hdest == INVALID_HANDLE_VALUE)
      {
          MessageBox(NULL,TEXT("NOT OK"),TEXT("NOT OK"),0);
      }
  
      if (DeviceIoControl( hdest,FSCTL_LOCK_VOLUME,NULL,0,NULL,0,&amp;b,NULL))
      {
          MessageBox(NULL,TEXT("OK"),TEXT("OK"),0);
  
              hf = CreateFile(TEXT("E:\\M_lucky.txt"), GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
                  if (hf == INVALID_HANDLE_VALUE)
                  {
                      MessageBox(NULL,TEXT("NOT OK AFTER LOCK I"),TEXT("NOT OK AFTRE LOCK"),0);
                  }
              WriteFile(hf, TEXT("M very lucky"), 13, &amp;write, NULL);
      }
  
      CloseHandle((HANDLE)hdest);
      CloseHandle((HANDLE)hf);
  
      DeviceIoControl( hdest,FSCTL_UNLOCK_VOLUME,NULL,0,NULL,0,&amp;b,NULL);
  
      hf = CreateFile(TEXT("E:\\MNOT_lucky.txt"), GENERIC_WRITE, 0, NULL,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0);
                  if (hf == INVALID_HANDLE_VALUE)
                  {
                      MessageBox(NULL,TEXT("NOT OK AFTER LOCK"),TEXT("NOT OK AFTRE LOCK"),0);
  
                  }
              WriteFile(hf, TEXT("M lucky"), 8, &amp;write, NULL);
      CloseHandle((HANDLE)hf);
  </code></pre>
  
  <p>""but........""
  after getting exclusive lock on E drive, i am unable to create file.
  (i have read that : only hdest(HANDLE) gets exclusive lock on that drive. )</p>
  
  <p>here..!!! i want to create M_LUCKY.txt file..!!
  (I need EXLUSIVE access on drive with context to PROCESS)
  plz help! thanks a lottt!!</p>
  
  <p>is there any other method for doing this?? </p>