这里有"1。怎样把数字转换成二进制数字?"
http://feitsui.hyd.ncku.edu.tw/TLCheng/Basic/vbmath.htm
这里有"2。怎样检索磁盘的序列号???"
http://www.hosp.ncku.edu.tw/~cww/html/q00043.html
http://feitsui.hyd.ncku.edu.tw/TLCheng/Basic/vbmath.htm
这里有"2。怎样检索磁盘的序列号???"
http://www.hosp.ncku.edu.tw/~cww/html/q00043.html
http://feitsui.hyd.ncku.edu.tw/TLCheng/Basic/vbmath.htm
这里有"2。怎样检索磁盘的序列号???"
http://www.hosp.ncku.edu.tw/~cww/html/q00043.html
''
'' Converts Decimal to Binary
'' This uses the Quotient Remainder method
''
Dim Quot As Double
Dim Remainder As Double
Dim BinOut As String
Dim I As Integer
Dim NewVal As Double
Dim TempString As String
Dim TempVal As Double
Dim BinTemp As String
Dim BinTemp1 As String
Dim PosDot As Integer
Dim Temp2 As String
'' Check to see if there is a decimal point or not
''
If InStr(1, CStr(InputData), ".") Then
MsgBox "Only Whole Numbers can be converted", vbCritical
GoTo eds
End IfBinOut = ""
NewVal = InputData
DoAgain:'' Start the Calculations off
NewVal = (NewVal / 2)
'' If we have a remainder
If InStr(1, CStr(NewVal), ".") Then
BinOut = BinOut + "1"
'' Get rid of the Remainder
NewVal = Format(NewVal, "#0")
NewVal = (NewVal - 1)
If NewVal < 1 Then
GoTo DoneIt
End If
Else
BinOut = BinOut + "0"
If NewVal < 1 Then
GoTo DoneIt
End If
End If
GoTo DoAgainDoneIt:
MsgBox BinOut
BinTemp = ""'' Reverse the Result
For I = Len(BinOut) To 1 Step -1
BinTemp1 = Mid(BinOut, I, 1)
BinTemp = BinTemp + BinTemp1
Next IBinOut = BinTemp'' Output the Result
Dec2Bin = BinOut
eds:
End Function
3.这个例子是用来读取SCSI设备控制器的信息Computer = "MyMachineName"
Set SCSIs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").ExecQuery("Select * From Win32_SCSIController")
For Each mycard In SCSIs
MsgBox mycard.DeviceID
NextWin32_SCSIController类的详细信息,请查阅MSDN文章。4、列举所有的SCSI磁盘ID信息。Computer = "MyMachineName"
Set SCSIs = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & Computer & "\root\cimv2").ExecQuery("Select * From Win32_DiskDrive")
For Each mycard In SCSIs
MsgBox mycard.SCSITargetId
Next
MORE INFORMATION
===================
Windows Management Instrumentation (WMI) is the Microsoft implementation of Web-Based Enterprise Management (WBEM), which is an industry initiative to develop a standard technology for accessing management information in an enterprise environment. WMI uses the Common Information Model (CIM) industry standard to represent systems, applications, networks, devices, and other managed components in an enterprise environment. Applications that use WMI require Microsoft® Windows NT®/Windows® 2000, or Windows® 95/98. For information on which operating systems are required to use a particular API element, see the Requirements section of the documentation for the function, method, or property. -缺省情况下,Windows ME/2000是支持WMI的.如果要使你的系统支持WMI,请访问这个URL:http://msdn.microsoft.com/code/sample.asp?url=/msdn-files/027/001/576/msdncompositedoc.xml&frame=trueNOTE:上面的代码在Win2000下测试通过. 有些WMI类在不同的操作系统下有不同的支持和实现,具体情况还需参照MSDN文章
Public Function convDecToBin(ByVal curNumber As Currency) As String
On Error GoTo convDecToBin_end
Dim strBin As String
Dim i As Long For i = 64 To 0 Step -1 If Int(curNumber / (2 ^ i)) = 1 Then strBin = strBin & "1"
curNumber = curNumber - (2 ^ i) Else If strBin <> "" Then
strBin = strBin & "0"
End If End If Next convDecToBin = strBinconvDecToBin_end:
If Err <> 0 Or strBin = "" Then convDecToBin = "-E-"
Exit Function
End Function2.是这样的
private Const MAX_FILENAME_LEN = 256
Private Declare Function GetVolumeInformation& Lib "kernel32" Alias "GetVolumeInformationA" _
(ByVal lpRootPathName As String, ByVal pVolumeNameBuffer As String, _
ByVal nVolumeNameSize As Long, lpVolumeSerialNumber As Long, _
lpMaximumComponentLength As Long, lpFileSystemFlags As Long, _
ByVal lpFileSystemNameBuffer As String, ByVal nFileSystemNameSize As Long)Private Function GetSerialNumber(sDrive As String) As Long
Dim ser As Long
Dim s As String * MAX_FILENAME_LEN
Dim s2 As String * MAX_FILENAME_LEN
Dim i As Long
Dim j As Long
Call GetVolumeInformation(sDrive + ":\" & Chr$(0), s, MAX_FILENAME_LEN, ser, i, j, s2, MAX_FILENAME_LEN)
GetSerialNumber = ser
End Function