hello again,
i refered your suggession and created one MFC application ....in which i m creating a button , a combo box a list box and some other control for my project.
1. what i did (achieved) is :
when i clicked the button the application is flooding the no of domains ,servers and the individual computers at a time in a sequence by a callback function NetServerEnum() (callback --->i think so till now not checked) & i m displaying in the list box. but my requirement is different in the following manner ....
2. my requirement is :
when i click the button the application should enumerate the no of domains first and should put in the combo box.then when i will select one of the domain from the combo , i should get the list of computers in that particular domain , which i want to show in the list box.
To build your project in UNICODE configuration:
Add UNICODE to "Project Setings\C/C++\Preprocessor definitions"
Type wWinMainCRTStartup in "Project Setings\Link\Output(category)\Entry-point symbol"
Other issues:
Add netapi32.lib to "Project Setings\Link\General(category)\Object/library modules".
Add the following includes in your source file:
#include <LMCONS.H>
#include <lmserver.h >
#include <LMERR.H>
However a sample project is attached here.
Last edited by ovidiucucu; January 30th, 2005 at 07:42 AM.
Quite nice the Send2 program that you have uploaded here (netblabla.zip).
But I have to report something:
It can send messages only to workstations from the primary domain.
Is this a bug, or a missing feature?
Last edited by marsh_pottaye; February 5th, 2004 at 09:06 AM.
Quite nice the Send2 program that you have uploaded here (netblabla.zip).
But I have to report something:
It can send messages only to workstations from the primary domain.
Is this a bug, or a missing feature?
It's a missing feature... Maybe I will implement it in version 2.0
Hi,
my program using NetServerEnum is not getting all of the workstations on the network the MSDN states:
ERROR_MORE_DATA More entries are available. Specify a large enough buffer to receive all entries.
So how do I specify a large enough buffer to get all the workstations??
Code:
LPSERVER_INFO_101 pBuf = NULL;
LPSERVER_INFO_101 pTmpBuf;
DWORD dwLevel = 101;
DWORD dwPrefMaxLen = MAX_PREFERRED_LENGTH;
DWORD dwEntriesRead = 0;
DWORD dwTotalEntries = 0;
DWORD dwTotalCount = 0;
DWORD dwServerType = SV_TYPE_WORKSTATION; // all workstations
DWORD dwResumeHandle = 0;
NET_API_STATUS nStatus;
LPCWSTR pszServerName = NULL;
LPCWSTR domain = (LPCWSTR)m_strDom.GetBuffer();
DWORD i;
// Call the NetServerEnum function to retrieve information
// for all workstations, specifying information level 101.
//
nStatus = NetServerEnum(pszServerName,
dwLevel,
(LPBYTE *) &pBuf,
dwPrefMaxLen,
&dwEntriesRead,
&dwTotalEntries,
dwServerType,
domain,
&dwResumeHandle);
//
// If the call succeeds,
//
if ((nStatus == NERR_Success) || (nStatus == ERROR_MORE_DATA))
{
if ((pTmpBuf = pBuf) != NULL)
{
//
// Loop through the entries and
// print the data for all server types.
//
for (i = 0; i < dwEntriesRead; i++)
{
ASSERT(pTmpBuf != NULL);
if (pTmpBuf == NULL)
{
break;
}
CString n = pTmpBuf->sv101_name;
GetListCtrl().InsertItem(i,n);
pTmpBuf++;
dwTotalCount++;
}
}
}
// Free the allocated buffer.
if (pBuf != NULL)
NetApiBufferFree(pBuf);
Best Regards,
--Zim
If you find this post useful, please rate it.
_________________________________ "Have you the brain worms?!?!?"
Well, in MSDN is stated that If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the data. Still returns ERROR_MORE_DATA?
with max_preferred_length set it NEVER returns ERROR_MORE_DATA.
it only returns ERROR_MORE_DATA if I change the value to greater than or less than max_preferred_length
either netserverenum is failing to return all workstations OR it only lists those workstations with someone logged onto them
In other words, it's not like reading the active directory which will return every workstation.
I found an undocumented function NetServerEnumEx which is supposed to return more workstations (the resume variable is not reserved in this function) but I couldn't get it to work. It kept reporting Linker errors, but I don't know why, NetServerEnumEx is in the same file as NetServerEnum!
And since it's undocumented, I don't know what additional libraries or files to include to make it work!!
Best Regards,
--Zim
If you find this post useful, please rate it.
_________________________________ "Have you the brain worms?!?!?"
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.