为什么我定义NetUserGetGroups出错哦?<br><br>调用的时候出现内存访问错误哦<br><br>有没有高手留个msn让我骚扰骚扰阿<br><br>type GROUP_USERS_INFO_1=record<br>grui1_name:LPWSTR;<br>grui1_attributes
WORD;<br>end;<br> lpGROUP_USER_INFO_1=^GROUP_USERS_INFO_1;<br>function NetUserGetGroups(<br> servername
WideChar;<br> username
WideChar;<br> level:dword;<br> var bufptr
ointer;<br> prefmaxlen:dword;<br> entriesread:dword;<br> totalentries:dword<br>):LongWord; stdcall; external 'netapi32.dll';<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> EntiesRead: DWORD;<br> TotalEntries: DWORD;<br> UserInfo: lpUSER_INFO_3;<br> lpBuffer: Pointer;<br> ResumeHandle: DWord;<br> Counter,j: Integer;<br> NetApiStatus: LongWord;<br><br> GroupInfo:lpGROUP_USER_INFO_1;<br> lpGbuffer
ointer;<br> Gentiesread:dword;<br> Gtotalentries:dword;<br> GNetApiStatus: LongWord;<br><br> outstring:string;<br>begin<br>memo1.Lines.Text:='';<br> ResumeHandle := 0;<br> Gentiesread:=0;<br> Gtotalentries:=0;<br> repeat<br>// NetApiStatus := NetUserEnum(PChar('//NT-Domain'), 1, 0, lpBuffer, 0,EntiesRead, TotalEntries, ResumeHandle);<br> NetApiStatus := NetUserEnum(nil, 3, 0, lpBuffer, 0, EntiesRead,TotalEntries, ResumeHandle);<br> UserInfo := lpBuffer;<br><br> for Counter := 0 to EntiesRead - 1 do<br> begin<br> outstring:=WideCharToString(UserInfo^.usri3_name) + ' --> ' +WideCharToString(UserInfo^.usri3_comment) + ' --> ' +intToStr(UserInfo^.usri3_primary_group_id )+ ' --> ';<br> repeat<br> showmessage( UserInfo^.usri3_name);<br> GNetApiStatus:=NetUserGetGroups(nil,UserInfo^.usri3_name,1,lpGbuffer,MAXLONGINT,Gentiesread,Gtotalentries);<br> GroupInfo:=lpGbuffer;<br> for j:=0 to gentiesread-1 do<br> begin<br> outstring:=outstring +WideCharToString(GroupInfo^.grui1_name) ;<br> Inc(GroupInfo);<br> end;<br><br> Inc(UserInfo);<br> NetApiBufferFree(lpGbuffer);<br> until (GNetApiStatus <> ERROR_MORE_DATA);<br> memo1.Lines.Add(outstring); <br> end;<br><br> NetApiBufferFree(lpBuffer);<br> until (NetApiStatus <> ERROR_MORE_DATA);<br>{*<br> repeat<br>// NetApiStatus := NetUserEnum(PChar('//NT-Domain'), 1, 0, lpBuffer, 0,EntiesRead, TotalEntries, ResumeHandle);<br> NetApiStatus := NetUserEnum(nil, 1, 0, lpBuffer, 0, EntiesRead,TotalEntries, ResumeHandle);<br> UserInfo := lpBuffer;<br><br> for Counter := 0 to EntiesRead - 1 do<br> begin<br> memo1.Lines.Add(WideCharToString(UserInfo^.usri1_name) + ' --> ' +<br>WideCharToString(UserInfo^.usri1_comment) + ' --> ' +<br>WideCharToString(UserInfo^.usri1_home_dir))<br>;<br> Inc(UserInfo);<br> end;<br><br> NetApiBufferFree(lpBuffer);<br> until (NetApiStatus <> ERROR_MORE_DATA);<br>}<br>end;