>>>Is there an API to map a Windows NT network drive letter? Similar to the NET USE dos prompt command.
>>
>>In addition to the API stuff mentioned by others, the Windows Scripting Host (native to 98, and addable to other operating systems by running the self-installing WSH.EXE available from Microsoft's Web site) provides a network automation object. If WSHOM.OCX has been registered, the following works:
>>
>>
>>oWshNet = CREATEOBJ('Wscript.Network')
>>* Lots of arguments available here:
>>* cLocalDrive is the local resource name (eg 'N:')
>>* cRemoteName is the UNC of the path you want to map
>>* (optional) lUpdateProfile (bool) if .T., save the mapping
>>* (optional) cUserId the name of a user other than the default
>>* Windows Login userid for accessing UNC
>>* (optional) cPassword password for user accessing UNC
>>oWshNet.MapNetworkDrive(cLocalDrive, cRemoteName)
>>*
>>* You can unmap a drive by:
>>*
>>oWshNet.RemoveNetworkDrive(cLocalDrive)
>>
>
>Here's some more scripts that might be useful at:
>
>
http://cwashington.netreach.net/site/scripts/scripts_index.htmlThanks for the reference, John. What I'm doing at this point is incorporating the use of the support objects from Wscript and scripting-related automation objects into VFP - in particular, the Wscript.Shell, Wscript.Network, and the various ADSI components are incredibly useful in accessing things in various APIs that would otherwise require wrapper .DLLs and significant coding to make their functions available; for example, getting the functionality of WNetAddConnection2() rather than WNetAddConnection(), is much easier using the Wscript.Network object than writing the wrappers needed to make the API call itself.
I'm playing a bit with the ADSI 2.5 object set, and will let you know how it goes making that available to VFP as well. The biggest issue I have is in ensuring that it installs properly - Wscript is a piece of cake, since it can install cross-platform unambiguously, but ADSI is a bit trickier to get set up right.