Sorry about posting my previous on an old thread.

Okay, here's my updated problem. Ideally I'd like to use DllImport.
However, have a look at the following two declares:
<DllImport("Netapi32")> _
Public Shared Function
NetQueryDisplayInformation(<MarshalAs(UnmanagedType.LPWStr)> ByVal
p_sServerName As String, ByVal p_iLevel As Integer, ByVal p_iIndex As
Integer, ByVal p_iEntriesRequested As Integer, ByVal
p_iPreferredMaximumLength As Integer, ByRef p_iReturnedEntryCount As
Integer, ByRef p_iBuffer As Integer) As Integer

End Function

Private Declare Function NetQueryDisplayInformation Lib "netapi32" Alias
"NetQueryDisplayInformation" (<MarshalAs(UnmanagedType.LPWStr)> ByVal
p_sServerName As String, ByVal p_iLevel As Integer, ByVal p_iIndex As
Integer, ByVal p_iEntriesRequested As Integer, ByVal
p_iPreferredMaximumLength As Integer, ByRef p_iReturnedEntryCount As
Integer, ByRef p_iBuffer As Integer) As Integer

As far as I can see they should produce the exact same results. In
reality they only do if I pass in Nothing into ServerName. If I pass
\\DOMAINCONTROLLER for example, the DllImport returns a Server Not
Available error, whereas when I call the Declared function it returns
More Data, which is correct. Why are these two returning different
results? As far as I can see they are identical.

-----Original Message-----
From: Tracy Martin [mailto:[EMAIL PROTECTED] 
Sent: 09 September 2003 09:32 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] .Net and NetCool Omnibus


At 12:13 9/9/2003, Sean Hederman wrote:

>When I run GetGroupList with Nothing in the Server Name, I get a valid 
>result, however when I run it with \\MACHINENAME I get a result from 
>NetQueryDisplayInformation of 1722, which is RPC server unavailable. 
>Anybody got any ideas?

I have no idea why your code is failing - but your post prompted me to
write my own code to do this (minimal code, minimal testing - but it
worked with both no server name specified and a valid server name in the
form \\name). Perhaps you can use this as a starting point to find your
problem....

BTW, I know there are some things in here that are "wrong" (ie. they use
the Microsoft.VisualBasic namespace) - such as Len() - but I was in a
hurry and didn't want to go looking for the "right" way... They
shouldn't be hard to pick out and fix....

Imports System.Runtime.InteropServices

Module Module1

     Structure NET_DISPLAY_GROUP
         <MarshalAs(UnmanagedType.LPWStr)> _
         Public grpi3_name As String
         <MarshalAs(UnmanagedType.LPWStr)> _
         Public grpi3_comment As String
         Public grpi3_group_id As Integer
         Public grpi3_attributes As Integer
         Public grpi3_next_index As Integer
     End Structure


     Private Declare Function NetQueryDisplayInformation _
      Lib "netapi32" _
      (<MarshalAs(UnmanagedType.LPWStr)> _
      ByVal ServerName As String, _
      ByVal Level As Integer, _
      ByVal Index As Integer, _
      ByVal EntriesRequested As Integer, _
      ByVal PreferredMaximumLength As Integer, _
      ByRef ReturnedEntryCount As Integer, _
      ByRef SortedBuffer As Integer) As Integer     ' NET_API_STATUS

     Private Declare Function NetApiBufferFree _
     Lib "netapi32" _
     (ByRef Buffer As Integer) As Integer       ' NET_API_STATUS

     Sub Main()
         Dim values() As NET_DISPLAY_GROUP

         values = GetInfo("\\schmoo")
         MsgBox(values.Length.ToString)
     End Sub

     Private Function GetInfo(ByVal MachineName As String)
         Dim values() As NET_DISPLAY_GROUP
         Dim value As NET_DISPLAY_GROUP
         Dim level As Integer
         Dim index As Integer
         Dim reqentries As Integer
         Dim maxlen As Integer
         Dim retentries As Integer
         Dim buffer As Integer
         Dim retval As Integer
         Dim count As Integer

         level = 3
         reqentries = 100
         maxlen = &HFFFFFFFF

         retval = NetQueryDisplayInformation(MachineName, level, index,
reqentries, maxlen, retentries, buffer)
         If retval > 0 Then
             MsgBox(retval.ToString())
             Return Nothing
         End If

         ReDim values(retentries - 1)

         For count = 1 To retentries
             value = Marshal.PtrToStructure(New IntPtr((buffer + ((count
-
1) * Len(value)))), GetType(NET_DISPLAY_GROUP))
             values(count - 1) = value
         Next

         NetApiBufferFree(buffer)
         Return values
     End Function
End Module

===================================
This list is hosted by DevelopMentor(r)  http://www.develop.com NEW!
ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at
http://discuss.develop.com

______________________________________________

"This information is intended only for the person or entity to which it is addressed 
and 
may contain private, confidential, proprietary and/or privileged material and may be 
subject
to confidentiality agreements.

Any review, retransmission, dissemination, or any other use of or taking of any action 
in
reliance upon this information, by persons or entities other than the intended 
recipient,
is prohibited. 

If you received this in error, please contact the sender and delete the material from 
all 
storage media.

The company is neither liable for proper, complete transmission of the information 
contained
in this communication, any delay in its receipt or that the mail is virus-free"

===================================
This list is hosted by DevelopMentor�  http://www.develop.com
NEW! ASP.NET courses you may be interested in:

2 Days of ASP.NET, 29 Sept 2003, in Redmond
http://www.develop.com/courses/2daspdotnet

Guerrilla ASP.NET, 13 Oct 2003, in Boston
http://www.develop.com/courses/gaspdotnet

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to