I am trying to get the disk extents given a disk number but I am getting back the following error.
Traceback (most recent call last): File "test2.py", line 29, in <module> win32file.DeviceIoControl(hDevice,winioctlcon.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, None, extents, None) pywintypes.error: (1, 'DeviceIoControl', 'Incorrect function.') I have tried with all three of the disks on my system: \\.\PhysicalDrive0, \\.\PhysicalDrive1, and \\.\PhyscialDrive2 but the results are always the same. Thanks for any insights as to why I am getting this "Incorrect function" error and how to resolve it. Doug Here is the code that I am using. import ctypes import winioctlcon import win32file import win32con disk = r'\\.\PhysicalDrive1' hDevice = win32file.CreateFile( disk, win32con.GENERIC_READ, win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE, None, win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL, None) class DISK_EXTENT(ctypes.Structure): _fields_ = ( ('DiskNumber', ctypes.c_ulong), ('StartingOffset', ctypes.c_longlong), ('ExtentLength', ctypes.c_longlong)) ANYSIZE_ARRAY = 1 class VOLUME_DISK_EXTENTS(ctypes.Structure): _fields_ = ( ('NumberOfDiskExtents', ctypes.c_ulong), ('Extents', DISK_EXTENT * ANYSIZE_ARRAY)) extents = VOLUME_DISK_EXTENTS() try: win32file.DeviceIoControl(hDevice,winioctlcon.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, None, extents, None) finally: hDevice.close()
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32