ホーム › NetworkManagement.Snmp › SnmpListen
SnmpListen
関数指定エンティティでのトラップ受信待ち受けを制御する。
シグネチャ
// wsnmp32.dll
#include <windows.h>
DWORD SnmpListen(
INT_PTR hEntity,
SNMP_STATUS lStatus
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hEntity | INT_PTR | in | 受信待機の対象となるエンティティ(エージェント)ハンドル。 |
| lStatus | SNMP_STATUS | in | 待機の有効/無効を示す状態値(SNMP_STATUS)。 |
戻り値の型: 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 // DWORDfunction 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)。const std = @import("std");
extern "wsnmp32" fn SnmpListen(
hEntity: isize, // INT_PTR
lStatus: u32 // SNMP_STATUS
) callconv(std.os.windows.WINAPI) u32;proc SnmpListen(
hEntity: int, # INT_PTR
lStatus: uint32 # SNMP_STATUS
): uint32 {.importc: "SnmpListen", stdcall, dynlib: "wsnmp32.dll".}pragma(lib, "wsnmp32");
extern(Windows)
uint SnmpListen(
ptrdiff_t hEntity, // INT_PTR
uint lStatus // SNMP_STATUS
);ccall((:SnmpListen, "wsnmp32.dll"), stdcall, UInt32,
(Int, UInt32),
hEntity, lStatus)
# hEntity : INT_PTR -> Int
# lStatus : SNMP_STATUS -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SnmpListen(
intptr_t hEntity,
uint32_t lStatus);
]]
local wsnmp32 = ffi.load("wsnmp32")
-- wsnmp32.SnmpListen(hEntity, lStatus)
-- hEntity : INT_PTR
-- lStatus : SNMP_STATUS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsnmp32.dll');
const SnmpListen = lib.func('__stdcall', 'SnmpListen', 'uint32_t', ['intptr_t', 'uint32_t']);
// SnmpListen(hEntity, lStatus)
// hEntity : INT_PTR -> 'intptr_t'
// lStatus : SNMP_STATUS -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsnmp32.dll", {
SnmpListen: { parameters: ["isize", "u32"], result: "u32" },
});
// lib.symbols.SnmpListen(hEntity, lStatus)
// hEntity : INT_PTR -> "isize"
// lStatus : SNMP_STATUS -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SnmpListen(
intptr_t hEntity,
uint32_t lStatus);
C, "wsnmp32.dll");
// $ffi->SnmpListen(hEntity, lStatus);
// hEntity : INT_PTR
// lStatus : SNMP_STATUS
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wsnmp32 extends StdCallLibrary {
Wsnmp32 INSTANCE = Native.load("wsnmp32", Wsnmp32.class);
int SnmpListen(
long hEntity, // INT_PTR
int lStatus // SNMP_STATUS
);
}@[Link("wsnmp32")]
lib Libwsnmp32
fun SnmpListen = SnmpListen(
hEntity : LibC::SSizeT, # INT_PTR
lStatus : UInt32 # SNMP_STATUS
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SnmpListenNative = Uint32 Function(IntPtr, Uint32);
typedef SnmpListenDart = int Function(int, int);
final SnmpListen = DynamicLibrary.open('wsnmp32.dll')
.lookupFunction<SnmpListenNative, SnmpListenDart>('SnmpListen');
// hEntity : INT_PTR -> IntPtr
// lStatus : SNMP_STATUS -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SnmpListen(
hEntity: NativeInt; // INT_PTR
lStatus: DWORD // SNMP_STATUS
): DWORD; stdcall;
external 'wsnmp32.dll' name 'SnmpListen';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SnmpListen"
c_SnmpListen :: CIntPtr -> Word32 -> IO Word32
-- hEntity : INT_PTR -> CIntPtr
-- lStatus : SNMP_STATUS -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let snmplisten =
foreign "SnmpListen"
(intptr_t @-> uint32_t @-> returning uint32_t)
(* hEntity : INT_PTR -> intptr_t *)
(* lStatus : SNMP_STATUS -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsnmp32 (t "wsnmp32.dll"))
(cffi:use-foreign-library wsnmp32)
(cffi:defcfun ("SnmpListen" snmp-listen :convention :stdcall) :uint32
(h-entity :int64) ; INT_PTR
(l-status :uint32)) ; SNMP_STATUS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SnmpListen = Win32::API::More->new('wsnmp32',
'DWORD SnmpListen(LPARAM hEntity, DWORD lStatus)');
# my $ret = $SnmpListen->Call($hEntity, $lStatus);
# hEntity : INT_PTR -> LPARAM
# lStatus : SNMP_STATUS -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f SnmpListenEx — 拡張オプション付きでエンティティの受信待ち受けを制御する。
使用する型