ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSFinger/Net.cs
(Generate patch)

Comparing CCSFinger/Net.cs (file contents):
Revision 710 by douglas, 2006-03-24T01:37:37-08:00 vs.
Revision 718 by douglas, 2006-03-30T02:50:17-08:00

# Line 57 | Line 57 | public static class Net
57          }
58  
59          [DllImport("Netapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "NetQueryDisplayInformation")]
60 <        public static extern uint QueryDisplayInformation([In] string ServerName, [In] uint Level, [In] uint Index, [In] uint EntriesRequested, [In] uint PreferredMaximumLength, [Out] uint ReturnedEntryCount, [Out] NET_DISPLAY_USER[] SortedBuffer);
60 >        public static extern uint QueryDisplayInformation(string ServerName, uint Level, uint Index, uint EntriesRequested, uint PreferredMaximumLength, out uint ReturnedEntryCount, out IntPtr SortedBuffer);
61 >
62 >        public static uint QueryDisplayInformation(string ServerName, uint Level, uint Index, uint EntriesRequested, uint PreferredMaximumLength, out uint ReturnedEntryCount, out NET_DISPLAY_USER[] SortedBuffer)
63 >        {
64 >                IntPtr pointer;
65 >                uint value = QueryDisplayInformation(ServerName, Level, Index, EntriesRequested, PreferredMaximumLength, out ReturnedEntryCount, out pointer);
66 >
67 >                SortedBuffer = new NET_DISPLAY_USER[ReturnedEntryCount];
68 >
69 >                for (long index = 0; index != ReturnedEntryCount; ++index)
70 >                {
71 >                        IntPtr pointer_ = new IntPtr(pointer.ToInt64() + Marshal.SizeOf(typeof(NET_DISPLAY_USER)) * index);
72 >
73 >                        SortedBuffer[index] = (NET_DISPLAY_USER)Marshal.PtrToStructure(pointer_, typeof(NET_DISPLAY_USER));
74 >                }
75 >
76 >                ApiBufferFree(pointer);
77 >
78 >                return value;
79 >        }
80  
81          [DllImport("Netapi32.dll", CharSet = CharSet.Unicode, EntryPoint = "NetUserGetInfo")]
82 <        public static extern uint UserGetInfo([In] string servername, [In] string username, [In] uint level, [Out] USER_INFO_11 bufptr);
82 >        public static extern uint UserGetInfo(string servername, string username, uint level, out IntPtr bufptr);
83  
84 <        [DllImport("Netapi32.dll", EntryPoint = "NetApiBufferFree")]
85 <        public static extern uint ApiBufferFree([In] USER_INFO_11 buffer);
84 >        public static uint UserGetInfo(string servername, string username, uint level, out USER_INFO_11 bufptr)
85 >        {
86 >                IntPtr pointer;
87 >                uint value = UserGetInfo(servername, username, level, out pointer);
88 >
89 >                bufptr = new USER_INFO_11();
90 >
91 >                Marshal.PtrToStructure(pointer, bufptr);
92 >
93 >                ApiBufferFree(pointer);
94 >
95 >                return value;
96 >        }
97  
98          [DllImport("Netapi32.dll", EntryPoint = "NetApiBufferFree")]
99 <        public static extern uint ApiBufferFree([In] NET_DISPLAY_USER[] buffer);
99 >        public static extern uint ApiBufferFree(IntPtr buffer);
100   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines