Re: IOCTL_DISK_GET_PARTITION_INFO_EX Fails on Dynamic Disks with (1) Incorrect function.
From: Joe Richards [MVP] (humorexpress_at_hotmail.com)
Date: 08/07/04
- Next message: Chuck Chopp: "Re: Changing a Services session id"
- Previous message: Gary Chanson: "Re: How can I get list of all active low lever Hooks"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 07 Aug 2004 17:58:29 -0400
n/m I think I worked it out. Issue would appear to be that a volume that sits on
a dynamic disk could span multiple dynamic disks. Calling a function to get the
info under one of those disks wouldn't make sense.
--
Joe Richards Microsoft MVP Windows Server Directory Services
www.joeware.net
Joe Richards [MVP] wrote:
> I am trying to use the IOCTL_DISK_GET_PARTITION_INFO_EX control code and
> anytime I hit a volume that is Dynamic is kicks out with an Error of 1,
> Incorrect Function.
>
> Below is a small snippet of how the handle is opened and the way I am
> using IOCTL_DISK_GET_PARTITION_INFO_EX. Note that it works great on
> volumes that are located on Basic Disks....
>
> Disk0 has C: and is basic
> Disk1 has E: J: K: L: and is dynamic
> Disk2 has F: G: H: I: and is basic
>
>
> DEBUG: Gather Part Info for c:
> DEBUG: Opening \\.\c:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 1
> DEBUG: Partition Style : 0
>
> DEBUG: Gather Part Info for e:
> DEBUG: Opening \\.\e:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
>
> DEBUG: Gather Part Info for f:
> DEBUG: Opening \\.\f:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 1
> DEBUG: Partition Style : 0
>
> DEBUG: Gather Part Info for g:
> DEBUG: Opening \\.\g:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 2
> DEBUG: Partition Style : 0
>
> DEBUG: Gather Part Info for h:
> DEBUG: Opening \\.\h:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 3
> DEBUG: Partition Style : 0
>
> DEBUG: Gather Part Info for i:
> DEBUG: Opening \\.\i:
> DEBUG: Get Partition Info
> DEBUG: Partition Number: 4
> DEBUG: Partition Style : 0
>
> DEBUG: Gather Part Info for j:
> DEBUG: Opening \\.\j:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
>
> DEBUG: Gather Part Info for k:
> DEBUG: Opening \\.\k:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
>
> DEBUG: Gather Part Info for l:
> DEBUG: Opening \\.\l:
> DEBUG: Get Partition Info
> ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): (1) Incorrect function.
> DEBUG: Partition Number: -1
> DEBUG: Partition Style : -1
>
>
>
>
>
>
> HANDLE OpenHandle(string v)
> {
> v="\\\\.\\"+v;
> if (bDebug) cout << "DEBUG: Opening " << v << endl;
> HANDLE h = CreateFile(v.c_str(),GENERIC_READ,
> FILE_SHARE_READ | FILE_SHARE_WRITE,
> NULL, OPEN_EXISTING, 0, NULL);
> if (h == INVALID_HANDLE_VALUE)
> {
> DisplayErrorMsg("ERROR (CreateFile): ");
> return 0;
> }
> return h;
> }
>
>
> bool GetPartInfo(HANDLE h)
> {
> DWORD dwSize=0;
> PARTITION_INFORMATION_EX pie;
>
> ZeroMemory(&pie,sizeof(pie));
>
> if (!DeviceIoControl(h,IOCTL_DISK_GET_PARTITION_INFO_EX,NULL,0,&pie,
> sizeof(pie), &dwSize,NULL))
> { // This fails with err=1 if Dynamic...
> DWORD dwErr=GetLastError();
> DisplayErrorMsg("ERROR (IOCTL_DISK_GET_PARTITION_INFO_EX): ");
> return false;
> }
>
> //
> // Do something with partition info...
> //
>
> return true;
> }
>
>
>
>
> --
> Joe Richards Microsoft MVP Windows Server Directory Services
> www.joeware.net
- Next message: Chuck Chopp: "Re: Changing a Services session id"
- Previous message: Gary Chanson: "Re: How can I get list of all active low lever Hooks"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|