Excel/Word/Access user log
It keeps a log (IP, TIME (local), NetworkUserName) of those that open the office document you put the code in. Example: Peter 7/29/2001 11:27:12 AM 172.19.20.22
AI
Podsumowanie AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Kod źródłowy
Public Function getstring(hkey As Long, strpath As String, strvalue As String)
Dim keyhand, datatype, lResult, lDataBufSize As Long
Dim strBuf As String
Dim intZeroPos As Integer
r = RegOpenKey(hkey, strpath, keyhand)
lResult = RegQueryValueEx(keyhand, strvalue, 0&, lValueType, ByVal 0&, lDataBufSize)
If lValueType = REG_SZ Then
strBuf = String(lDataBufSize, " ")
lResult = RegQueryValueEx(keyhand, strvalue, 0&, 0&, ByVal strBuf, lDataBufSize)
If lResult = ERROR_SUCCESS Then
intZeroPos = InStr(strBuf, Chr$(0))
If intZeroPos > 0 Then
getstring = Left$(strBuf, intZeroPos - 1)
Else
getstring = strBuf
End If
End If
End If
End Function
Public Function NetworkUserName() As String
Dim lpBuff As String * 25
Dim retval As Long
retval = GetUserName(lpBuff, 25)
NetworkUserName = Left(lpBuff, InStr(lpBuff, Chr(0)) - 1)
End Function
Public Function WorkstationID() As String
Dim sBuffer As String * 255
If GetComputerNameA(sBuffer, 255&) > 0 Then
WorkstationID = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1)
Else
WorkstationID = "?"
End If
End Function
Sub AUTO_Open()'put it in workbook_open in excel
ip = getstring(HKEY_LOCAL_MACHINE, "System\CurrentControlSet\Services\Class\NetTrans\0001", "ipaddress")
ActiveWorkbook.BuiltinDocumentProperties(5) = ActiveWorkbook.BuiltinDocumentProperties(5) + vbCr + NetworkUserName & " " & Now & " " & ip
End Sub
Oryginalne komentarze (3)
Odzyskane z Wayback Machine