Click here to Skip to main content
15,887,485 members
Articles / Programming Languages / C#
Article

.NET Wrapper DLL for the WNet API

Rate me:
Please Sign up or sign in to vote.
2.74/5 (23 votes)
18 Aug 2003 101.9K   1.5K   24   11
A simple wrapper DLL containing most of the functions in the WNet API.

Introduction

This is a simple wrapper DLL to allow easier access to the WNet API from within the .NET environment.

The WNet API can be used to add/delete network connections (drive and printer mappings) as well as enumerate all devices and shares on the network (see MSDN for the full documentation).

Out of a total of 23 functions and seven structures, 17 functions and all structures are included in this version of the DLL.

The download contains source code for the DLL, which has XML documentation included. There is also a (very) simple sample application in order to demonstrate how to call the functions.

At the moment, the following functions still have not been wrapped.

  • WNetGetNetworkInformation
  • WNetGetProviderName
  • WNetGetResourceInformation
  • WNetGetReourceParent
  • WNetGetUniversalName
  • WNetRestoreConnectionW

Any feedback would be appreciated.

Email (make obvious replacements): nlinnett *at* integranetworks *dot* com.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 4 Pin
lowellsavage24-Jan-13 16:10
lowellsavage24-Jan-13 16:10 
Questionhow to test these classes Pin
baya328-May-08 8:46
baya328-May-08 8:46 
GeneralThank you Pin
sbsrazor23-May-08 15:53
sbsrazor23-May-08 15:53 
GeneralNice article Pin
Vikas Salvi24-May-06 21:23
Vikas Salvi24-May-06 21:23 
Generalnice, but need WNetGetNetworkInformation Pin
Princesse18-Jan-05 5:49
Princesse18-Jan-05 5:49 
Really nice, it's exaclty what I was searching for.

The only thing missing to fully feed my need is the WNetGetNetworkInformation function.

Here is what I want to do :

I have a network connection (ex. Z: pointing on \\server\Dir) that I want to redirect temporary on a local directory (ex. Z: pointing on \\Computer_Name\C$\Windows\Temp) and after some job redirect it again to its previous location (\\server\Dir).

When I unmap a connection without making it persistent, the API won't let me redirect it to another location. Consequently, I have to make the change persistent and if so, I cannot use the RestoreConnection function. Cry | :((

I want to be able to know where a drive connection where accessing before I change it, I suppose that the WNetGetNetworkInformation is the right API to use, but When I tried to add it to your class I had some problem with the Interfacing thing (kind of thing I'm not used to yet).

Is anybody can give me a quick method to get a path drive connection?
Or then, can you help me find my problem with my essaie?


Thanks in advance about everyting. Big Grin | :-D
GeneralRe: nice, but need WNetGetNetworkInformation Pin
Princesse18-Jan-05 6:02
Princesse18-Jan-05 6:02 
GeneralRe: nice, but need WNetGetNetworkInformation Pin
Princesse20-Jan-05 4:40
Princesse20-Jan-05 4:40 
GeneralNice Job Pin
Eric Rinn21-Dec-03 6:06
Eric Rinn21-Dec-03 6:06 
QuestionHow do you respond to the Author of these code submissions Pin
SilverKitty21-Aug-03 4:52
SilverKitty21-Aug-03 4:52 
Generalsuch a hi rating Pin
NormDroid19-Aug-03 20:19
professionalNormDroid19-Aug-03 20:19 
GeneralRe: such a hi rating Pin
Nish Nishant19-Aug-03 21:34
sitebuilderNish Nishant19-Aug-03 21:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.