Amaresh080997
asked on
NetServerEnum
Have any of you used the call "NetServerEnum"? If so, can you please provide me with a code snippet? Here when I use it, the parameters "entriesread" and "totalentries" read sensible value, but the bufptr reads some junk(strange characters). I am using SERVER_INFO_101 structure in my call. Can any of you throw some light in this? A code snippet would be very useful..
Thanks and Regards
Amaresh
Thanks and Regards
Amaresh
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you set prefmaxlen parameter to at least sizeof(SERVER_INFO_101) on input ?
What are the values of entriesread and totalentries parameters on output ?
What are the values of entriesread and totalentries parameters on output ?
Are you on Win95/98 or WinNT ?
ASKER
totalentries = 81 and entriesread = 8. I am using Win NT4.0.
Yes, I think my prefmaxlen parameter is okay..set to some high value..
Thanks for your reply...
Yes, I think my prefmaxlen parameter is okay..set to some high value..
Thanks for your reply...
I have managed to get a correct server enumeration on my net using the following piece of code :
{
NET_API_STATUS nas ;
SERVER_INFO_101 *psi101 ;
DWORD entriesread,totalentries ;
char sz[300] ;
nas = NetServerEnum(NULL,101,(LP BYTE*)&psi 101,sizeof (SERVER_INFO_101) * 6,
&entriesread,&totalentries ,SV_TYPE_A LL,NULL,0) ;
wsprintf(sz,"nas=%d entriesread=%d totalentries=%d servername1=%ls servername2=%ls", (int)nas, (int)entriesread, (int)totalentries, (LPWSTR)psi101->sv101_name , (LPWSTR)(psi101+1)->sv101_ name) ;
}
I get :
nas=ERROR_MORE_DATA
entriesread=2
totalentries=6
and servername1 and servername2 indicate two of my servers name.
Please check that you access the SERVER_INFO_101 structure fields with the right syntax, and that you process sv101_name field as a UNICODE string. You should also try to set prefmaxlen to a multiple of sizeof(SERVER_INFO_101)
Hope this helps.
{
NET_API_STATUS nas ;
SERVER_INFO_101 *psi101 ;
DWORD entriesread,totalentries ;
char sz[300] ;
nas = NetServerEnum(NULL,101,(LP
&entriesread,&totalentries
wsprintf(sz,"nas=%d entriesread=%d totalentries=%d servername1=%ls servername2=%ls", (int)nas, (int)entriesread, (int)totalentries, (LPWSTR)psi101->sv101_name
}
I get :
nas=ERROR_MORE_DATA
entriesread=2
totalentries=6
and servername1 and servername2 indicate two of my servers name.
Please check that you access the SERVER_INFO_101 structure fields with the right syntax, and that you process sv101_name field as a UNICODE string. You should also try to set prefmaxlen to a multiple of sizeof(SERVER_INFO_101)
Hope this helps.
ASKER
Thanks stsanz...The mistakes I was doing are 1) Wrong value for servertype, 2) casting (LPBYTE*) to pserverinfo (instead of &pserverinfo) and not reading the sv101_name as unicode..I did not read that part of online help carefully..I went through again and it was okay...Thankyou very much..
Regards
Amaresh
Regards
Amaresh
ASKER
I am sorry abt a mistake in my previous remark..The bufptr that I was passing was okay..I was passing the pointer to pointer paramater..But II committed a mistake in the servertype and while reading the sv101_name..
Thanks for your info ..
Regards
Amaresh
Thanks for your info ..
Regards
Amaresh
ASKER
Thanks for your reply..