[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.sdk

How to call WNetOpenEnum and WNetEnumResource

Siegfried Heintze

10/1/2002 4:08:00 PM

(1) Are WNetOpenEnum and WNetEnumResource wrapped or do I have to use
PInvoke?

Since these are extremely slow functions (on a large network, they can take
a minute per function invocation), one would want to call them in a seperate
thread. However, these functions also require precious memory from
GlobalAlloc (does this function require PInvoke too?) so you don't want any
thread exiting prematurely without calling GlobalFree (because image rundown
won't give you this memory back).

(2) What function can I override to detect that the user wants to shut down
the GUI? I need a message handler for WM_NCDESTROY, for example. How can I
write any message handler in C#?
(3) In this function, how can I gracefully block until all the child threads
have successfully called GlobalFree? Since the child threads may have just
started a call to WNetEnumResource, it could be an entire minute until the
child thread receives the suicide note and can come back and respond that
suicide is complete. How can the main thread display a progress control that
is updated 10 times/second while it is responding to WM_NCDESTROY.
(4) How can I implement the child threads as a UI threads that check the
message pump for a custom message (such as a suicide note message) to
determine if the user wants to shut down before they are done enumerating
the network?



2 Answers

NETMaster

10/1/2002 4:21:00 PM

0

> (1) Are WNetOpenEnum and WNetEnumResource wrapped or do I have to use PInvoke?

If you can't use the .NET DirectoryServices namespace,
AFAIK you could use PInvoke like:
http://groups.google.com/groups?selm=uMfNxEwLCHA.2088%40t...


--
NETMaster (Thomas Scheidegger)
http://www.cetus-links.org/oo_c...


(Ping Zheng)

10/2/2002 7:46:00 AM

0

Hi,

As for the first problem, I did not find the managed class wich equal to
the WNetOpenEnum, so please use PInvoke. Please refer to the following link
to know detailed information of Interop:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/c...
l/cpconinteroperatingwithunmanagedcode.asp

(2) What function can I override to detect that the user wants to shut down
the GUI? I need a message handler for WM_NCDESTROY, for example. How can I
write any message handler in C#?

You can overload the "close" event. Please refer to the following ariticle
to know how to add the event
handler:http://msdn.microsoft.com/library/default.asp?url=/library...
on/html/vbtskCreatingEventHandlers.asp


(3) You can detect the thread ending the event handler.
Please refer to the following link to get the thread class information,
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/c...
l/cpconusingthreadsthreading.asp

This posting is provided "AS IS" with no warranties, and confers no rights.

George Zheng [MS]