>I have the following function in my startup program (I pulled it off the thread awile ago) that is supposed to estabish a network connection if the user isn't already connected. It works fine in test (when I manually disconnect from the drive and run the startup.prg). However, once I compile the EXE and run it (after disconnecting from the drive) I get a FILE NOT FOUND error. The first line of code in the launch program is :
>
>if ConnectToDrive()=.f.
> return .f.
>endif
>
>
>
>***********************
>function ConnectToDrive
>***********************
>* Already connected
>if drivetype("y")=4
> return .t.
>endif
>
>* Drive doesn't exist
>if drivetype("y")=1
> declare integer WNetAddConnection in "mpr.dll" ;
> string cRemoteName, ;
> string cPassword, ;
> string cLocalName
>
> cResource = "\\server\directory"
> cPassword = ""
> cDriveLetter = "y:"
>
> * Established connection.
> if WNetAddConnection(cResource, cPassword, cDriveLetter)=0
> return .t.
> endif
>endif
>return .f.
I've used this function quite a bit in the past. Off the top of my head, my declaration and execution of the call look like this.
DECLARE INTEGER WNetAddConnection IN Win32API;
STRING @lpszRemoteName, STRING @lpszPassword, STRING @lpszLocalName
lnresult = WNetAddConnection(@cResource, 0, @cDriveLetter)
IOW, the strings should be passed by reference. To pass a null pointer for the password, use 0 rather than an empty string.
George
Ubi caritas et amor, deus ibi est