мои
<div class="sp-wrap"><div class="sp-head-wrap"><div class="sp-head folded clickable">5 копеек</div></div><div class="sp-body"><div class="sp-content"><!--shcode--><pre><code class='ls'>'WinAPI для определения windows имени пользователя и ip машины
Private Const LOG_MAX_IP = 5 'To make a buffer... i dont think you have more than 5 ip on your pc..
Private Const LOG_MAX_COMPUTERNAME_LENGTH = 31
Private Type LOG_IPINFO
dwAddr As Long ' IP address
dwIndex As Long ' interface index
dwMask As Long ' subnet mask
dwBCastAddr As Long ' broadcast address
dwReasmSize As Long ' assembly size
unused1 As Integer ' not currently used
unused2 As Integer '; not currently used
End Type
Private Type LOG_MIB_IPADDRTABLE
dEntrys As Long 'number of entries in the table
mIPInfo (LOG_MAX_IP) As LOG_IPINFO 'array of IP address entries
End Type
Private Type LOG_IP_Array
mBuffer As LOG_MIB_IPADDRTABLE
BufferLen As Long
End Type
Declare Private Sub LOG_CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, Byval Length As Long)
Declare Private Function LOG_GetIpAddrTable Lib "IPHlpApi" Alias "GetIpAddrTable" (pIPAdrTable As Byte, pdwSize As Long, Byval Sort As Long) As Long
Declare Private Function LOG_GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (Byval lpBuffer As String, nSize As Long) As Long
Declare Private Function LOG_GetComputerName Lib "kernel32" Alias "GetComputerNameA" (Byval lpBuffer As String, nSize As Long) As Long
Private Function INNER_Get_IP_List (log_IP_List () As String) As Boolean
On Error Goto errorHandler
INNER_Get_IP_List = False
Dim Ret As Long, Tel As Long
Dim bBytes () As Byte
Dim Listing As LOG_MIB_IPADDRTABLE
Dim t1 As LOG_IPINFO, t2, t3
Call LOG_GetIpAddrTable (Byval 0&, Ret, True)
If Ret <= 0 Then Exit Function
Redim bBytes (0 To Ret - 1) As Byte
'retrieve the data
Call LOG_GetIpAddrTable (bBytes(0), Ret, False)
'Get the first 4 bytes to get the entry's.. ip installed
Call LOG_CopyMemory (Listing.dEntrys, bBytes (0), 4)
Redim log_IP_List (Listing.dEntrys - 1)
For Tel = 0 To Listing.dEntrys - 1
t1 = Listing.mIPInfo (Tel)
t2 = bBytes (4 + (Tel * Len (Listing.mIPInfo (0))))
t3 = Len (Listing.mIPInfo (Tel))
Call LOG_CopyMemory (Listing.mIPInfo (Tel), bBytes (4 + (Tel * Len (Listing.mIPInfo (0)))), Len (Listing.mIPInfo(Tel)))
log_IP_List (Tel) = INNER_ConvertAddressToString (Listing.mIPInfo (Tel).dwAddr)
Next
INNER_Get_IP_List = True
ex:
Exit Function
errorHandler:
Call INNER_ProcessError (MODULE_NAME, Err, Error, Erl, Lsi_info (2), Lsi_info (12))
Resume ex
End Function
Private Function INNER_ConvertAddressToString (longAddr As Long) As String
Dim myByte (3) As Byte
Dim Cnt As Long
Call LOG_CopyMemory (myByte(0), longAddr, 4)
For Cnt = 0 To 3
INNER_ConvertAddressToString = INNER_ConvertAddressToString + Cstr (myByte (Cnt)) + "."
Next Cnt
INNER_ConvertAddressToString = Left$ (INNER_ConvertAddressToString, Len (INNER_ConvertAddressToString) - 1)
End Function[/CODE]
использовать аккуратно - можно повалить notes