ホーム › Storage.FileSystem › NetStatisticsGet
NetStatisticsGet
関数ワークステーションまたはサーバーの稼働統計を取得する。
シグネチャ
// NETAPI32.dll
#include <windows.h>
DWORD NetStatisticsGet(
CHAR* ServerName,
CHAR* Service,
DWORD Level,
DWORD Options,
BYTE** Buffer
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| ServerName | CHAR* | in |
| Service | CHAR* | in |
| Level | DWORD | in |
| Options | DWORD | in |
| Buffer | BYTE** | out |
戻り値の型: DWORD
各言語での呼び出し定義
// NETAPI32.dll
#include <windows.h>
DWORD NetStatisticsGet(
CHAR* ServerName,
CHAR* Service,
DWORD Level,
DWORD Options,
BYTE** Buffer
);[DllImport("NETAPI32.dll", ExactSpelling = true)]
static extern uint NetStatisticsGet(
IntPtr ServerName, // CHAR*
IntPtr Service, // CHAR*
uint Level, // DWORD
uint Options, // DWORD
IntPtr Buffer // BYTE** out
);<DllImport("NETAPI32.dll", ExactSpelling:=True)>
Public Shared Function NetStatisticsGet(
ServerName As IntPtr, ' CHAR*
Service As IntPtr, ' CHAR*
Level As UInteger, ' DWORD
Options As UInteger, ' DWORD
Buffer As IntPtr ' BYTE** out
) As UInteger
End Function' ServerName : CHAR*
' Service : CHAR*
' Level : DWORD
' Options : DWORD
' Buffer : BYTE** out
Declare PtrSafe Function NetStatisticsGet Lib "netapi32" ( _
ByVal ServerName As LongPtr, _
ByVal Service As LongPtr, _
ByVal Level As Long, _
ByVal Options As Long, _
ByVal Buffer As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
NetStatisticsGet = ctypes.windll.netapi32.NetStatisticsGet
NetStatisticsGet.restype = wintypes.DWORD
NetStatisticsGet.argtypes = [
ctypes.POINTER(ctypes.c_byte), # ServerName : CHAR*
ctypes.POINTER(ctypes.c_byte), # Service : CHAR*
wintypes.DWORD, # Level : DWORD
wintypes.DWORD, # Options : DWORD
ctypes.c_void_p, # Buffer : BYTE** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('NETAPI32.dll')
NetStatisticsGet = Fiddle::Function.new(
lib['NetStatisticsGet'],
[
Fiddle::TYPE_VOIDP, # ServerName : CHAR*
Fiddle::TYPE_VOIDP, # Service : CHAR*
-Fiddle::TYPE_INT, # Level : DWORD
-Fiddle::TYPE_INT, # Options : DWORD
Fiddle::TYPE_VOIDP, # Buffer : BYTE** out
],
-Fiddle::TYPE_INT)#[link(name = "netapi32")]
extern "system" {
fn NetStatisticsGet(
ServerName: *mut i8, // CHAR*
Service: *mut i8, // CHAR*
Level: u32, // DWORD
Options: u32, // DWORD
Buffer: *mut *mut u8 // BYTE** out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("NETAPI32.dll")]
public static extern uint NetStatisticsGet(IntPtr ServerName, IntPtr Service, uint Level, uint Options, IntPtr Buffer);
"@
$api = Add-Type -MemberDefinition $sig -Name 'NETAPI32_NetStatisticsGet' -Namespace Win32 -PassThru
# $api::NetStatisticsGet(ServerName, Service, Level, Options, Buffer)#uselib "NETAPI32.dll"
#func global NetStatisticsGet "NetStatisticsGet" sptr, sptr, sptr, sptr, sptr
; NetStatisticsGet varptr(ServerName), varptr(Service), Level, Options, varptr(Buffer) ; 戻り値は stat
; ServerName : CHAR* -> "sptr"
; Service : CHAR* -> "sptr"
; Level : DWORD -> "sptr"
; Options : DWORD -> "sptr"
; Buffer : BYTE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "NETAPI32.dll" #cfunc global NetStatisticsGet "NetStatisticsGet" var, var, int, int, var ; res = NetStatisticsGet(ServerName, Service, Level, Options, Buffer) ; ServerName : CHAR* -> "var" ; Service : CHAR* -> "var" ; Level : DWORD -> "int" ; Options : DWORD -> "int" ; Buffer : BYTE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "NETAPI32.dll" #cfunc global NetStatisticsGet "NetStatisticsGet" sptr, sptr, int, int, sptr ; res = NetStatisticsGet(varptr(ServerName), varptr(Service), Level, Options, varptr(Buffer)) ; ServerName : CHAR* -> "sptr" ; Service : CHAR* -> "sptr" ; Level : DWORD -> "int" ; Options : DWORD -> "int" ; Buffer : BYTE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD NetStatisticsGet(CHAR* ServerName, CHAR* Service, DWORD Level, DWORD Options, BYTE** Buffer) #uselib "NETAPI32.dll" #cfunc global NetStatisticsGet "NetStatisticsGet" var, var, int, int, var ; res = NetStatisticsGet(ServerName, Service, Level, Options, Buffer) ; ServerName : CHAR* -> "var" ; Service : CHAR* -> "var" ; Level : DWORD -> "int" ; Options : DWORD -> "int" ; Buffer : BYTE** out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD NetStatisticsGet(CHAR* ServerName, CHAR* Service, DWORD Level, DWORD Options, BYTE** Buffer) #uselib "NETAPI32.dll" #cfunc global NetStatisticsGet "NetStatisticsGet" intptr, intptr, int, int, intptr ; res = NetStatisticsGet(varptr(ServerName), varptr(Service), Level, Options, varptr(Buffer)) ; ServerName : CHAR* -> "intptr" ; Service : CHAR* -> "intptr" ; Level : DWORD -> "int" ; Options : DWORD -> "int" ; Buffer : BYTE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
netapi32 = windows.NewLazySystemDLL("NETAPI32.dll")
procNetStatisticsGet = netapi32.NewProc("NetStatisticsGet")
)
// ServerName (CHAR*), Service (CHAR*), Level (DWORD), Options (DWORD), Buffer (BYTE** out)
r1, _, err := procNetStatisticsGet.Call(
uintptr(ServerName),
uintptr(Service),
uintptr(Level),
uintptr(Options),
uintptr(Buffer),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction NetStatisticsGet(
ServerName: Pointer; // CHAR*
Service: Pointer; // CHAR*
Level: DWORD; // DWORD
Options: DWORD; // DWORD
Buffer: Pointer // BYTE** out
): DWORD; stdcall;
external 'NETAPI32.dll' name 'NetStatisticsGet';result := DllCall("NETAPI32\NetStatisticsGet"
, "Ptr", ServerName ; CHAR*
, "Ptr", Service ; CHAR*
, "UInt", Level ; DWORD
, "UInt", Options ; DWORD
, "Ptr", Buffer ; BYTE** out
, "UInt") ; return: DWORD●NetStatisticsGet(ServerName, Service, Level, Options, Buffer) = DLL("NETAPI32.dll", "dword NetStatisticsGet(void*, void*, dword, dword, void*)")
# 呼び出し: NetStatisticsGet(ServerName, Service, Level, Options, Buffer)
# ServerName : CHAR* -> "void*"
# Service : CHAR* -> "void*"
# Level : DWORD -> "dword"
# Options : DWORD -> "dword"
# Buffer : BYTE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。