@IFEX %&CurFile%.LOG, LOGS * %&CurFile%.LOG
ENVI^ EnviMode=1
_SUB CreateDrive //LocalName RemoteName  UserName Password
    ENVI#$$ &&NetDrive=*48 0 //NETRESOURCE
    ENVI-long &NetDrive=2 //NetDrive
    //ENVI-long &NetDrive=0:~1 //dwType
    //ENVI-long &NetDrive=0:~2 //dwDisplayType
    ENVI-long &NetDrive=0:~3 //dwUsage

    SET &LocalName=%~1
    SET &RemoteName=%~2
    ENVI-ptr &NetDrive=&LocalName:16 //lpLocalName
    ENVI-ptr &NetDrive=&RemoteName:(16+%&ptrlen%) //lpRemoteName


    SET &UN=%~3
    SET &PW=%~4
    CALL $--qd Mpr.dll,WNetAddConnection2W,*&NetDrive,*&PW,*&UN,#0
_END

_SUB RemoveDrive //LocalName
    CALL $--qd Mpr.dll,WNetCancelConnection2W,$%~1,#1,#1
_END


CreateDrive "Y:"  "\\127.0.0.1\SHARE" "user"  "12345"
MESS 11
RemoveDrive "Y:"
MESS 111

EXIT FILE

typedef struct  _NETRESOURCEW {
    DWORD    dwScope;
    DWORD    dwType;
    DWORD    dwDisplayType;
    DWORD    dwUsage;
    LPWSTR   lpLocalName;
    LPWSTR   lpRemoteName;
    LPWSTR   lpComment ;
    LPWSTR   lpProvider;
}NETRESOURCEW, *LPNETRESOURCEW;
