/// <summary>
 ///     Retrieves operating statistics for a service. Currently, only the workstation and server services are supported.
 /// </summary>
 /// <param name="serverName">
 ///     Pointer to a string that specifies the DNS or NetBIOS name of the server on which the function
 ///     is to execute. If this parameter is NULL, the local computer is used.
 /// </param>
 /// <param name="netName">
 ///     Pointer to a string that specifies the name of the service about which to get the statistics.
 ///     Only the values SERVICE_SERVER and SERVICE_WORKSTATION are currently allowed.
 /// </param>
 /// <returns>
 ///     If the function succeeds, the return value is NERR_Success. If the function fails, the return value is a
 ///     system error code. For a list of error codes, see System Error Codes.
 /// </returns>
 public static Statworkstation0 GetStatistics(string serverName, string netName)
 {
     var returnValue = new Statworkstation0();
     IntPtr pBuffer;
     var status = DllImports.NetShareGetInfo(serverName, netName, 503, out pBuffer);
     if (status == 0)
     {
         var shareinfoType = typeof (Structs.StatWorkstation0);
         var pItem = new IntPtr(pBuffer.ToInt32());
         var statworkstation0 = (Structs.StatWorkstation0) Marshal.PtrToStructure(pItem, shareinfoType);
         returnValue = Statworkstation0.MapToStatworkstation0(statworkstation0);
         ApiBuffer.FreeBuffer(pBuffer);
     }
     return returnValue;
 }
Example #2
0
 /// <summary>
 ///     Maps the managed Statworkstation0 Object to a native Statworkstation0 Struct.
 /// </summary>
 /// <param name="statworkstation0">The managed source Statworkstation0 Object.</param>
 /// <returns>A native Statworkstation0 Struct.</returns>
 internal static Structs.StatWorkstation0 MapToNativeStatworkstation0(Statworkstation0 statworkstation0)
 {
     return(new Structs.StatWorkstation0
     {
         BytesReceived = statworkstation0.BytesReceived,
         CacheReadBytesRequested = statworkstation0.CacheReadBytesRequested,
         CoreConnects = statworkstation0.CoreConnects,
         BytesTransmitted = statworkstation0.BytesTransmitted,
         CacheWriteBytesRequested = statworkstation0.CacheWriteBytesRequested,
         CurrentCommands = statworkstation0.CurrentCommands,
         FailedCompletionOperations = statworkstation0.FailedCompletionOperations,
         FailedSessions = statworkstation0.FailedSessions,
         FailedUseCount = statworkstation0.FailedUseCount,
         HungSessions = statworkstation0.HungSessions,
         InitiallyFailedOperations = statworkstation0.InitiallyFailedOperations,
         Lanman20Connects = statworkstation0.Lanman20Connects,
         Lanman21Connects = statworkstation0.Lanman21Connects,
         LanmanNtConnects = statworkstation0.LanmanNtConnects,
         LargeReadSmbs = statworkstation0.LargeReadSmbs,
         LargeWriteSmbs = statworkstation0.LargeWriteSmbs,
         NetworkErrors = statworkstation0.NetworkErrors,
         NetworkReadBytesRequested = statworkstation0.NetworkReadBytesRequested,
         NetworkWriteBytesRequested = statworkstation0.NetworkWriteBytesRequested,
         NonPagingReadBytesRequested = statworkstation0.NonPagingReadBytesRequested,
         NonPagingWriteBytesRequested = statworkstation0.NonPagingWriteBytesRequested,
         PagingReadBytesRequested = statworkstation0.PagingReadBytesRequested,
         PagingWriteBytesRequested = statworkstation0.PagingWriteBytesRequested,
         RandomReadOperations = statworkstation0.RandomReadOperations,
         RandomWriteOperations = statworkstation0.RandomWriteOperations,
         RawReadsDenied = statworkstation0.RawReadsDenied,
         RawWritesDenied = statworkstation0.RawWritesDenied,
         ReadOperations = statworkstation0.ReadOperations,
         ReadSmbs = statworkstation0.ReadSmbs,
         Reconnects = statworkstation0.Reconnects,
         ServerDisconnects = statworkstation0.ServerDisconnects,
         Sessions = statworkstation0.Sessions,
         SmallReadSmbs = statworkstation0.SmallReadSmbs,
         SmallWriteSmbs = statworkstation0.SmallWriteSmbs,
         SmbsReceived = statworkstation0.SmbsReceived,
         SmbsTransmitted = statworkstation0.SmbsTransmitted,
         StatisticsStartTime = statworkstation0.StatisticsStartTime,
         UseCount = statworkstation0.UseCount,
         WriteOperations = statworkstation0.WriteOperations,
         WriteSmbs = statworkstation0.WriteSmbs
     });
 }
 /// <summary>
 ///     Maps the managed Statworkstation0 Object to a native Statworkstation0 Struct.
 /// </summary>
 /// <param name="statworkstation0">The managed source Statworkstation0 Object.</param>
 /// <returns>A native Statworkstation0 Struct.</returns>
 internal static Structs.StatWorkstation0 MapToNativeStatworkstation0(Statworkstation0 statworkstation0)
 {
     return new Structs.StatWorkstation0
     {
         BytesReceived = statworkstation0.BytesReceived,
         CacheReadBytesRequested = statworkstation0.CacheReadBytesRequested,
         CoreConnects = statworkstation0.CoreConnects,
         BytesTransmitted = statworkstation0.BytesTransmitted,
         CacheWriteBytesRequested = statworkstation0.CacheWriteBytesRequested,
         CurrentCommands = statworkstation0.CurrentCommands,
         FailedCompletionOperations = statworkstation0.FailedCompletionOperations,
         FailedSessions = statworkstation0.FailedSessions,
         FailedUseCount = statworkstation0.FailedUseCount,
         HungSessions = statworkstation0.HungSessions,
         InitiallyFailedOperations = statworkstation0.InitiallyFailedOperations,
         Lanman20Connects = statworkstation0.Lanman20Connects,
         Lanman21Connects = statworkstation0.Lanman21Connects,
         LanmanNtConnects = statworkstation0.LanmanNtConnects,
         LargeReadSmbs = statworkstation0.LargeReadSmbs,
         LargeWriteSmbs = statworkstation0.LargeWriteSmbs,
         NetworkErrors = statworkstation0.NetworkErrors,
         NetworkReadBytesRequested = statworkstation0.NetworkReadBytesRequested,
         NetworkWriteBytesRequested = statworkstation0.NetworkWriteBytesRequested,
         NonPagingReadBytesRequested = statworkstation0.NonPagingReadBytesRequested,
         NonPagingWriteBytesRequested = statworkstation0.NonPagingWriteBytesRequested,
         PagingReadBytesRequested = statworkstation0.PagingReadBytesRequested,
         PagingWriteBytesRequested = statworkstation0.PagingWriteBytesRequested,
         RandomReadOperations = statworkstation0.RandomReadOperations,
         RandomWriteOperations = statworkstation0.RandomWriteOperations,
         RawReadsDenied = statworkstation0.RawReadsDenied,
         RawWritesDenied = statworkstation0.RawWritesDenied,
         ReadOperations = statworkstation0.ReadOperations,
         ReadSmbs = statworkstation0.ReadSmbs,
         Reconnects = statworkstation0.Reconnects,
         ServerDisconnects = statworkstation0.ServerDisconnects,
         Sessions = statworkstation0.Sessions,
         SmallReadSmbs = statworkstation0.SmallReadSmbs,
         SmallWriteSmbs = statworkstation0.SmallWriteSmbs,
         SmbsReceived = statworkstation0.SmbsReceived,
         SmbsTransmitted = statworkstation0.SmbsTransmitted,
         StatisticsStartTime = statworkstation0.StatisticsStartTime,
         UseCount = statworkstation0.UseCount,
         WriteOperations = statworkstation0.WriteOperations,
         WriteSmbs = statworkstation0.WriteSmbs
     };
 }