ホーム › NetworkManagement.Snmp › SnmpSetVb
SnmpSetVb
関数変数バインドリストの指定位置にOIDと値を設定する。
シグネチャ
// wsnmp32.dll
#include <windows.h>
DWORD SnmpSetVb(
INT_PTR vbl,
DWORD index,
smiOID* name,
smiVALUE* value
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| vbl | INT_PTR | in | 対象の変数バインドリストハンドル。 |
| index | DWORD | in | 設定する要素の1始まりインデックス。0で末尾に追加。 |
| name | smiOID* | inout | 設定する変数バインドのOID(smiOID)ポインタ。 |
| value | smiVALUE* | inout | 設定する変数バインドの値(smiVALUE)ポインタ。 |
戻り値の型: DWORD
各言語での呼び出し定義
// wsnmp32.dll
#include <windows.h>
DWORD SnmpSetVb(
INT_PTR vbl,
DWORD index,
smiOID* name,
smiVALUE* value
);[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern uint SnmpSetVb(
IntPtr vbl, // INT_PTR
uint index, // DWORD
IntPtr name, // smiOID* in/out
IntPtr value // smiVALUE* in/out
);<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpSetVb(
vbl As IntPtr, ' INT_PTR
index As UInteger, ' DWORD
name As IntPtr, ' smiOID* in/out
value As IntPtr ' smiVALUE* in/out
) As UInteger
End Function' vbl : INT_PTR
' index : DWORD
' name : smiOID* in/out
' value : smiVALUE* in/out
Declare PtrSafe Function SnmpSetVb Lib "wsnmp32" ( _
ByVal vbl As LongPtr, _
ByVal index As Long, _
ByVal name As LongPtr, _
ByVal value As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SnmpSetVb = ctypes.windll.wsnmp32.SnmpSetVb
SnmpSetVb.restype = wintypes.DWORD
SnmpSetVb.argtypes = [
ctypes.c_ssize_t, # vbl : INT_PTR
wintypes.DWORD, # index : DWORD
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')
SnmpSetVb = Fiddle::Function.new(
lib['SnmpSetVb'],
[
Fiddle::TYPE_INTPTR_T, # vbl : INT_PTR
-Fiddle::TYPE_INT, # index : DWORD
Fiddle::TYPE_VOIDP, # name : smiOID* in/out
Fiddle::TYPE_VOIDP, # value : smiVALUE* in/out
],
-Fiddle::TYPE_INT)#[link(name = "wsnmp32")]
extern "system" {
fn SnmpSetVb(
vbl: isize, // INT_PTR
index: u32, // DWORD
name: *mut smiOID, // smiOID* in/out
value: *mut smiVALUE // smiVALUE* in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsnmp32.dll")]
public static extern uint SnmpSetVb(IntPtr vbl, uint index, IntPtr name, IntPtr value);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpSetVb' -Namespace Win32 -PassThru
# $api::SnmpSetVb(vbl, index, name, value)#uselib "wsnmp32.dll"
#func global SnmpSetVb "SnmpSetVb" sptr, sptr, sptr, sptr
; SnmpSetVb vbl, index, varptr(name), varptr(value) ; 戻り値は stat
; vbl : INT_PTR -> "sptr"
; index : DWORD -> "sptr"
; name : smiOID* in/out -> "sptr"
; value : smiVALUE* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "wsnmp32.dll" #cfunc global SnmpSetVb "SnmpSetVb" sptr, int, var, var ; res = SnmpSetVb(vbl, index, name, value) ; vbl : INT_PTR -> "sptr" ; index : DWORD -> "int" ; name : smiOID* in/out -> "var" ; value : smiVALUE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "wsnmp32.dll" #cfunc global SnmpSetVb "SnmpSetVb" sptr, int, sptr, sptr ; res = SnmpSetVb(vbl, index, varptr(name), varptr(value)) ; vbl : INT_PTR -> "sptr" ; index : DWORD -> "int" ; name : smiOID* in/out -> "sptr" ; value : smiVALUE* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD SnmpSetVb(INT_PTR vbl, DWORD index, smiOID* name, smiVALUE* value) #uselib "wsnmp32.dll" #cfunc global SnmpSetVb "SnmpSetVb" intptr, int, var, var ; res = SnmpSetVb(vbl, index, name, value) ; vbl : INT_PTR -> "intptr" ; index : DWORD -> "int" ; name : smiOID* in/out -> "var" ; value : smiVALUE* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD SnmpSetVb(INT_PTR vbl, DWORD index, smiOID* name, smiVALUE* value) #uselib "wsnmp32.dll" #cfunc global SnmpSetVb "SnmpSetVb" intptr, int, intptr, intptr ; res = SnmpSetVb(vbl, index, varptr(name), varptr(value)) ; vbl : INT_PTR -> "intptr" ; index : DWORD -> "int" ; name : smiOID* in/out -> "intptr" ; value : smiVALUE* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
procSnmpSetVb = wsnmp32.NewProc("SnmpSetVb")
)
// vbl (INT_PTR), index (DWORD), name (smiOID* in/out), value (smiVALUE* in/out)
r1, _, err := procSnmpSetVb.Call(
uintptr(vbl),
uintptr(index),
uintptr(name),
uintptr(value),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SnmpSetVb(
vbl: NativeInt; // INT_PTR
index: DWORD; // DWORD
name: Pointer; // smiOID* in/out
value: Pointer // smiVALUE* in/out
): DWORD; stdcall;
external 'wsnmp32.dll' name 'SnmpSetVb';result := DllCall("wsnmp32\SnmpSetVb"
, "Ptr", vbl ; INT_PTR
, "UInt", index ; DWORD
, "Ptr", name ; smiOID* in/out
, "Ptr", value ; smiVALUE* in/out
, "UInt") ; return: DWORD●SnmpSetVb(vbl, index, name, value) = DLL("wsnmp32.dll", "dword SnmpSetVb(int, dword, void*, void*)")
# 呼び出し: SnmpSetVb(vbl, index, name, value)
# vbl : INT_PTR -> "int"
# index : DWORD -> "dword"
# name : smiOID* in/out -> "void*"
# value : smiVALUE* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wsnmp32" fn SnmpSetVb(
vbl: isize, // INT_PTR
index: u32, // DWORD
name: [*c]smiOID, // smiOID* in/out
value: [*c]smiVALUE // smiVALUE* in/out
) callconv(std.os.windows.WINAPI) u32;proc SnmpSetVb(
vbl: int, # INT_PTR
index: uint32, # DWORD
name: ptr smiOID, # smiOID* in/out
value: ptr smiVALUE # smiVALUE* in/out
): uint32 {.importc: "SnmpSetVb", stdcall, dynlib: "wsnmp32.dll".}pragma(lib, "wsnmp32");
extern(Windows)
uint SnmpSetVb(
ptrdiff_t vbl, // INT_PTR
uint index, // DWORD
smiOID* name, // smiOID* in/out
smiVALUE* value // smiVALUE* in/out
);ccall((:SnmpSetVb, "wsnmp32.dll"), stdcall, UInt32,
(Int, UInt32, Ptr{smiOID}, Ptr{smiVALUE}),
vbl, index, name, value)
# vbl : INT_PTR -> Int
# index : DWORD -> UInt32
# name : smiOID* in/out -> Ptr{smiOID}
# value : smiVALUE* in/out -> Ptr{smiVALUE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t SnmpSetVb(
intptr_t vbl,
uint32_t index,
void* name,
void* value);
]]
local wsnmp32 = ffi.load("wsnmp32")
-- wsnmp32.SnmpSetVb(vbl, index, name, value)
-- vbl : INT_PTR
-- index : DWORD
-- name : smiOID* in/out
-- value : smiVALUE* in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('wsnmp32.dll');
const SnmpSetVb = lib.func('__stdcall', 'SnmpSetVb', 'uint32_t', ['intptr_t', 'uint32_t', 'void *', 'void *']);
// SnmpSetVb(vbl, index, name, value)
// vbl : INT_PTR -> 'intptr_t'
// index : DWORD -> 'uint32_t'
// name : smiOID* in/out -> 'void *'
// value : smiVALUE* in/out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("wsnmp32.dll", {
SnmpSetVb: { parameters: ["isize", "u32", "pointer", "pointer"], result: "u32" },
});
// lib.symbols.SnmpSetVb(vbl, index, name, value)
// vbl : INT_PTR -> "isize"
// index : DWORD -> "u32"
// name : smiOID* in/out -> "pointer"
// value : smiVALUE* in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t SnmpSetVb(
intptr_t vbl,
uint32_t index,
void* name,
void* value);
C, "wsnmp32.dll");
// $ffi->SnmpSetVb(vbl, index, name, value);
// vbl : INT_PTR
// index : DWORD
// name : smiOID* in/out
// value : smiVALUE* in/out
// 構造体/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 SnmpSetVb(
long vbl, // INT_PTR
int index, // DWORD
Pointer name, // smiOID* in/out
Pointer value // smiVALUE* in/out
);
}@[Link("wsnmp32")]
lib Libwsnmp32
fun SnmpSetVb = SnmpSetVb(
vbl : LibC::SSizeT, # INT_PTR
index : UInt32, # DWORD
name : smiOID*, # smiOID* in/out
value : smiVALUE* # smiVALUE* in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SnmpSetVbNative = Uint32 Function(IntPtr, Uint32, Pointer<Void>, Pointer<Void>);
typedef SnmpSetVbDart = int Function(int, int, Pointer<Void>, Pointer<Void>);
final SnmpSetVb = DynamicLibrary.open('wsnmp32.dll')
.lookupFunction<SnmpSetVbNative, SnmpSetVbDart>('SnmpSetVb');
// vbl : INT_PTR -> IntPtr
// index : DWORD -> Uint32
// name : smiOID* in/out -> Pointer<Void>
// value : smiVALUE* in/out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SnmpSetVb(
vbl: NativeInt; // INT_PTR
index: DWORD; // DWORD
name: Pointer; // smiOID* in/out
value: Pointer // smiVALUE* in/out
): DWORD; stdcall;
external 'wsnmp32.dll' name 'SnmpSetVb';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SnmpSetVb"
c_SnmpSetVb :: CIntPtr -> Word32 -> Ptr () -> Ptr () -> IO Word32
-- vbl : INT_PTR -> CIntPtr
-- index : DWORD -> Word32
-- name : smiOID* in/out -> Ptr ()
-- value : smiVALUE* in/out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let snmpsetvb =
foreign "SnmpSetVb"
(intptr_t @-> uint32_t @-> (ptr void) @-> (ptr void) @-> returning uint32_t)
(* vbl : INT_PTR -> intptr_t *)
(* index : DWORD -> uint32_t *)
(* name : smiOID* in/out -> (ptr void) *)
(* value : smiVALUE* in/out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wsnmp32 (t "wsnmp32.dll"))
(cffi:use-foreign-library wsnmp32)
(cffi:defcfun ("SnmpSetVb" snmp-set-vb :convention :stdcall) :uint32
(vbl :int64) ; INT_PTR
(index :uint32) ; DWORD
(name :pointer) ; smiOID* in/out
(value :pointer)) ; smiVALUE* in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SnmpSetVb = Win32::API::More->new('wsnmp32',
'DWORD SnmpSetVb(LPARAM vbl, DWORD index, LPVOID name, LPVOID value)');
# my $ret = $SnmpSetVb->Call($vbl, $index, $name, $value);
# vbl : INT_PTR -> LPARAM
# index : DWORD -> DWORD
# name : smiOID* in/out -> LPVOID
# value : smiVALUE* in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
使用する型