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