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