找回密码
 加入
搜索
查看: 5020|回复: 9

[系统综合] 如何判断一个盘符是第一块硬盘还是第几块硬盘?

  [复制链接]
发表于 2010-5-24 10:44:03 | 显示全部楼层 |阅读模式
本帖最后由 awfymwvf 于 2010-5-25 14:14 编辑

点击“判断”,提示这是第几块硬盘上的第几个分区,能实现吗?

在用了SETUPAPI。AU3之后,单独运行没事。加到我的程序中就会有如下的提示,我知道,在原贴中说是误报的,但是我实在是不想看到这个提示,有什么办法可以解决吗?

刚才又发现,用SETUPAPI。AU3。C盘得到的是0-1,而D盘就是0-3了,这是为什么呢,获取的值不对啊?

错误是
D:\autoit3\Include\LocalSecurityAuthority.au3(43,109) : ERROR: $SE_CREATE_TOKEN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CREATE_TOKEN_NAME") Then Global Const $SE_CREATE_TOKEN_NAME = "SeCreateTokenPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(44,128) : ERROR: $SE_ASSIGNPRIMARYTOKEN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_ASSIGNPRIMARYTOKEN_NAME") Then Global Const $SE_ASSIGNPRIMARYTOKEN_NAME = "SeAssignPrimaryTokenPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(45,106) : ERROR: $SE_LOCK_MEMORY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_LOCK_MEMORY_NAME") Then Global Const $SE_LOCK_MEMORY_NAME = "SeLockMemoryPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(46,115) : ERROR: $SE_INCREASE_QUOTA_NAME previously declared as a 'Const'
If Not IsDeclared("SE_INCREASE_QUOTA_NAME") Then Global Const $SE_INCREASE_QUOTA_NAME = "SeIncreaseQuotaPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(47,124) : ERROR: $SE_UNSOLICITED_INPUT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_UNSOLICITED_INPUT_NAME") Then Global Const $SE_UNSOLICITED_INPUT_NAME = "SeUnsolicitedInputPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(48,118) : ERROR: $SE_MACHINE_ACCOUNT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_MACHINE_ACCOUNT_NAME") Then Global Const $SE_MACHINE_ACCOUNT_NAME = "SeMachineAccountPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(49,83) : ERROR: $SE_TCB_NAME previously declared as a 'Const'
If Not IsDeclared("SE_TCB_NAME") Then Global Const $SE_TCB_NAME = "SeTcbPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(50,98) : ERROR: $SE_SECURITY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SECURITY_NAME") Then Global Const $SE_SECURITY_NAME = "SeSecurityPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(51,115) : ERROR: $SE_TAKE_OWNERSHIP_NAME previously declared as a 'Const'
If Not IsDeclared("SE_TAKE_OWNERSHIP_NAME") Then Global Const $SE_TAKE_OWNERSHIP_NAME = "SeTakeOwnershipPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(52,106) : ERROR: $SE_LOAD_DRIVER_NAME previously declared as a 'Const'
If Not IsDeclared("SE_LOAD_DRIVER_NAME") Then Global Const $SE_LOAD_DRIVER_NAME = "SeLoadDriverPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(53,115) : ERROR: $SE_SYSTEM_PROFILE_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SYSTEM_PROFILE_NAME") Then Global Const $SE_SYSTEM_PROFILE_NAME = "SeSystemProfilePrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(54,104) : ERROR: $SE_SYSTEMTIME_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SYSTEMTIME_NAME") Then Global Const $SE_SYSTEMTIME_NAME = "SeSystemtimePrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(55,132) : ERROR: $SE_PROF_SINGLE_PROCESS_NAME previously declared as a 'Const'
If Not IsDeclared("SE_PROF_SINGLE_PROCESS_NAME") Then Global Const $SE_PROF_SINGLE_PROCESS_NAME = "SeProfileSingleProcessPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(56,128) : ERROR: $SE_INC_BASE_PRIORITY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_INC_BASE_PRIORITY_NAME") Then Global Const $SE_INC_BASE_PRIORITY_NAME = "SeIncreaseBasePriorityPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(57,118) : ERROR: $SE_CREATE_PAGEFILE_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CREATE_PAGEFILE_NAME") Then Global Const $SE_CREATE_PAGEFILE_NAME = "SeCreatePagefilePrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(58,121) : ERROR: $SE_CREATE_PERMANENT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CREATE_PERMANENT_NAME") Then Global Const $SE_CREATE_PERMANENT_NAME = "SeCreatePermanentPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(59,92) : ERROR: $SE_BACKUP_NAME previously declared as a 'Const'
If Not IsDeclared("SE_BACKUP_NAME") Then Global Const $SE_BACKUP_NAME = "SeBackupPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(60,95) : ERROR: $SE_RESTORE_NAME previously declared as a 'Const'
If Not IsDeclared("SE_RESTORE_NAME") Then Global Const $SE_RESTORE_NAME = "SeRestorePrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(61,98) : ERROR: $SE_SHUTDOWN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SHUTDOWN_NAME") Then Global Const $SE_SHUTDOWN_NAME = "SeShutdownPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(62,89) : ERROR: $SE_DEBUG_NAME previously declared as a 'Const'
If Not IsDeclared("SE_DEBUG_NAME") Then Global Const $SE_DEBUG_NAME = "SeDebugPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(63,89) : ERROR: $SE_AUDIT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_AUDIT_NAME") Then Global Const $SE_AUDIT_NAME = "SeAuditPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(64,127) : ERROR: $SE_SYSTEM_ENVIRONMENT_NAME previously declared as a 'Const'
If Not IsDeclared("SE_SYSTEM_ENVIRONMENT_NAME") Then Global Const $SE_SYSTEM_ENVIRONMENT_NAME = "SeSystemEnvironmentPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(65,112) : ERROR: $SE_CHANGE_NOTIFY_NAME previously declared as a 'Const'
If Not IsDeclared("SE_CHANGE_NOTIFY_NAME") Then Global Const $SE_CHANGE_NOTIFY_NAME = "SeChangeNotifyPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(66,118) : ERROR: $SE_REMOTE_SHUTDOWN_NAME previously declared as a 'Const'
If Not IsDeclared("SE_REMOTE_SHUTDOWN_NAME") Then Global Const $SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(67,92) : ERROR: $SE_UNDOCK_NAME previously declared as a 'Const'
If Not IsDeclared("SE_UNDOCK_NAME") Then Global Const $SE_UNDOCK_NAME = "SeUndockPrivilege"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(130,89) : ERROR: $TOKEN_ADJUST_DEFAULT previously declared as a 'Const'
If Not IsDeclared("TOKEN_ADJUST_DEFAULT") Then Global Const $TOKEN_ADJUST_DEFAULT = 0x80
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(131,87) : ERROR: $TOKEN_ADJUST_GROUPS previously declared as a 'Const'
If Not IsDeclared("TOKEN_ADJUST_GROUPS") Then Global Const $TOKEN_ADJUST_GROUPS = 0x40
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(132,95) : ERROR: $TOKEN_ADJUST_PRIVILEGES previously declared as a 'Const'
If Not IsDeclared("TOKEN_ADJUST_PRIVILEGES") Then Global Const $TOKEN_ADJUST_PRIVILEGES = 0x20
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(133,94) : ERROR: $TOKEN_ADJUST_SESSIONID previously declared as a 'Const'
If Not IsDeclared("TOKEN_ADJUST_SESSIONID") Then Global Const $TOKEN_ADJUST_SESSIONID = 0x100
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(134,89) : ERROR: $TOKEN_ASSIGN_PRIMARY previously declared as a 'Const'
If Not IsDeclared("TOKEN_ASSIGN_PRIMARY") Then Global Const $TOKEN_ASSIGN_PRIMARY = 0x01
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(135,78) : ERROR: $TOKEN_DUPLICATE previously declared as a 'Const'
If Not IsDeclared("TOKEN_DUPLICATE") Then Global Const $TOKEN_DUPLICATE = 0x2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(137,82) : ERROR: $TOKEN_IMPERSONATE previously declared as a 'Const'
If Not IsDeclared("TOKEN_IMPERSONATE") Then Global Const $TOKEN_IMPERSONATE = 0x4
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(138,70) : ERROR: $TOKEN_QUERY previously declared as a 'Const'
If Not IsDeclared("TOKEN_QUERY") Then Global Const $TOKEN_QUERY = 0x8
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(139,85) : ERROR: $TOKEN_QUERY_SOURCE previously declared as a 'Const'
If Not IsDeclared("TOKEN_QUERY_SOURCE") Then Global Const $TOKEN_QUERY_SOURCE = 0x10
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(207,79) : ERROR: $GENERIC_READ previously declared as a 'Const'
If Not IsDeclared("GENERIC_READ") Then Global Const $GENERIC_READ = 0x80000000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(208,81) : ERROR: $GENERIC_WRITE previously declared as a 'Const'
If Not IsDeclared("GENERIC_WRITE") Then Global Const $GENERIC_WRITE = 0x40000000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(209,85) : ERROR: $GENERIC_EXECUTE previously declared as a 'Const'
If Not IsDeclared("GENERIC_EXECUTE") Then Global Const $GENERIC_EXECUTE = 0x20000000
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3\Include\LocalSecurityAuthority.au3(210,77) : ERROR: $GENERIC_ALL previously declared as a 'Const'
If Not IsDeclared("GENERIC_ALL") Then Global Const $GENERIC_ALL = 0x10000000
#include <GUIConstants.au3>
#include <WindowsConstants.au3>

dim $Form1,$check4

Opt("GUIOnEventMode", 1)
OnAutoItExitRegister("Quit")

$Form1=GUICreate ( "判断盘符测试", 484, 273,-1,-1,BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) 
GUISetOnEvent($GUI_EVENT_CLOSE, "quit")
GUISetState (@SW_SHOW,$Form1)

$check4=GUICtrlCreateCheckbox("判断F盘是第几块硬盘第几个分区", 20,235,300,25)
GUICtrlSetOnEvent($check4, "check4")

While 1
  Sleep(1000)
WEnd

Func check4()
        ;在这添加分区的信息的代码
EndFunc

Func Quit()
    GUISetState(@SW_HIDE)
    Exit
EndFunc
发表于 2010-5-24 13:02:36 | 显示全部楼层
這個我想知道
发表于 2010-5-24 13:18:21 | 显示全部楼层
#Include <WinAPIEx.au3>
_WinAPI_GetDriveGeometryEx
楼主可以参考下这个函数,不过这个几块好像没法确定
 楼主| 发表于 2010-5-24 16:20:20 | 显示全部楼层
这个函数。为什么我在UDF中找不到啊
发表于 2010-5-24 17:39:42 | 显示全部楼层
#include <SetupAPI.au3>

Const $tagDISK_NUMBER = "ulong DeviceType;ulong DeviceNumber;ulong PartitionNumber"

Local $tBuffer, $hDrive, $iDisk, $iPartition, $sDrive = "F:"

$tBuffer = DllStructCreate($tagDISK_NUMBER)
$hDrive = _CM_Create_File("\\." & $sDrive, $GENERIC_READ, 3, 0, 3, 0)
_CM_Device_IO_Control($hDrive, 0x2D1080, 0, 0, $tBuffer, 12)
$iDisk = DllStructGetData($tBuffer, "DeviceNumber") ; 0-based
$iPartition = DllStructGetData($tBuffer, "PartitionNumber") ; 1-based
_CM_Assign_Var($tBuffer, 0, _CM_Close_Handle($hDrive))

Msgbox(0, $sDrive, $iDisk & " -> " & $iPartition)
 楼主| 发表于 2010-5-24 18:12:03 | 显示全部楼层
版主好。为什么我运行你的代码会提示不能打开包含文件 <SetupAPI.au3>

我没有这个文件?
发表于 2010-5-24 18:52:18 | 显示全部楼层
发表于 2010-5-24 20:32:56 | 显示全部楼层
wmi试试
 楼主| 发表于 2010-5-25 08:02:58 | 显示全部楼层
本帖最后由 awfymwvf 于 2010-5-25 11:21 编辑

已测试通过。太强大了,但运行前出现了错误提示
发表于 2010-5-25 10:29:44 | 显示全部楼层
本帖最后由 sanhen 于 2010-5-25 10:31 编辑

回复 8# rikthhpgf2005


这是WMI的。以前工具用到的。
MsgBox(0,0,_Query(@HomeDrive))

Func _Query($Drive)
        Local $avArray,$i
        if Not StringRegExp($Drive,"^[a-zA-Z]\:+$") then Return SetError(0,1)
        $avArray =_PartitionToDisk()
        For $i=0 To UBound($avArray)-1
                If $avArray[$i][0]=$Drive Then Return $avArray[$i][1]
        Next
EndFunc

Func _PartitionToDisk()
        Local $objWMIService
        Local $objItem ,$colItems
        Local $Ret[1][2],$x=0
        Local $Part,$Disk
        $objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
        $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_LogicalDiskToPartition")
        For $objItem in $colItems
                if $x>0 Then ReDim $Ret[UBound($Ret) + 1][2]
                $Part=StringRegExp($objItem.Dependent,'(?i)deviceid="(.*)"+$',3)
                $Disk=StringRegExp($objItem.Antecedent,"(?i)disk.+?(\d)",3)
                $Ret[$x][0]=$Part[0]
                $Ret[$x][1]=$Disk[0]
                $x+=1
        Next
        Return $Ret
EndFunc
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 04:28 , Processed in 0.079988 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表