Tutorials to .com

Tutorials to .com » Software » Vfp » Visual FoxPro how to add and remove the network connection

Visual FoxPro how to add and remove the network connection

Print View , by: iSee ,Total views: 64 ,Word Count: 1219 ,Date: Sat, 18 Apr 2009 Time: 6:38 PM

Outlined in the foxpro for Windows 2.x and Foxtools.fll with Visual FoxPro in DECLARE DLL command using the definition of the relevant Windows API (Application Programming Interface) function, you can add and remove FoxPro networks.
Only continue to support the Visual FoxPro control FOXTOOLS as a backward-compatible database, DECLARE commands to call DLL function is the better way.

For more information, including the following sections FoxPro 2.x and Visual FoxPro usage agreement.

FoxPro 2.x
FOXTOOLS used in FoxPro 2.x database, follow the steps below to add and remove network connections.

Loading database with the following command:

Register you want to call the Windows API function. Under the present circumstances is that we need to WNetAddConnection () and WNetCancelConnection ().

addconn = RegFn ( 'WNetAddConnection', 'CCC', 'I')
delconn = RegFn ( 'WNetCancelConnection', 'CI', 'I')

To connect to the network equipment, issued the following command:

= CallFn (addconn, "\ \ SERVER \ SHARE", "password", "<drive>:")

To be disconnected from the network, released the following command:

= CallFn (delconn, "<drive>:", 0)

Visual FoxPro
DECLARE DLL command using the definition of the DLL function to call:

**-- DLL definition
Declare integer WNetAddConnection in WIN32API string, string, string Declare integer Declare integer WNetCancelConnection in WIN32API String, integer

Add a network connection **--
= WNetAddConnection ( "\ \ SERVER \ SHARE", "", "DriveLetter:")

**-- Remove the network connection
= WNetCancelConnection ( "DriveLetter:", 0)

The following information provides API calls to the two additional reference material.
WNetAddConnection ()
WNetAddConnection () function to redirect the specified local device (disk or print-port) for a given shared device or remote device. It uses the following parameters:

Point to null at the end of the string that specifies the connection to network resources, such as \ \ Server \ Share.
NOTE: Novell users usually do not use:: symbol to invoke the server and directory. For example, do not try to use the following methods to invoke a directory:
\ \ server \ volume:: \ mydirectory.
And should use the following methods:
\ \ server \ volume \ mydirectory

Point to null at the end of the string that specifies the operation to connect to the password. This parameter is usually associated with the current user password, if the parameter is null, then use the default password. If the string is air, do not use a password (using ordinary empty string as a placeholder):
= CallFn (addconn, "\ \ SERVER \ share ","","< drive>:")

Point to a null string at the end of the string to be designated a local device redirection. LpszLocalName string all (such as LPT1) is case-sensitive. Only use the device name is A: to Z: and the device name to LPT1 LPT3.

WNetCancelConnection ()
WNetCancelConnection () function of the abolition of the network connection. It uses the following parameters:

Point to null at the end of the string that specifies the redirection of the local device name (such as LPT1: or D:) or the lifting of the long-range connectivity to network resources. When the parameter specifies a redirected local device, the redirection of the specified equipment to be dismantled. If the parameter specifies a remote network resources, then the only connection to the remote resources rather than equipment to be dismantled.

Specified even if the connection has open files or tasks, whether or not to interrupt any connection. If the parameter is FALSE, then there are open files or tasks, the failure of the function call.

Reference on the WNetAddConnection () and WNetCancelConnection () API call for more information, please see the Microsoft Windows software development Kit (SDK) "Programmer Reference, Volume II: function."

Note: API calls return value will not be FoxPro for Windows conversion.

Visual FoxPro DECLARE command on the details, see "DECLARE - DLL" Help Topics

Original author: James

Visual FoxPro Tutorial Articles

Can't Find What You're Looking For?

Rating: Not yet rated


No comments posted.