You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
I am using this code in both Novell and in NT (see Win32api.inc for structures and constants and declarations):
FUNCTION AttachServer(RemoteName AS ASCIIZ PTR, Pwd AS ASCIIZ PTR, netUserName AS ASCIIZ PTR) AS LONG
'===================================================
'Usage:
' pass1 = "MXLFS001"
' pass2 = "BANDI"
' pass3 = "THUUPTR"
' CALL AttachServer(pass1, pass2, pass3)
'===================================================
LOCAL nw AS NETRESOURCE
LOCAL uN AS ASCIIZ * 40
LOCAL pw AS ASCIIZ * 40
LOCAL x AS LONG
nw.dwScope = %RESOURCE_GLOBALNET
nw.dwType = %RESOURCETYPE_ANY
nw.dwDisplayType = %RESOURCEDISPLAYTYPE_SERVER
nw.dwUsage = %RESOURCEUSAGE_CONNECTABLE
'nw.lpLocalName = %NULL 'because it is not yet connected
nw.lpRemoteName = RemoteName
'nw.lpComment = %NULL
'nw.lpProvider = %NULL
pw = @Pwd
uN = @netUserName
x = WNetAddConnection2(nw, pw, uN, %CONNECT_UPDATE_PROFILE)
IF x = 0 THEN
FUNCTION = x
ELSE
FUNCTION = GetLastError()
END IF
END FUNCTION
FUNCTION MapDrive(LocalName AS ASCIIZ PTR, RemoteName AS ASCIIZ PTR) AS LONG
LOCAL nw AS NETRESOURCE
LOCAL x AS LONG
nw.dwScope = %RESOURCE_CONNECTED
nw.dwType = %RESOURCETYPE_DISK
nw.dwDisplayType = %RESOURCEDISPLAYTYPE_GENERIC
'nw.dwUsage = %RESOURCEUSAGE_CONNECTABLE
nw.lpLocalName = LocalName
nw.lpRemoteName = RemoteName
'nw.lpComment = %NULL
'nw.lpProvider = %NULL
x = WNetAddConnection2(nw, "", "", %CONNECT_UPDATE_PROFILE)
IF x = 0 THEN
FUNCTION = x
ELSE
FUNCTION = GetLastError()
END IF
END FUNCTION
FUNCTION UnMapDrive(LocalName AS ASCIIZ PTR) AS LONG
LOCAL x AS LONG
'LOCAL lN AS ASCIIZ * 255
'lN = @LocalName
x = WNetCancelConnection2(@LocalName, %CONNECT_UPDATE_PROFILE, %TRUE)
IF x = 0 THEN
FUNCTION = x
ELSE
FUNCTION = GetLastError()
END IF
END FUNCTION
FUNCTION DetachServer(RemoteName AS ASCIIZ PTR) AS LONG
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment