lsq726 发表于 2010-3-27 16:58:58

求助怎么读取 系统里硬盘的名字?有图[已经解决谢谢热情的你们:)]

本帖最后由 lsq726 于 2010-3-27 18:58 编辑

AU3应该怎么可以读到?

afan 发表于 2010-3-27 17:00:21

DriveGetLabel("盘符")

lsq726 发表于 2010-3-27 17:14:23

DriveGetLabel("盘符")
afan 发表于 2010-3-27 17:00 http://www.autoitx.com/images/common/back.gif


    谢谢,不过无效无法获取磁盘名。只能获取磁盘卷标

afan 发表于 2010-3-27 17:31:49

回复 3# lsq726


    看错了…… 硬盘名称论坛有相关帖子:
http://www.autoitx.com/forum.php?mod=viewthread&tid=4050

lsq726 发表于 2010-3-27 17:43:19

回复lsq726


    看错了…… 硬盘名称论坛有相关帖子:
afan 发表于 2010-3-27 17:31 http://www.autoitx.com/images/common/back.gif

谢谢的确能很快的硬盘的名字。。

这里还有个问题请教。就是用这个只能列出一个硬盘的名字,如果有多个硬盘要怎么样可以全列出来?
===================
嘿嘿不好意思没看说明。说明里有介绍了。 太感谢了。AFAN。。谢谢你。

pusofalse 发表于 2010-3-27 17:45:58

#include <SetupAPI.au3>

Local $hDevs, $tDevInfo, $iIndex, $sDescr, $sDisks, $aDisk

$hDevs = _SetupDiGetClassDevs($DIGCF_PRESENT, "DiskDrive")
While _SetupDiEnumDeviceInfo($hDevs, $iIndex, $tDevInfo)
        $sDescr = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, 12)
        If ($sDescr = "") Then
                $sDescr = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, 0)
        EndIf
        $sDisks &= $sDescr & @LF
        $iIndex += 1
WEnd
_SetupDiDestroyDeviceInfoList($hDevs)
_SetupDiApiBufferFree($tDevInfo)

$aDisk = StringSplit(StringTrimRight($sDisks, 1), @LF)
_Arraydisplay($aDisk)

afan 发表于 2010-3-27 17:47:52


pusofalse 发表于 2010-3-27 17:45 http://www.autoitx.com/images/common/back.gif


    还是纯 Au3 的好啊~~~

afan 发表于 2010-3-27 17:49:21

回复 5# lsq726


    P版的不用Dll文件,更方便~ :face (29):

lsq726 发表于 2010-3-27 18:05:40


pusofalse 发表于 2010-3-27 17:45 http://www.autoitx.com/images/common/back.gif


    我怎么运行出错了?
D:\au3\au3安装程序\getinfo\test.au3(1,10) : ERROR: can't open include file <SetupAPI.au3>
#include <SetupAPI.au3>
~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(5,45) : WARNING: $DIGCF_PRESENT: 使用前并未进行声明.
$hDevs = _SetupDiGetClassDevs($DIGCF_PRESENT,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(5,45) : ERROR: $DIGCF_PRESENT: undeclared global variable.
$hDevs = _SetupDiGetClassDevs($DIGCF_PRESENT,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(5,58) : ERROR: _SetupDiGetClassDevs(): undefined function.
$hDevs = _SetupDiGetClassDevs($DIGCF_PRESENT, "DiskDrive")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(6,56) : ERROR: _SetupDiEnumDeviceInfo(): undefined function.
While _SetupDiEnumDeviceInfo($hDevs, $iIndex, $tDevInfo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(7,74) : ERROR: _SetupDiGetDeviceRegistryProperty(): undefined function.
      $sDescr = _SetupDiGetDeviceRegistryProperty($hDevs, $tDevInfo, 12)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(14,37) : ERROR: _SetupDiDestroyDeviceInfoList(): undefined function.
_SetupDiDestroyDeviceInfoList($hDevs)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(15,32) : ERROR: _SetupDiApiBufferFree(): undefined function.
_SetupDiApiBufferFree($tDevInfo)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(18,21) : ERROR: _Arraydisplay(): undefined function.
_Arraydisplay($aDisk)
~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3 - 8 error(s), 1 warning(s)
")
While _SetupDiEnumDeviceInfo($hDevs,

pusofalse 发表于 2010-3-27 18:08:27

回复 9# lsq726


    SetupAPI.au3 03/19/2010 - http://autoitx.com/forum.php?mod=viewthread&tid=10543&extra=page%3D1

masterpcc 发表于 2010-3-27 18:13:14

谢谢分享!!

afan 发表于 2010-3-27 18:17:23

本帖最后由 afan 于 2010-3-27 18:39 编辑

写着玩的,纯属娱乐……
;Local $iPid = Run('wmic DISKDRIVE get Caption', '', 0, 2), $Stdout
While 1
        Sleep(1)
        $Stdout &= StdoutRead($iPid)
        If @error Then ExitLoop
WEnd
MsgBox(0, '硬盘型号(名称)', StringRegExpReplace($Stdout, '(?s)Caption\s*?\n(.+?)\s+', '$1'));
没有多硬盘测试,多硬盘可能需要修改正则……

lsq726 发表于 2010-3-27 18:23:45

回复lsq726


    SetupAPI.au3 03/19/2010 -
pusofalse 发表于 2010-3-27 18:08 http://www.autoitx.com/images/common/back.gif

还是有错~~~
=============================================================


    D:\autoit3.3\Include\SetupAPI.au3(2,10) : ERROR: can't open include file <LocalSecurityAuthority.au3>
#include <LocalSecurityAuthority.au3>
~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2450,40) : WARNING: $SE_UNDOCK_NAME: 使用前并未进行声明.
        Local $aPriv = [[$SE_UNDOCK_NAME,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2450,67) : WARNING: $SE_LOAD_DRIVER_NAME: 使用前并未进行声明.
        Local $aPriv = [[$SE_UNDOCK_NAME, 2], [$SE_LOAD_DRIVER_NAME,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2778,50) : WARNING: $tagOBJECT_ATTRIBUTES: 使用前并未进行声明.
        $tBuffer = DllStructCreate($tagOBJECT_ATTRIBUTES,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5486,36) : WARNING: $GENERIC_READ: 使用前并未进行声明.
        $iAccessMask = bitOR($GENERIC_READ,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5486,52) : WARNING: $GENERIC_WRITE: 使用前并未进行声明.
        $iAccessMask = bitOR($GENERIC_READ, $GENERIC_WRITE)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5729,58) : WARNING: $SE_DEBUG_NAME: 使用前并未进行声明.
        Local $hToken, $fResult, $aPriv = [[$SE_DEBUG_NAME,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5730,21) : WARNING: $SE_RESTORE_NAME: 使用前并未进行声明.
                        [$SE_RESTORE_NAME,
                        ~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5731,20) : WARNING: $SE_BACKUP_NAME: 使用前并未进行声明.
                        [$SE_BACKUP_NAME,
                        ~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5734,22) : WARNING: $SE_SECURITY_NAME: 使用前并未进行声明.
                        [$SE_SECURITY_NAME,
                        ~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5735,28) : WARNING: $SE_TAKE_OWNERSHIP_NAME: 使用前并未进行声明.
                        [$SE_TAKE_OWNERSHIP_NAME,
                        ~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(5786,62) : WARNING: $ERROR_SUCCESS: 使用前并未进行声明.
        Return SetError($iResult, 0, $iResult = $ERROR_SUCCESS)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2450,40) : ERROR: $SE_UNDOCK_NAME: undeclared global variable.
        Local $aPriv = [[$SE_UNDOCK_NAME,
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2452,32) : ERROR: _OpenProcessToken(): undefined function.
        $hToken = _OpenProcessToken(-1)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2453,40) : ERROR: _AdjustTokenPrivileges(): undefined function.
        _AdjustTokenPrivileges($hToken, $aPriv)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2454,25) : ERROR: _LsaCloseHandle(): undefined function.
        _LsaCloseHandle($hToken)
        ~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2766,52) : ERROR: _LsaNtStatusToWinError(): undefined function.
        Return SetError(_LsaNtStatusToWinError($iResult)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(2775,54) : ERROR: _LsaInitializeObjectAttributes(): undefined function.
        $pObject = _LsaInitializeObjectAttributes($sPhysName)
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
D:\autoit3.3\Include\SetupAPI.au3(6211,22) : ERROR: _HeapFree(): undefined function.
                _HeapFree($pContext)
                ~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3(18,21) : ERROR: _Arraydisplay(): undefined function.
_Arraydisplay($aDisk)
~~~~~~~~~~~~~~~~~~~~^
D:\au3\au3安装程序\getinfo\test.au3 - 9 error(s), 11 warning(s)

pusofalse 发表于 2010-3-27 18:43:19

回复 13# lsq726


   ^_^ 对于这样的问题,我一般无视或者回答“不知道”~ - -||||

lsq726 发表于 2010-3-27 18:52:24

少个LocalSecurityAuthority.au3文件
我搜索了找不见有这个文件。。
页: [1] 2
查看完整版本: 求助怎么读取 系统里硬盘的名字?有图[已经解决谢谢热情的你们:)]