Unit NetConn

------------------------------------------------------------------------------- Network Connection Mangager Copyright (c) 1996 Ryan P. Cote Digital Insight 75040.2640@compuserve.com The code herein is released to public domain. You are free to use it or modify it as you choose. You may redistribute this code under the following conditions: 1. You must distribute all of its original files. 2. Each file must be in its original condition. 3. You may not profit from the redistribution of this component as a component, part of another component, or part of a component package without the written permission of Ryan P. Cote. Digital Insight or Ryan Cote gives no warrenty to the accuracy, fitness for particular use, effects of use, or reliability of the code containted herein. -------------------------------------------------------------------------------- Purpose: This component manages connections to network resources in Windows 95 and NT. You may establish connections, map local resources (drives and ports) to network resources, and you may break connections with this component. This component is essentially a wrapper for the Win32 API functions WNetAddConnection2 and WNetCancelConnection2. System Requirements: Delphi 2.0 or higher Windows 95 or Windows NT Installed network protocol Available network disk or print resources Installation: Copy the source file (NetConn.pas) and the component resource (NetConn.dcr) to a directory included in the Delphi Library Search Path (found in the Install Components dialog box). Select Component\Install from the Delphi menu. Properties: UserName - String containing User ID used to establish connections with with remote servers Password - String containing Password used with UserName ResourceType - rtDisk for Disk type resources, rtPrint for Printer type resources, and rtAny for any type resources. May only be rtAny if property LocalName is not specified (raises EParameterError when violated). LocalName - String containing name of local resource to map to network resource specified in property RemoteName. Example values are "F:" or "LPT2" (without the quotes). May not be specified when ResourceType is rtAny (raises EParameterError when violated). RemoteName - String containing name of remote network resource to connect to. Uses UNC (universal naming convention) which is in the format of "\\ServerName\ResourceName" (without the quotes). For example, the SYS volume of a Netware server named CENTRAL would be specified as "\\CENTRAL\SYS" (without the quotes). ReconnectAtLogon - Boolean value that is true when you want Windows to automatically attempt to reconnect to the specified resource each time you log in. A local resource must be specified in order for automatic reconnection (raises EParameterError on violation). Provider - String that specifies the network provider to connect to. Use this parameter only if you know for sure the provider you want to use. Otherwise, leave this field blank and let the operating system determine the provider for you. Methods: Connect - Takes no parameters. Attempts to connect to resource. Raises an EConnectError exception if the function fails. Disconnect - Takes one boolean parameter that tells whether or not to force disconnection when files are open on resource (True to force). If the LocalName property is set, it attempts to disconnect the resource connected to that device. Otherwise, it attempts to disconnect from the resouce specified by the RemoteName property. -------------------------------------------------------------------------------

Classes

TNetConnection -

Functions

Register -

Types

TResourceTypes

Constants

Variables


Functions


procedure Register;


Types


TResourceTypes = (rtDisk, rtPrint, rtAny);

Constants


Variables