VB3 Connecting to a Network Drive by Using WNetAddConnectionLast reviewed: January 9, 1997Article ID: Q94679 |
The information in this article applies to:
- Microsoft Visual Basic programming system for Windows, versions 1.0, 2.0, and 3.0
SUMMARYWindows version 3.1 provides a new API Call, WNetAddConnection, which will redirect a local device to a shared resource or network server. WNetAddConnection requires the name of the local device, the name of the network resource, and the password necessary to use that resource. This article explains in detail the arguments and potential error messages for the Windows version 3.1 WNetAddConnection function call.
MORE INFORMATIONTo use WNetAddConnection within a Visual Basic application, declare the WNetAddConnection function in the General Declarations Section of your code window. (In Visual Basic version 1.0 you can also put the declaration in the Global Module.) Declare the function as follows entering the entire Declare statement on one, single line:
Declare Function WnetAddConnection% Lib "user" (ByVal lpszNetPath As Any, ByVal lpszPassword As Any, ByVal lpszLocalName As Any)Here are definitions for the formal parameters:
Formal Parameter Definition ----------------------------------------------------------------------- lpszNetPath Points to a null-terminated string specifying the shared device or remote server. lpszPassword Points to a null-terminated string specifying the network password for the given device or server. lpszLocalName Points to a null-terminated string specifying the local drive or device to be redirected. All lpszLocalName strings (such as LPT1) are case independent. Only the drive names A through Z and device names LPT1 through LPT3 are used.Below are the possible return values as defined on page 990 of the Microsoft Windows version 3.1 Programmer's Reference:
Value (Hex Value) Meaning ----------------------------------------------------------------------- WN_SUCCESS (&H0) Function was successful. WN_NOT_SUPPORTED (&H1) Function was not supported. WN_OUT_OF_MEMORY (&HB) System was out of memory. WN_NET_ERROR (&H2) An error occurred on the network. WN_BAD_POINTER (&H4) Pointer was invalid. WN_BAD_NETNAME (&H32) Network resource name was invalid. WN_BAD_LOCALNAME (&H33) Local device name was invalid. WN_BAD_PASSWORD (&H6) Password was invalid. WN_ACCESS_DENIED (&H7) A security violation occurred. WN_ALREADY_CONNECTED (&H34) Local device was already connected to a remote resource.Below is an example of how to redirect a local device to a network resource:
REFERENCES"Microsoft Windows Software Development Kit: Reference Volume 2," version 3.1 and the WIN31WH.HLP file that shipped with the Microsoft Visual Basic version 2.0 Professional Version for Windows.
|
KBCategory: kbnetwork kbprg kbcode
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |