Solved

NetServerEnum

Posted on 1998-12-09
8
221 Views
Last Modified: 2013-11-20
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
0
Comment
Question by:Amaresh080997
  • 4
  • 4
8 Comments
 
LVL 6

Accepted Solution

by:
stsanz earned 10 total points
ID: 1325957
Did you check that bufptr is a pointer to pointer parameter ?
0
 

Author Comment

by:Amaresh080997
ID: 1325958
Yes, It is a pointer to LPVOID...the return value is ERROR_MORE_DATA. But the bufptr is storing some junk values...Dont know why..
Thanks for your reply..
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1325959
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 ?

0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:stsanz
ID: 1325960
Are you on Win95/98 or WinNT ?
0
 

Author Comment

by:Amaresh080997
ID: 1325961
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...
0
 
LVL 6

Expert Comment

by:stsanz
ID: 1325962
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,(LPBYTE*)&psi101,sizeof (SERVER_INFO_101) * 6,
&entriesread,&totalentries,SV_TYPE_ALL,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.

0
 

Author Comment

by:Amaresh080997
ID: 1325963
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
0
 

Author Comment

by:Amaresh080997
ID: 1325964
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ODBC Connection Logging, ADO.NET 6 71
Replacement selected text 2 65
Named range not carried over 10 66
Way to decrease size of apk file 9 104
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question