Link to home
Start Free TrialLog in
Avatar of tato
tato

asked on

Problems w/WNetEnumResource

I have a prob. w/WNetEnumResource
anybody can help me, this example have a prob?
Dim f As Long, k As Long, n As NETRESOURCE
Dim g As NETRESOURCE
Dim lpcCount As Long, lpBufferSize As Long
f = WNetOpenEnum(RESOURCE_CONNECTED, RESOURCETYPE_ANY, _
0, g, k)

lpBufferSize = Len(n)
If k Then f = WNetEnumResource(k, lpcCount, n, lpBufferSize)
If lpcCount Then
     
        Debug.Print n.dwDisplayType
        Debug.Print n.dwScope
        Debug.Print n.dwType
        Debug.Print n.dwUsage
        Debug.Print n.lpComment
        Debug.Print n.lpLocalName
        Debug.Print n.lpProvider
        Debug.Print n.lpRemoteName
else
Debug.Print f
End If
Debug.Print lpBuffer
If k Then f = WNetCloseEnum(k)
Avatar of tato
tato

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of mdougan
mdougan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tato

ASKER

Dear mdougan:
Your answer is good, but i need info to copy a pointer to string as long in string.
Declare Function lstrcpyn Lib "kernel32" Alias "lstrcpynA" (ByVal lpString1 As String, ByVal lpString2 As String, ByVal iMaxLength As Long) As Long
I try to use lstcpyn bu don have success.
Excuse my english bye
Hi,

Sorry, I tried to include all of the definitions with the routine, but I forgot these.  These are the declarations of the API functions necessary to copy the long pointers into strings.  The following snippet of code from the EnumContainers routine calls these two functions:

                  ' ---------------------------
                  ' Get the strings from the
                  '     string pointers
                  ' ---------------------------
                  p_lngLen = lstrlen(p_atypNetResAPI(p_lngLoop).lpLocalName)
                  If p_lngLen > 0 Then
                     g_atypNetRes(g_NetResLastIndex).sLocalName = Space$(p_lngLen)
                     CopyMem ByVal g_atypNetRes(g_NetResLastIndex).sLocalName, _
                             ByVal p_atypNetResAPI(p_lngLoop).lpLocalName, _
                             p_lngLen
                  End If

Public Declare Sub CopyMem _
   Lib "kernel32" Alias "RtlMoveMemory" _
   (pTo As Any, _
    pFrom As Any, _
    ByVal lCount As Long)

Public Declare Function lstrlen _
   Lib "kernel32" Alias "lstrlenA" _
   (ByVal sText As Any) As Long

Hope this helps

MD
Avatar of tato

ASKER

thanks mdougan

Bought This Question.