unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,<br> StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br> WKSTA_USER_INFO_0 = record<br> wkui0_username
WideChar;<br> end;<br><br> PWKSTA_USER_INFO_0 = ^WKSTA_USER_INFO_0;<br><br> WKSTA_USER_INFO_1 = record<br> wkui1_username
WideChar;<br> wkui1_logon_domain
WideChar;<br> wkui1_oth_domains
WideChar;<br> wkui1_logon_server
WideChar;<br> end;<br><br> PWKSTA_USER_INFO_1 = ^WKSTA_USER_INFO_1;<br><br> function NetWkstaUserEnum( servername
WideChar; level
WORD; var bufptr
ointer;<br> prefmaxlen: DWORD; var entriesread, totalentries, resumehandle
WORD ): DWORD; cdecl;<br> external 'netapi32.dll' name 'NetWkstaUserEnum';<br><br> function NetApiBufferFree( bufptr
ointer ): DWORD; cdecl;<br> external 'netapi32.dll' name 'NetApiBufferFree';<br><br>var<br> Form1: TForm1;<br><br><br><br>implementation<br><br><br>{$R *.DFM}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> wui
WKSTA_USER_INFO_0;<br> dwPrefMaxLen
WORD;<br> dwEntriesRead
WORD;<br> dwTotalEntries
WORD;<br> dwResumeHandle
WORD;<br> rc: DWORD;<br>begin<br> dwPrefMaxLen := $FFFFFFFF;<br> dwEntriesRead := 0;<br> dwTotalEntries := 0;<br> dwResumeHandle := 0;<br><br> repeat<br> rc := NetWkstaUserEnum( nil, 0, pointer(wui), dwPrefMaxLen, dwEntriesRead,<br> dwTotalEntries, dwResumeHandle );<br><br> if (rc = 0) or (rc = ERROR_MORE_DATA) then begin<br><br> ShowMessage( wui.wkui0_username );<br><br> NetApiBufferFree( wui );<br> end;<br> until (rc <> 0) and (rc <> ERROR_MORE_DATA);<br><br>end;<br><br>end.<br>--<br>细节自己再修正, OK!