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