Sorry tooo much cheese on that.
I found some VB code which I’m trying to convert to lotusscript to get the username of a someone logged into a remote computer.
I have declared the following functions:
Declare Function NetWkstaUserEnum Lib “netapi32.dll” (Byval strServerName As Unicode String, Byval dwLevel As Long, _
lpBuffer As Long, Byval dwPrefMaxLen As Long, lpdEntriesRead As Long, lpdTotalEntries As Long, _
lpdResumehandle As Long) As Long
Declare Function NetApiBufferFree Lib “netapi32.dll” (Byval pBuffer As Long) As Long
Declare Function NetApiBufferSize Lib “netapi32.dll” (lpBuffer As Any, lpLength As Long) As Long
Declare Sub CopyMem Lib “kernel32.dll” Alias “RtlMoveMemory” (pTo As Any, uFrom As Any, Byval lSize As Long)
Declare Function lstrlenW Lib “kernel32.dll” (Byval lpString As Long) As Long
The first three I know I’ll need to use. I’m not sure what the last two are for.
So far I have the following:
Sub Initialize
Dim lngReturn As Long, lngBuffer As Long, lngEntriesRead As Long, lngTotalEntries As Long, lngResumeHandle As Long
Dim intCount As Integer
Dim strHostName As String * 255
Dim results As String
strHostName="56.9.0.23" & Chr(0) ' add null character to string.
lngReturn = NetWkstaUserEnum(strHostName, 0, lngBuffer, -1, lngEntriesRead, lngTotalEntries, lngResumeHandle)
If lngReturn=NERR_Success Then
Msgbox "API Call Successfull: " & lngEntriesRead & " entries read of " & lngTotalEntries & " total entries."
'>> Need to get at lngBuffer here.
If lngBuffer Then
Msgbox "Clearing buffer."
Call NetApiBufferFree(Byval lngBuffer)
End If
Else
Msgbox "API Call failed."
End If
End Sub
My call works and my message boxes tell me I’m getting results. Problem is I can’t figure out how to read from lngBuffer.
Microsofts description of the function describe it as "Pointer to the buffer that receives the data. The format of this data depends on the value of the level parameter. "
Obviously I’m not too familar with VB or calling C functions so any tips would be wonderful.
There is an example in the help where they declare the function as I have (returns value to a pointer) and just place a fixed length string in the call but it doesn’t seem right to me and I can’t make it work (type mismatch errors).