|
This works fine for me:
bool GetResources( NETRESOURCE *pNetResource )
{
DWORD dwResult;
NETRESOURCE *NetResource = NULL;
HANDLE hEnum;
dwResult = WNetOpenEnum(RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, pNetResource, &hEnum);
if (NO_ERROR == dwResult)
{
NETRESOURCE Buffer[750];
DWORD Count = 0xFFFFFFFF,
BufferSize;
BufferSize = sizeof(Buffer);
do
{
dwResult = WNetEnumResource(hEnum, &Count, &Buffer, &BufferSize);
if (NO_ERROR == dwResult || ERROR_MORE_DATA == dwResult)
{
for (UINT i = 0; i < Count; i++)
{
if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_DOMAIN)
cout << "Domain ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_SERVER)
cout << "Server ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_SHARE)
cout << "Share ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_GROUP)
cout << "Group ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_NETWORK)
cout << "Network ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_ROOT)
cout << "Root ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_SHAREADMIN)
cout << "ShareAdmin ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_TREE)
cout << "Tree ";
else if (Buffer[i].dwDisplayType == RESOURCEDISPLAYTYPE_NDSCONTAINER)
cout << "NDS ";
else
cout << "Unknown ";
cout << Buffer[i].lpRemoteName << endl;
if ((Buffer[i].dwUsage & RESOURCEUSAGE_CONTAINER) == RESOURCEUSAGE_CONTAINER)
GetResources(&Buffer[i]);
}
}
} while (NO_ERROR == dwResult || ERROR_MORE_DATA == dwResult);
dwResult = WNetCloseEnum(hEnum);
}
return true;
}
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I am trying to get the list of domains AND LIST OF COMPUTERS under each domain.
I am getting domains when I use the parameter RESOURCE_GLOBALNET in WNetOpenEnum.
I am getting list of only computers when I use the parameter RESOURCE_CONTEXT in WNetOpenEnum.
But my requirement is I would like to get computers under each domain.
How should I achive this .This is the code.Pls tell me where I am going wrong.
NETRESOURCE res[10];
HANDLE hMain;
int x,y,i;
DWORD dwCnt = 0xffffffff;
DWORD dwSize;
DWORD dwRes;
dwRes = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0,
NULL, &hMain);
dwSize = sizeof (res);
if (WNetEnumResource (hMain, &dwCnt, res, &dwSize) == NO_ERROR)
{
HANDLE hEnum;
dwRes = WNetOpenEnum (RESOURCE_GLOBALNET, RESOURCETYPE_ANY, 0, res,&hEnum);
while (dwRes == NO_ERROR || dwRes == ERROR_MORE_DATA)
{
dwCnt = 9;
dwSize = sizeof (NETRESOURCE) * 10;
dwRes = WNetEnumResource (hEnum, &dwCnt, res, &dwSize);
if (dwRes != ERROR_NO_MORE_ITEMS)
{
for ( i = 0; i < dwCnt; i++)
{
if (res[i].lpLocalName != NULL || res[i].lpRemoteName!= NULL)
{
//MessageBox(0,res[i].lpLocalName,res[i].lpRemoteName,0);
//Add this in to a list box. SendMessage (hwndList, LB_ADDSTRING, 0, (LPARAM)res[i].lpRemoteName) ;
}
}
}
WNetCloseEnum (hEnum);
}
WNetCloseEnum (hMain);
Pls guide
|
|
|
|
|
I have a base class that I have a copy construtor for, since I have dynamically allocated memory etc.
If I add a CList to my base class definition, and add the copying code to my base class copy constructor, do I need to also do the copying in my derived class??
class Msg
{ char *pszTst;
CList myList;
}
class tstMsg : public msg
{ }
msg::msg (const Msg &i_MsgToCopyFrom)
{
POSITION pos;
CIVAttrib attr, *pAttr;
if (i_MsgToCopyFrom.mCleanMsgBuffer != NULL)
{
mCleanMsgBuffer = new BYTE [i_MsgToCopyFrom.mCleanMsgBuffSize];
if (mCleanMsgBuffer != NULL)
memcpy (mCleanMsgBuffer, i_MsgToCopyFrom.mCleanMsgBuffer, i_MsgToCopyFrom.mCleanMsgBuffSize);
}
else
mCleanMsgBuffer = NULL;
pos = i_MsgToCopyFrom.myList.GetHeadPosition();
for (int i=0;i < i_MsgToCopyFrom.myList.GetCount();i++)
{
attr = myList.GetNext(pos);
pAttr = new CIVAttrib;
if (pAttr != NULL)
{
*pAttr = attr;
myList.AddTail(pAttr);
}
}
}
when i have a function call foo (tstMsg i_msg), will the copy constructor defined in the base class be called as well as the copy constructor of the derired class??
Thanks.
-C
|
|
|
|
|
no, it can't, how would it know how to initialise the object from the derived class ?
you must provide in the derived class a new copy constructor.
TOXCCT >>> GEII power
|
|
|
|
|
No.. i meant if i made a call foo (tstMsg i_msg), would this call both the derived and the base class copy constructors??
|
|
|
|
|
you could define such constructor (see my following post to understand where these types come from) :
Manager::Manager(<font style="color:blue;">const</font> string& n, <font style="color:blue;">int</font> d, <font style="color:blue;">int</font> lvl)
: Employee(n, d), <font style="color:green;">
level(lvl) <font style="color:green;">
{
<font style="color:green;">
}
TOXCCT >>> GEII power
|
|
|
|
|
i quote you the related chapter from the "C++ Language" (chapter §12.2.3). for that, we consider we have the following classes :
<font style="color:blue;">class</font> Employee {
string first_name, family_name;
<font style="color:blue;">short </font>department;
<font style="color:green;">
<font style="color:blue;">public</font>:
Employee(<font style="color:blue;">const</font> string& n, <font style="color:blue;">int </font>d); <font style="color:green;">
<font style="color:green;">
};
<font style="color:blue;">class</font> Manager : <font style="color:blue;">public</font> Employee {
set<Employee*> group;
<font style="color:blue;">short </font>level;
<font style="color:green;">
<font style="color:blue;">public</font>:
Manager(<font style="color:blue;">const </font>string& n, <font style="color:blue;">int </font>d, <font style="color:blue;">int </font>lvl);
<font style="color:green;">
};
"the copy:
Classes objects copy is defined by the copy constructor and also by the affectations. Watch the following code :
<font style="color:blue;">void</font> f(<font style="color:blue;">const</font> Manager& m) {
Employee e = m; <font style="color:green;">
e = m; <font style="color:green;">
}
Only the Employee of Manager is copied, because the copy functions of Employee don't know anything from Manager. That is commonly called slicing. That can be a source of surprises and mistakes. One of the reasons we transmit pointers to and references of objects into a hierarchy is precisely to avoid that operations. Polymorphic behavior safeguarding and efficiency improvement are other ones".
hope this will help...
TOXCCT >>> GEII power
|
|
|
|
|
So its not possible?? or do I need to do something else explicit within my copy constructor in my derived class?? How do I explicitly call the base class copy constructor when the derived copy constructor is called??
Maybe I"m not getting it.
-C
|
|
|
|
|
Correct. You need to explicitly copy the base class in the copied object's derived class. The base class default constructor is called before the derived class copy constructor.
In summation, a call to the derived class copy constructor does not call the base class copy constructor. Instead, the default constructor is called in the base class.
Kuphryn
|
|
|
|
|
Wheatbread wrote:
How do I explicitly call the base class copy constructor when the derived copy constructor is called??
like this... (see upper this post)
TOXCCT >>> GEII power
|
|
|
|
|
Thanks alot man!! Something so simple just seemed to confuse me!!
-C
|
|
|
|
|
Hi, I'm using MS VC++ 6.0. I have a dialog box with 255 edit boxes, so I had to add them dynamically in the code since the editor can only handle 255 controls total. Now I have to assign them ID's so I can use UpdateData and the Message map. I gave them ID's 200-455 because that didn't conflict with anything that'd been done automatically in Resource.h. That worked fine for the Message map, but when I tried to put it in DoDataExchange it violated the assertion: no data exchange control with ID 0x%04. Does this mean that I've chosen invalid numbers to use? The numbers generated in recourse.h seem to follow a pattern, but I can't figure out what it is to mimic it. What numbers would be valid to use? Thank you.
|
|
|
|
|
brettslote wrote:
I have a dialog box with 255 edit boxes,
I hope I never have to use your software ...
The other thing, are you sure you don't have conflicting IDs ? or are you sure you're using the good IDs ? the assertion seems to think that ( from CDataExchange::PrepareCtrl )
The resource IDs are sequential, no "real" patterns; I think that the upper limit is 32767 ( or something close to that )
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
|
Step through each statement in the DoDataExchange() function until you find the one that asserts.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
how to disable messager service?
thanks.
|
|
|
|
|
If you look at OpenSCManager() , OpenService() and ControlService() it should put you in good stead!
Ant.
|
|
|
|
|
Thanks!
schService = OpenService(
schSCManager, // SCM database
"Sample_Srv", // service name
SERVICE_ALL_ACCESS);
but what is the service name of messenger service?
sdfsdfffffffffffffffffffffffasdf
|
|
|
|
|
Messenger
Ant.
|
|
|
|
|
..Oh BTW if you are looking for service names:
1) Open RegEdit
2) Look under the registry key
HKLM\System\CurrentControlSet\Services
You will find them all listed in there.
Ant.
|
|
|
|
|
thx very much
;)
sdfsdfffffffffffffffffffffffasdf
|
|
|
|
|
Hi all,
I have a program written in Delphi that broadcats a window message.
I have manage to read this message using Delphi code using the RegisterWindowMessage function, Delphi's TApplicationEvents component OnMessage function with great succes.
Now I want to read this same message using my beloved Visual C++ code.
Where do I start?
Thanks
|
|
|
|
|
louis wrote:
Now I want to read this same message using my beloved Visual C++ code.
Just provide a message handler for the message that is being broadcast. Put the handler in between BEGIN_MESSAGE_MAP() and END_MESSAGE_MAP() .
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Thanks,
I have done so. That part works.
I am still not able to update my listview with the new data. The program gives an application error.
One more question. How do I read the handle of the application.
Thanks again.
Cheers
|
|
|
|
|
louis wrote:
I am still not able to update my listview with the new data.
What does the code look like that is doing the updating?
louis wrote:
The program gives an application error.
And that error would be?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|