We have entered a partnership with VBXtras to provide many development tools available for sale on our web site. For a limited time we are offering a FREE one year subscription for anyone who purchases any products through our web site. If you are currently shopping for some cool tools, check out http://www.codeoftheweek.com/catalog.html
This area is new and does not yet have all products online. If there is something particular you are looking for (and can't find it on our site), please let us know. We probably can get it for you at a great price!
If you are interested in advertising in COTW please email us at sponsor@codeoftheweek.com Our rates are VERY reasonable, actually they are almost FREE. We reach over three thousand Visual Basic developers each week.
The source code in this issue is designed for Visual Basic 5.0 and higher. It will probably work in VB4 32-bit with some minor changes.
This issue adds to the class module we introduced last week for manipulating network connections and retrieving the login name. This issue shows how to manually connect or disconnect from network resources. We have also included some better error handling that will complement the error handling found in the issue from last week.
You might have seen the dialogs built into Windows 95/NT for making and removing network connections. This class makes the necessary calls to the Networking API to show those dialogs. These functions will only work under Windows 95 and Windows NT. They depend on a DLL called MPR.DLL which should exists on all 95/NT systems that have networking installed. To connect to network resources we use the API function WNetAddConnection. To disconnect from network resources we use the API function WNetCancelConnection.
Public Function ConnectResource(sLocalName As String, sRemoteName As String, sPassword As String) Public Function DisconnectResource(sLocalName As String, Optional bForce As Boolean = False)
Nothing is returned upon a successful call. If an error occurs it is raised to the caller.
A couple of examples are shown below.
Dim Network as New cNetworkInterface Network.ConnectResource "T:", "\\P120\APPS2", "" Network.DisconnectResource "T:" Network.ConnectResource "LPT2:", "\\P120\HP4L", "pass" Network.DisconnectResource "LPT2:"
The first connect will connect the T: drive to the network resource called \\P120\APPS2. The second connect will connect the LPT2 port to the network printer called \\P120\HP4L using the password "pass"
To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0028.html
We have entered a partnership with VBXtras to provide many development tools available for sale on our web site. For a limited time we are offering a FREE one year subscription for anyone who purchases any products through our web site. If you are currently shopping for some cool tools, check out http://www.codeoftheweek.com/catalog.html
This area is new and does not yet have all products online. If there is something particular you are looking for (and can't find it on our site), please let us know. We probably can get it for you at a great price!
That concludes this issue of COTW. We hope you find the source code useful in your development.
The below describes the ways you can supply us some feedback about COTW. We would like to see our members help mold COTW into the best Visual Basic source code resource available. But to do that we need your feedback about what you like and what you do not like about COTW.
If you are interested in advertising in COTW please email us at sponsor@codeoftheweek.com Our rates are VERY reasonable, actually they are almost FREE. We reach over three thousand Visual Basic developers each week.
If you have any suggestions for topics you would like to see covered or questions about this issue, please email them to info@codeoftheweek.com or use online feedback form at http://www.codeoftheweek.com/feedback.html.
If you have any source code you would like to submit for possible inclusion in COTW, please fill out our online submission form at http://www.codeoftheweek.com/submission.html.
Thank you for trying Code of the Week for Visual Basic.
Your free trial expires after you receive your fourth issue. If you want to continue to receive Code of the Week you can get 52 issues of COTW for only $19.95. This is a full year of Visual Basic source code and information to help with all your development. So don't wait, subscribe now! The quickest way to subscribe is to jump to our online order form at http://www.codeoftheweek.com/order.html