Win32 API 日本語リファレンス
ホームNetworkManagement.Snmp › SnmpListen

SnmpListen

関数
指定エンティティでのトラップ受信待ち受けを制御する。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// wsnmp32.dll
#include <windows.h>

DWORD SnmpListen(
    INT_PTR hEntity,
    SNMP_STATUS lStatus
);

パラメーター

名前方向
hEntityINT_PTRin
lStatusSNMP_STATUSin

戻り値の型: DWORD

各言語での呼び出し定義

// wsnmp32.dll
#include <windows.h>

DWORD SnmpListen(
    INT_PTR hEntity,
    SNMP_STATUS lStatus
);
[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern uint SnmpListen(
    IntPtr hEntity,   // INT_PTR
    uint lStatus   // SNMP_STATUS
);
<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpListen(
    hEntity As IntPtr,   ' INT_PTR
    lStatus As UInteger   ' SNMP_STATUS
) As UInteger
End Function
' hEntity : INT_PTR
' lStatus : SNMP_STATUS
Declare PtrSafe Function SnmpListen Lib "wsnmp32" ( _
    ByVal hEntity As LongPtr, _
    ByVal lStatus As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SnmpListen = ctypes.windll.wsnmp32.SnmpListen
SnmpListen.restype = wintypes.DWORD
SnmpListen.argtypes = [
    ctypes.c_ssize_t,  # hEntity : INT_PTR
    wintypes.DWORD,  # lStatus : SNMP_STATUS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wsnmp32.dll')
SnmpListen = Fiddle::Function.new(
  lib['SnmpListen'],
  [
    Fiddle::TYPE_INTPTR_T,  # hEntity : INT_PTR
    -Fiddle::TYPE_INT,  # lStatus : SNMP_STATUS
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wsnmp32")]
extern "system" {
    fn SnmpListen(
        hEntity: isize,  // INT_PTR
        lStatus: u32  // SNMP_STATUS
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wsnmp32.dll")]
public static extern uint SnmpListen(IntPtr hEntity, uint lStatus);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpListen' -Namespace Win32 -PassThru
# $api::SnmpListen(hEntity, lStatus)
#uselib "wsnmp32.dll"
#func global SnmpListen "SnmpListen" sptr, sptr
; SnmpListen hEntity, lStatus   ; 戻り値は stat
; hEntity : INT_PTR -> "sptr"
; lStatus : SNMP_STATUS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "wsnmp32.dll"
#cfunc global SnmpListen "SnmpListen" sptr, int
; res = SnmpListen(hEntity, lStatus)
; hEntity : INT_PTR -> "sptr"
; lStatus : SNMP_STATUS -> "int"
; DWORD SnmpListen(INT_PTR hEntity, SNMP_STATUS lStatus)
#uselib "wsnmp32.dll"
#cfunc global SnmpListen "SnmpListen" intptr, int
; res = SnmpListen(hEntity, lStatus)
; hEntity : INT_PTR -> "intptr"
; lStatus : SNMP_STATUS -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
	procSnmpListen = wsnmp32.NewProc("SnmpListen")
)

// hEntity (INT_PTR), lStatus (SNMP_STATUS)
r1, _, err := procSnmpListen.Call(
	uintptr(hEntity),
	uintptr(lStatus),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SnmpListen(
  hEntity: NativeInt;   // INT_PTR
  lStatus: DWORD   // SNMP_STATUS
): DWORD; stdcall;
  external 'wsnmp32.dll' name 'SnmpListen';
result := DllCall("wsnmp32\SnmpListen"
    , "Ptr", hEntity   ; INT_PTR
    , "UInt", lStatus   ; SNMP_STATUS
    , "UInt")   ; return: DWORD
●SnmpListen(hEntity, lStatus) = DLL("wsnmp32.dll", "dword SnmpListen(int, dword)")
# 呼び出し: SnmpListen(hEntity, lStatus)
# hEntity : INT_PTR -> "int"
# lStatus : SNMP_STATUS -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。