-
AutoIt
(
http://forum.oszone.net/forumdisplay.php?f=103)
Определить серийный номер устройства с которого запущен скрипт.
Собственно как определить серийник если устройство может быть как и флешка так и HDD ну и т.д. Спасибо!
|
Что подразумевается под «серийный номер устройства»? WMI, класс «Win32_LogicalDisk», свойство «VolumeSerialNumber», оно же «DriveGetSerial ()»?!
|
Centrinar,
Код:
#include <WinAPIEx.au3>
$sProcess = 'notepad.exe'
Run('notepad.exe', '', @SW_MINIMIZE)
Sleep(1000)
$PID = ProcessExists($sProcess)
If $PID Then
$sPath = _WinAPI_GetProcessFileName($PID)
$sDrive = _WinAPI_PathStripToRoot($sPath)
$sSerial = DriveGetSerial($sDrive)
MsgBox(64, 'Info', 'Процесс: ' & $sProcess & @LF & 'Путь: ' & $sPath & @LF & 'Диск: ' & _
$sDrive & @LF & '№: Диска ' & $sDrive & ' = ' & $sSerial)
ProcessClose($sProcess)
EndIf
WinAPIEx.au3
|
Centrinar, MsgBox(0, 'Это что ли?', DriveGetSerial(StringLeft(@ScriptDir, 2)))
|
Код:
#include <file.au3>
AutoItSetOption("MustDeclareVars", 1)
Local $sDrive, $sDir, $sFName, $sExt
_PathSplit(@ScriptFullPath, $sDrive, $sDir, $sFName, $sExt)
ConsoleWrite(Hex(Number(DriveGetSerial($sDrive))) & @CRLF)
Local $oFSO = ObjCreate("Scripting.FileSystemObject")
ConsoleWrite(Hex($oFSO.GetDrive($oFSO.GetDriveName(@ScriptFullPath)).SerialNumber) & @CRLF)
$oFSO = 0
Local $oSWbemLocator = ObjCreate("WbemScripting.SWbemLocator")
ConsoleWrite($oSWbemLocator.ConnectServer(".", "root\cimv2").Get("Win32_LogicalDisk.DeviceID='" & $sDrive & "'").VolumeSerialNumber & @CRLF)
$oSWbemLocator = 0
|
Можно просто hex сделать MsgBox(0, 'Это что ли?', Hex(DriveGetSerial(StringLeft(@ScriptDir, 2))))
|
Для не знающих, что значит HEX
|
Перевод числа в строку в шестнадцатеричной системе счисления.
Цитата:
Цитата Function Reference
Hex
Returns a string representation of an integer or of a binary type converted to hexadecimal.
|
|
Время: 21:24.
© OSzone.net 2001-