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

SnmpCreateSession

関数
コールバックを伴うWinSNMPセッションを作成する。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT_PTR SnmpCreateSession(
    HWND hWnd,
    DWORD wMsg,
    SNMPAPI_CALLBACK fCallBack,
    void* lpClientData
);

パラメーター

名前方向
hWndHWNDin
wMsgDWORDin
fCallBackSNMPAPI_CALLBACKin
lpClientDatavoid*inout

戻り値の型: INT_PTR

各言語での呼び出し定義

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

INT_PTR SnmpCreateSession(
    HWND hWnd,
    DWORD wMsg,
    SNMPAPI_CALLBACK fCallBack,
    void* lpClientData
);
[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern IntPtr SnmpCreateSession(
    IntPtr hWnd,   // HWND
    uint wMsg,   // DWORD
    IntPtr fCallBack,   // SNMPAPI_CALLBACK
    IntPtr lpClientData   // void* in/out
);
<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpCreateSession(
    hWnd As IntPtr,   ' HWND
    wMsg As UInteger,   ' DWORD
    fCallBack As IntPtr,   ' SNMPAPI_CALLBACK
    lpClientData As IntPtr   ' void* in/out
) As IntPtr
End Function
' hWnd : HWND
' wMsg : DWORD
' fCallBack : SNMPAPI_CALLBACK
' lpClientData : void* in/out
Declare PtrSafe Function SnmpCreateSession Lib "wsnmp32" ( _
    ByVal hWnd As LongPtr, _
    ByVal wMsg As Long, _
    ByVal fCallBack As LongPtr, _
    ByVal lpClientData As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SnmpCreateSession = ctypes.windll.wsnmp32.SnmpCreateSession
SnmpCreateSession.restype = ctypes.c_ssize_t
SnmpCreateSession.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND
    wintypes.DWORD,  # wMsg : DWORD
    ctypes.c_void_p,  # fCallBack : SNMPAPI_CALLBACK
    ctypes.POINTER(None),  # lpClientData : void* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wsnmp32.dll')
SnmpCreateSession = Fiddle::Function.new(
  lib['SnmpCreateSession'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND
    -Fiddle::TYPE_INT,  # wMsg : DWORD
    Fiddle::TYPE_VOIDP,  # fCallBack : SNMPAPI_CALLBACK
    Fiddle::TYPE_VOIDP,  # lpClientData : void* in/out
  ],
  Fiddle::TYPE_INTPTR_T)
#[link(name = "wsnmp32")]
extern "system" {
    fn SnmpCreateSession(
        hWnd: *mut core::ffi::c_void,  // HWND
        wMsg: u32,  // DWORD
        fCallBack: *const core::ffi::c_void,  // SNMPAPI_CALLBACK
        lpClientData: *mut ()  // void* in/out
    ) -> isize;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wsnmp32.dll")]
public static extern IntPtr SnmpCreateSession(IntPtr hWnd, uint wMsg, IntPtr fCallBack, IntPtr lpClientData);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpCreateSession' -Namespace Win32 -PassThru
# $api::SnmpCreateSession(hWnd, wMsg, fCallBack, lpClientData)
#uselib "wsnmp32.dll"
#func global SnmpCreateSession "SnmpCreateSession" sptr, sptr, sptr, sptr
; SnmpCreateSession hWnd, wMsg, fCallBack, lpClientData   ; 戻り値は stat
; hWnd : HWND -> "sptr"
; wMsg : DWORD -> "sptr"
; fCallBack : SNMPAPI_CALLBACK -> "sptr"
; lpClientData : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "wsnmp32.dll"
#cfunc global SnmpCreateSession "SnmpCreateSession" sptr, int, sptr, sptr
; res = SnmpCreateSession(hWnd, wMsg, fCallBack, lpClientData)
; hWnd : HWND -> "sptr"
; wMsg : DWORD -> "int"
; fCallBack : SNMPAPI_CALLBACK -> "sptr"
; lpClientData : void* in/out -> "sptr"
; INT_PTR SnmpCreateSession(HWND hWnd, DWORD wMsg, SNMPAPI_CALLBACK fCallBack, void* lpClientData)
#uselib "wsnmp32.dll"
#cfunc global SnmpCreateSession "SnmpCreateSession" intptr, int, intptr, intptr
; res = SnmpCreateSession(hWnd, wMsg, fCallBack, lpClientData)
; hWnd : HWND -> "intptr"
; wMsg : DWORD -> "int"
; fCallBack : SNMPAPI_CALLBACK -> "intptr"
; lpClientData : void* in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
	procSnmpCreateSession = wsnmp32.NewProc("SnmpCreateSession")
)

// hWnd (HWND), wMsg (DWORD), fCallBack (SNMPAPI_CALLBACK), lpClientData (void* in/out)
r1, _, err := procSnmpCreateSession.Call(
	uintptr(hWnd),
	uintptr(wMsg),
	uintptr(fCallBack),
	uintptr(lpClientData),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // INT_PTR
function SnmpCreateSession(
  hWnd: THandle;   // HWND
  wMsg: DWORD;   // DWORD
  fCallBack: Pointer;   // SNMPAPI_CALLBACK
  lpClientData: Pointer   // void* in/out
): NativeInt; stdcall;
  external 'wsnmp32.dll' name 'SnmpCreateSession';
result := DllCall("wsnmp32\SnmpCreateSession"
    , "Ptr", hWnd   ; HWND
    , "UInt", wMsg   ; DWORD
    , "Ptr", fCallBack   ; SNMPAPI_CALLBACK
    , "Ptr", lpClientData   ; void* in/out
    , "Ptr")   ; return: INT_PTR
●SnmpCreateSession(hWnd, wMsg, fCallBack, lpClientData) = DLL("wsnmp32.dll", "int SnmpCreateSession(void*, dword, void*, void*)")
# 呼び出し: SnmpCreateSession(hWnd, wMsg, fCallBack, lpClientData)
# hWnd : HWND -> "void*"
# wMsg : DWORD -> "dword"
# fCallBack : SNMPAPI_CALLBACK -> "void*"
# lpClientData : void* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。