>>if NOT file(addbs(PATH_TO_DATA_ON_SERVER) + "MYDBC.DBC") >> ** Can't find data >> return >>endif>>
FUNCTION MapDevice >LPARAMETERS tcLocal, tcRemote, tcUserID, tcPassword, tlPermanent >LOCAL oHeapObj, oNetRsc, nResult >IF ! 'CLSHEAP' $ UPPER(SET('PROC')) > SET PROCEDURE TO CLSHEAP ADDITIVE >ENDIF >IF ! 'NETRSC' $ UPPER(SET('PROC')) > SET PROCEDURE TO NETRSC ADDITIVE >ENDIF >oHeapObj=CREATEOBJ('Heap') && I need a heap to allocate a static block > >oNetRsc=CREATEOBJ('NETRESOURCE',oHeapObj) > >oNetRsc.SetRemoteName(tcRemote) && UNC of remote device >oNetRsc.SetLocalName(tcLocal) && Local device name > > >IF TYPE('tcUserID') # 'C' && No userid specified - null, use WinLogin > tcUserID = 0 >ELSE > tcUserID = tcUserID + CHR(0) >ENDIF >IF TYPE('tcPassword') # 'C' && No password given - null, use WinLogin > tcPassword = 0 >ELSE > tcPassword = tcPassword + CHR(0) >ENDIF >* Create the NETRESOURCE for the API call >oNetRsc.BuildNETRESOURCE() > >DECLARE INTEGER WNetAddConnection3 IN WIN32API ; > INTEGER hWnd, ; > STRING @ lpNETRESOURCE, ; > STRING @ lpPassword, ; > STRING @ lpUserID, ; > INTEGER dwFlags >DECLARE INTEGER GetActiveWindow IN WIN32API && If we need a dialog > && root to active window > >* tlPermanent indicates that we want to reestablish this mapping at next login > >nResult = WNetAddConnection3(GetActiveWindow() , ; > oNetRsc.cNETRESOURCE, ; > tcPassword, ; > tcUserID, ; > IIF(tlPermanent,1,0) ) >oNetRsc = NULL >oHeapObj = NULL >RETURN nResult > >* To use this: >nError = MapDevice('','\\Server\Share','MyUserID','Password') * * The following logs into the server without explicitly attaching a resource * by gaining access to the interprocess communication service rather than a * disk or printer resource explicitly * * nError = MapDevice('','\\Server\IPC$','MyUserID','Password') * * This way you can attach a server without knowing the name of an explicit share >* You can specify a drive letter for the first parameter to map the UNC to the >* drive, omitting userid and password use the WIndows Login userid and password >IF nError = 0 > * UNC is now Addressible - you should check for the ability to Create, Open > * Read, Write, Delete, create subdirectories and alter file attributes using > * low-level functions and API calls, or the Scripting.FileSystemObject >ELSE > * Error is one of: ERROR_ACCESS_DENIED, ERROR_ALREADY_ASSIGNED, > * ERROR_BAD_DEV_TYPE, ERROR_BAD_DEVICE, ERROR_BAD_NET_NAME, > * ERROR_BAD_PROFILE, ERROR_BAD_PROVIDER, ERROR_BUSY, > * ERROR_CANCELLED, ERROR_CANNOT_OPEN_PROFILE, > * ERROR_EXTENDED_ERROR, ERROR_INVALID_PASSWORD, ERROR_NO_NET_OR_BAD_PATH, > * ERROR_NO_NETWORK >ENDIF