Win32 API 日本語リファレンス
ホームNetworkManagement.Snmp › SnmpOpen

SnmpOpen

関数
WinSNMPセッションを開きウィンドウ通知を関連付ける。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// wsnmp32.dll
#include <windows.h>

INT_PTR SnmpOpen(
    HWND hWnd,
    DWORD wMsg
);

パラメーター

名前方向
hWndHWNDin
wMsgDWORDin

戻り値の型: 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_PTR
function 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)。