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