當前位置: 首頁>>代碼示例>>Python>>正文


Python win32file.GetDriveType方法代碼示例

本文整理匯總了Python中win32file.GetDriveType方法的典型用法代碼示例。如果您正苦於以下問題:Python win32file.GetDriveType方法的具體用法?Python win32file.GetDriveType怎麽用?Python win32file.GetDriveType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在win32file的用法示例。


在下文中一共展示了win32file.GetDriveType方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: findAvailableDrives

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def findAvailableDrives():
    return [(d, win32file.GetDriveType(d)) for d in
            win32api.GetLogicalDriveStrings().rstrip('\0').split('\0')] 
開發者ID:mbusb,項目名稱:multibootusb,代碼行數:5,代碼來源:win32.py

示例2: findVolumeGuids

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def findVolumeGuids():
    DiskExtent = collections.namedtuple(
        'DiskExtent', ['DiskNumber', 'StartingOffset', 'ExtentLength'])
    Volume = collections.namedtuple(
        'Volume', ['Guid', 'MediaType', 'DosDevice', 'Extents'])
    found = []
    h, guid = FindFirstVolume()
    while h and guid:
        #print (guid)
        #print (guid, win32file.GetDriveType(guid),
        #       win32file.QueryDosDevice(guid[4:-1]))
        hVolume = win32file.CreateFile(
            guid[:-1], win32con.GENERIC_READ,
            win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
            None, win32con.OPEN_EXISTING, win32con.FILE_ATTRIBUTE_NORMAL,  None)
        extents = []
        driveType = win32file.GetDriveType(guid)
        if driveType in [win32con.DRIVE_REMOVABLE, win32con.DRIVE_FIXED]:
            x = win32file.DeviceIoControl(
                hVolume, winioctlcon.IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS,
                None, 512, None)
            instream = io.BytesIO(x)
            numRecords = struct.unpack('<q', instream.read(8))[0]
            fmt = '<qqq'
            sz = struct.calcsize(fmt)
            while 1:
                b = instream.read(sz)
                if len(b) < sz:
                    break
                rec = struct.unpack(fmt, b)
                extents.append( DiskExtent(*rec) )
        vinfo = Volume(guid, driveType, win32file.QueryDosDevice(guid[4:-1]),
                       extents)
        found.append(vinfo)
        guid = FindNextVolume(h)
    return found 
開發者ID:mbusb,項目名稱:multibootusb,代碼行數:38,代碼來源:win32.py

示例3: check_drives

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def check_drives():
	for drive in win32api.GetLogicalDriveStrings().split("\x00"):
		sys.stdout.write(".")
		type = win32file.GetDriveType(drive)
		if type == win32con.DRIVE_FIXED:
			fs = win32api.GetVolumeInformation(drive)[4]
			if fs == 'NTFS':
				warning = ""
				weak_perms = check_weak_write_perms(drive, 'directory')
				if weak_perms:
					# print "Weak permissions on drive root %s:" % drive
					# print_weak_perms('directory', weak_perms)
					sys.stdout.write(".")
					save_issue("WPC010", "writable_drive_root", weak_perms) 
			elif fs == 'FAT':
				save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (FAT does not support file permissions)" )
				sys.stdout.write("!")
			elif fs == 'FAT32':
				save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem  (FAT32 does not support file permissions)" )
				sys.stdout.write("!")
			else:
				warning = " (not NTFS - might be insecure)"
				save_issue_string("WPC011", "fat_fs_drives", "Fixed drive " + drive + ": has " + fs + " filesystem (Not NTFS - might not be secure)" )
				sys.stdout.write("!")

				 
			# print "Fixed drive %s has %s filesystem%s" % (drive, fs, warning)
			
	print 
開發者ID:51x,項目名稱:WHP,代碼行數:31,代碼來源:windows-privesc-check.py

示例4: get_local_drives

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def get_local_drives():
    """Returns a list containing letters from local drives"""
    drive_list = win32api.GetLogicalDriveStrings()
    drive_list = drive_list.split("\x00")[0:-1]  # the last element is ""
    list_local_drives = []
    for letter in drive_list:
        if win32file.GetDriveType(letter) == win32file.DRIVE_FIXED:
            list_local_drives.append(letter)
    return list_local_drives 
開發者ID:SekoiaLab,項目名稱:Fastir_Collector,代碼行數:11,代碼來源:utils.py

示例5: get_removable_drives

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def get_removable_drives():
    """Returns a list containing letters from removable drives"""
    drive_list = win32api.GetLogicalDriveStrings()
    drive_list = drive_list.split("\x00")[0:-1]  # the last element is ""
    list_removable_drives = []
    for letter in drive_list:
        if win32file.GetDriveType(letter) == win32file.DRIVE_REMOVABLE:
            list_removable_drives.append(letter)
    return list_removable_drives 
開發者ID:SekoiaLab,項目名稱:Fastir_Collector,代碼行數:11,代碼來源:utils.py

示例6: getFilesHash

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def getFilesHash():

	ret = []
	
    # List logical drives
	drives = win32api.GetLogicalDriveStrings().split('\x00')
	drives.pop()
	
    # Only get local dries
	drives = [ d for d in drives if win32file.GetDriveType(d)==win32file.DRIVE_FIXED ]
	
    # List files
	for drive in drives:
		hashRec(drive) 
開發者ID:CERT-W,項目名稱:certitude,代碼行數:16,代碼來源:getfiles_hash.py

示例7: getFiles

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def getFiles():

	ret = []
	
    # List logical drives
	drives = win32api.GetLogicalDriveStrings().split('\x00')
	drives.pop()
	
    # Only get local dries
	drives = [ d for d in drives if win32file.GetDriveType(d)==win32file.DRIVE_FIXED ]
	
    # List files
	for drive in drives:
		print os.popen('dir /s /b '+drive).read() 
開發者ID:CERT-W,項目名稱:certitude,代碼行數:16,代碼來源:getfiles.py

示例8: is_optical_drive

# 需要導入模塊: import win32file [as 別名]
# 或者: from win32file import GetDriveType [as 別名]
def is_optical_drive(self, drive_letter):
        '''
        @summary: Checks if the specified drive letter is an optical drive
        @param drive_letter: The letter of the drive to check
        @return: True if drive is an optical drive, otherwise false
        '''
        
        if win32file.GetDriveType('%s:' % drive_letter) == win32file.DRIVE_CDROM:
            return True
        else:
            return False 
開發者ID:sithis993,項目名稱:Crypter,代碼行數:13,代碼來源:Base.py


注:本文中的win32file.GetDriveType方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。