Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17



Posted on 1997-02-10
Medium Priority
Last Modified: 2013-12-04
I've got a program:
      partitionHandle = CreateFile("\\\\.\\C:",
      if(partitionHandle == INVALID_HANDLE_VALUE)
            AfxMessageBox("Can't open RAID device",
                  MB_OK, 0);


            AfxMessageBox("Can't get RAID info",
                  MB_OK, 0);
Now what I got in a msg.string is "Access denied".
I've tried to run it as Administrator with same result.
So what's wrong or/and how could I get partition info in
Windows NT?
Question by:ILIIA
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
1 Comment
LVL 11

Accepted Solution

mikeblas earned 100 total points
ID: 1298760
You need to pass GENERIC_READ to CreateFile().

The documentation implies that you can query the device driver by using 0 for the dwDesiredAccess parameter, and that's true.  But the thing is that the disk driver will end up needing to read the physical device to answer your query, so you need to make sure the handle you pass has adequate access.

I think you should use FILE_SHARE_WRITE | FILE_SHARE_READ, by the way, instead of locking the drive for writes.

Finally, your code is leaky: if you successfully read the information, you never close the handle you created.  You need to CloseHandle() wether the DeviceIOControl() call failed or not.

.B ekiM


Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA.…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

722 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