Solved

detecting write protected media

Posted on 2001-08-02
4
227 Views
Last Modified: 2010-04-02
Hi.
I need to detect whether media in floppy or MO disk is write-protected or not.
I've tried to determine it by opening device "\\.\A:" with GENERIC_WRITE access permission, but it succeeds even if the media is write protected.
Any ideas ?
Thank you in advance.
0
Comment
Question by:sisadmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 6344878
I suppose you could try creating a file in it and see if it works:

HANDLE hTempFile;

GetTempFileName("A:\\", // dir. for temp. files
  "NEW",                // temp. filename prefix
  0,                    // create unique name
  szTempName);          // buffer for name

hTempFile = CreateFile((LPTSTR) szTempName,  // filename
  GENERIC_READ | GENERIC_WRITE, // open for read-write
  0,                            // do not share
  NULL,                         // no security
  CREATE_ALWAYS,                // overwrite existing file
  FILE_ATTRIBUTE_NORMAL,        // normal file
  NULL);                        // no attr. template

if (hTempFile == INVALID_HANDLE_VALUE) {
  printf("Read-only");
}


0
 
LVL 1

Author Comment

by:sisadmin
ID: 6352760
Hi.
I suppose this will work fine for floppy, but this might be wrong on MO disk, that is NTFS formatted and can have protected folders and so on.
0
 
LVL 11

Expert Comment

by:griessh
ID: 6842561
I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. Unless there is objection or further activity,  I will suggest to refund the points and delete this question since nobody had a satisfying answer for you.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 

Accepted Solution

by:
ComTech earned 0 total points
ID: 6858039
After review, the proposed answer will be accepted by:

ComTech
Community Support Admin
0

Featured Post

Technology Partners: 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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

737 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