Announcement

Collapse
No announcement yet.

Mapping a network drive!?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Mapping a network drive!?


    I'm trying to use the WNetUseConnection (mpr.dll) for mapping
    a network drive...

    Because I do not have the include file of it, I got a
    "million" of errors when I try to translate the VB code
    to the PB format.

    I would like to know if someone around here have already get
    this running!

    Thanks in advance...



    ------------------
    -------------------------------------------
    Francis Beaulieu
    FrabLaser Softwares
    Francis Beaulieu
    Prog senior of 17 years.
    Microsoft Specialist

  • #2
    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

    '==========================================================
    'Usage:
    'CALL MapDrive("F:", "\\MXLFS001\VOL2\DATA\PACKAGIN\DATA")
    '==========================================================

    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

    '============================================
    'Usage:
    'CALL UnMapDrive("F:")
    '============================================

    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

    '================================================
    'Usage:
    'CALL DetachServer("\\MXLFS001")
    '================================================

    LOCAL x AS LONG

    x = WNetCancelConnection2(@RemoteName, %CONNECT_UPDATE_PROFILE, %TRUE)
    IF x = 0 THEN
    FUNCTION = x
    ELSE
    FUNCTION = GetLastError()
    END IF
    END FUNCTION


    I hope this helps.


    Sincerely,


    Peter Redei

    ------------------

    Comment


    • #3
      Thanks Peter,

      It give to me a good exemple of how to declare my variables...



      ------------------
      -------------------------------------------
      Francis Beaulieu
      FrabLaser Softwares
      Francis Beaulieu
      Prog senior of 17 years.
      Microsoft Specialist

      Comment

      Working...
      X