F
forza
Unregistered / Unconfirmed
GUEST, unregistred user!
为什么列举不出来尼?
procedure TForm1.Button4Click(Sender: TObject);
var
str : string;
NetApiStatus : integer;
servername,qualifier : pwidechar;
shareinfo : PShare_info_0;
lpBuffer : pointer;
entriesread, totalentries, resume_handle : integer;
counter : integer;
begin
str := '//'+edit2.Text;
getmem(servername,sizeof(widechar)*(length(str)+1));
stringtowidechar(str,servername,sizeof(char)*(length(str)+1));
repeat
NetApiStatus := NetShareEnum(servername, 2, lpBuffer, -1,entriesread, totalentries, resume_handle);
shareInfo := pShare_info_0(lpbuffer);
for Counter := 0 to EntriesRead - 1 do
begin
showmessage(widechartostring(shareInfo^.shi0_netname));
netapibufferfree(lpbuffer);
Inc(shareInfo);
end;
until (NetApiStatus <> ERROR_MORE_DATA);
end;
另外,我用下面的程序(截取了一段)
res := WnetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY,
RESOURCEUSAGE_CONNECTABLE, @NetResource,lphEnum);
count :=$ffffffff;
buffersize := 8192;
getmem(buf,buffersize);
res := WnetEnumResource(lphEnum,count,buf,buffersize);
Temp := TNetResourceArray(Buf);
For Ind := 0 to Count - 1 do
begin
showmessage(Temp^.lpRemoteName + 2);
inc(temp);
end;
这样获取的只有自己设定的共享文件夹,对默认共享如(IPC$,C$,ADMIN$)列举不出来,是不是我的参数设定有问题,请指教。
procedure TForm1.Button4Click(Sender: TObject);
var
str : string;
NetApiStatus : integer;
servername,qualifier : pwidechar;
shareinfo : PShare_info_0;
lpBuffer : pointer;
entriesread, totalentries, resume_handle : integer;
counter : integer;
begin
str := '//'+edit2.Text;
getmem(servername,sizeof(widechar)*(length(str)+1));
stringtowidechar(str,servername,sizeof(char)*(length(str)+1));
repeat
NetApiStatus := NetShareEnum(servername, 2, lpBuffer, -1,entriesread, totalentries, resume_handle);
shareInfo := pShare_info_0(lpbuffer);
for Counter := 0 to EntriesRead - 1 do
begin
showmessage(widechartostring(shareInfo^.shi0_netname));
netapibufferfree(lpbuffer);
Inc(shareInfo);
end;
until (NetApiStatus <> ERROR_MORE_DATA);
end;
另外,我用下面的程序(截取了一段)
res := WnetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY,
RESOURCEUSAGE_CONNECTABLE, @NetResource,lphEnum);
count :=$ffffffff;
buffersize := 8192;
getmem(buf,buffersize);
res := WnetEnumResource(lphEnum,count,buf,buffersize);
Temp := TNetResourceArray(Buf);
For Ind := 0 to Count - 1 do
begin
showmessage(Temp^.lpRemoteName + 2);
inc(temp);
end;
这样获取的只有自己设定的共享文件夹,对默认共享如(IPC$,C$,ADMIN$)列举不出来,是不是我的参数设定有问题,请指教。