Visual Basic Script


Как получить информацию об операционной системе при помощи WMI - часть 2


'получаем дату и время при помощи 'Win32_NetworkAdapterConfiguration 'и разделяем на компоненты даты и времени, возвращиемые в 'переменных leasedatepart и leasetimepart

Dim pos As Long Dim bias As Long

pos = InStr(leasedate, ".")

If pos > 0 Then

bias = StripTimeZoneBias(leasedate) leasedatepart = Left$(leasedate, 8) leasetimepart = Mid$(leasedate, 9, pos - Len(leasedatepart) - 1) leasedatepart = InsertInString(leasedatepart, "-", 5, "") leasedatepart = InsertInString(leasedatepart, "-", 8, "") leasetimepart = InsertInString(leasetimepart, ":", 3, "") leasetimepart = InsertInString(leasetimepart, ":", 6, "")

SplitDateTimeBias = bias

Else

End If

End Function

Private Function InsertInString(ByVal sOriginal As String, _ sReplace As String, _ nField As Long, _ sDelimeter As String) As String

Dim nCount As Long Dim nStart As Long Dim nLast As Long

Do While InStr(nStart + 1, sOriginal, sDelimeter) > 0

nStart = InStr(nStart + 1, sOriginal, sDelimeter) nCount = nCount + 1

If nCount >= nField Then Exit Do End If

nLast = nStart

Loop

Select Case nCount

Case 1 InsertInString = sReplace & Mid$(sOriginal, nStart)

Case Is >= nField InsertInString = Mid$(sOriginal, 1, nLast) & _ sReplace & Mid$(sOriginal, nStart) Case Else InsertInString = sOriginal & _ String$((nField - 1) - nCount, sDelimeter) & _ sReplace End Select

End Function

Private Function StripTimeZoneBias(leasedate As String) As Long

Dim pos As Long Dim tmp As String

pos = InStr(leasedate, "-")

If pos = 0 Then

pos = InStr(leasedate, "+")

If pos = 0 Then StripTimeZoneBias = 0 Else

End If

Else

tmp = Mid$(leasedate, pos, Len(leasedate)) leasedate = Mid$(leasedate, 1, pos - 1) StripTimeZoneBias = CLng(tmp)

End If

End Function

Private Sub wmiOperatingSystemInfo()

Dim wmiObjSet As SWbemObjectSet Dim obj As SWbemObject Dim msg As String Dim itmx As ListItem

'рабочие переменные для возвращаемых данных




Начало  Назад  Вперед



Книжный магазин