Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

netstatisticsget (netapi32)
 
.
Summary
Retrieves operating statistics for a service. Currently, only the workstation and server services are supported.

C# Signature:

[DllImport("Netapi32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
    private extern static int NetStatisticsGet(
        [MarshalAs(UnmanagedType.LPWStr)] string serverName,
        [MarshalAs(UnmanagedType.LPWStr)] string service,
        int level,
        int options,
        out IntPtr BufPtr);

VB Signature:

Declare Function NetStatisticsGet Lib "Netapi32.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

//
// I found the following at http://www.codeproject.com/KB/cs/GetLastRebootTime.aspx by Gautham Jayaraman
//
static void Main(string[] args)
{
  IntPtr bufPtr = IntPtr.Zero;
  int val = NetStatisticsGet(null, "LanmanWorkstation", 0, 0, out bufPtr);
  STAT_WORKSTATION_0 wks = new STAT_WORKSTATION_0();
  if (val == 0)
  {
     wks = (STAT_WORKSTATION_0)Marshal.PtrToStructure(bufPtr, typeof(STAT_WORKSTATION_0));
  }
  DateTime aRebootTime = DateTime.FromFileTime(wks.StatisticsStartTime);
  System.Console.WriteLine(aRebootTime);
}

// See STAT_WORKSTATION_0

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions