>Have you guys tried calling WNetAddConnection2 instead of WNetAddConnect? According to the documentation WNetAddConnect2 supersedes the WNetAddConnect function. If you have, how can we mimic the 1st parm (NETRESOURCE structure).
Actually, I normally use WNetAddConnection3(); the NETRESOURCE structure is not one conveniently built using just VFP (there are several pointers to strings that are not convenient to build without use of HeapAlloc() and a memory copy facility like RtlMoveMemory() or lstrcopy() to move data to and from VFP memory space and the string buffers.) I use a wrapper .DLL on the API function which handles this for me.
There is a very strong alternative to using the API call; one of the OLE Automation objects in the Windows Scripting Host,
Wscript.Network has a very strong set of methods for accessing network functionality. The Windows Scripting Host is built into Win98 and WinNT 5; it can be conveniently added to NT 4.0 through Option Pack 4, or to any of the Win32 platforms from the self-installing .EXE available from Microsoft's Web site.
If Wscript.Network were the only useful automation object in WSH, I wouldn't be as enthusiastic about it; there are some other automation objects (Wscript.Shell, which provides a good deal of Shell functionality, including access to a shortcut and URL shortcut automation object, access to the Special Folders colection, environment strings, and the ability to create and execute VBScript and JScript through the WSCRIPT.EXE and CSCRIPT.EXE executables bundled into WSH.
It's considerably easier to work with than the Win32 API inside of VFP, too.