>I need to connect (login) to a network resource in VFP. What is the API call to do it?
>
There are several ways to do this. if you install the Windows Scripting Host (built into Win98 and Win2K, and distributed as a part of IE4/Ie5 and IIS, and also available as a self-installing .EXE from
http://msdn.microsoft.com/scripting), you can use the WScript.network automation object.
You can also use the WNetAddConnection family of API calls; I have example code in my NETRESOURCE class for using WNetAddConnection3() (you'll need to download CLSHEAP.ZIP and NETRSC.ZIP from the Files Section on UT; the example code is DEMO_WNetAddConnection3.PRG in NETRSC.ZIP, but it relies on services in my NETRESOURCE and Heap classes.)
If you don't need to specify a user id (you intend to use the current Windows login to attach to the remote resource) you can implement WNetAddConnection as a single API call; it's les capable than WNetAddConnection2() and WNetAddConnection3(), and is included only for some backwards compatibility. The declaration for WNetAddConnection would look like:
DECLARE INTEGER WNetAddConnection IN Win32API ;
STRING cRemoteUNC, ;
STRING cPassword, ;
STRING cLocalDrive
IF WNetAddConnection('\\SomeServer\SomeShare','MyPassword'+CHR(0),'N:') = 0
ENDIF
You can attach a device by name like 'LPT1:' to attach a remote printer, etc.