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

SnmpCreateVbl

関数
OIDと値からWinSNMPの変数バインドリストを作成する。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT_PTR SnmpCreateVbl(
    INT_PTR session,
    smiOID* name,
    smiVALUE* value
);

パラメーター

名前方向説明
sessionINT_PTRin使用するWinSNMPセッションハンドル。
namesmiOID*inout最初の変数バインドのOID(smiOID)ポインタ。NULLで空リストを作成可。
valuesmiVALUE*inout最初の変数バインドの値(smiVALUE)ポインタ。NULL可。

戻り値の型: INT_PTR

各言語での呼び出し定義

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

INT_PTR SnmpCreateVbl(
    INT_PTR session,
    smiOID* name,
    smiVALUE* value
);
[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern IntPtr SnmpCreateVbl(
    IntPtr session,   // INT_PTR
    IntPtr name,   // smiOID* in/out
    IntPtr value   // smiVALUE* in/out
);
<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpCreateVbl(
    session As IntPtr,   ' INT_PTR
    name As IntPtr,   ' smiOID* in/out
    value As IntPtr   ' smiVALUE* in/out
) As IntPtr
End Function
' session : INT_PTR
' name : smiOID* in/out
' value : smiVALUE* in/out
Declare PtrSafe Function SnmpCreateVbl Lib "wsnmp32" ( _
    ByVal session As LongPtr, _
    ByVal name As LongPtr, _
    ByVal value As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SnmpCreateVbl = ctypes.windll.wsnmp32.SnmpCreateVbl
SnmpCreateVbl.restype = ctypes.c_ssize_t
SnmpCreateVbl.argtypes = [
    ctypes.c_ssize_t,  # session : INT_PTR
    ctypes.c_void_p,  # name : smiOID* in/out
    ctypes.c_void_p,  # value : smiVALUE* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wsnmp32.dll')
SnmpCreateVbl = Fiddle::Function.new(
  lib['SnmpCreateVbl'],
  [
    Fiddle::TYPE_INTPTR_T,  # session : INT_PTR
    Fiddle::TYPE_VOIDP,  # name : smiOID* in/out
    Fiddle::TYPE_VOIDP,  # value : smiVALUE* in/out
  ],
  Fiddle::TYPE_INTPTR_T)
#[link(name = "wsnmp32")]
extern "system" {
    fn SnmpCreateVbl(
        session: isize,  // INT_PTR
        name: *mut smiOID,  // smiOID* in/out
        value: *mut smiVALUE  // smiVALUE* in/out
    ) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wsnmp32.dll")]
public static extern IntPtr SnmpCreateVbl(IntPtr session, IntPtr name, IntPtr value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpCreateVbl' -Namespace Win32 -PassThru
# $api::SnmpCreateVbl(session, name, value)
#uselib "wsnmp32.dll"
#func global SnmpCreateVbl "SnmpCreateVbl" sptr, sptr, sptr
; SnmpCreateVbl session, varptr(name), varptr(value)   ; 戻り値は stat
; session : INT_PTR -> "sptr"
; name : smiOID* in/out -> "sptr"
; value : smiVALUE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wsnmp32.dll"
#cfunc global SnmpCreateVbl "SnmpCreateVbl" sptr, var, var
; res = SnmpCreateVbl(session, name, value)
; session : INT_PTR -> "sptr"
; name : smiOID* in/out -> "var"
; value : smiVALUE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; INT_PTR SnmpCreateVbl(INT_PTR session, smiOID* name, smiVALUE* value)
#uselib "wsnmp32.dll"
#cfunc global SnmpCreateVbl "SnmpCreateVbl" intptr, var, var
; res = SnmpCreateVbl(session, name, value)
; session : INT_PTR -> "intptr"
; name : smiOID* in/out -> "var"
; value : smiVALUE* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
	procSnmpCreateVbl = wsnmp32.NewProc("SnmpCreateVbl")
)

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