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

SnmpSetRetry

関数
指定したエンティティの要求再試行回数を設定する。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD SnmpSetRetry(
    INT_PTR hEntity,
    DWORD nPolicyRetry
);

パラメーター

名前方向
hEntityINT_PTRin
nPolicyRetryDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

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

SnmpSetRetry = ctypes.windll.wsnmp32.SnmpSetRetry
SnmpSetRetry.restype = wintypes.DWORD
SnmpSetRetry.argtypes = [
    ctypes.c_ssize_t,  # hEntity : INT_PTR
    wintypes.DWORD,  # nPolicyRetry : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
	procSnmpSetRetry = wsnmp32.NewProc("SnmpSetRetry")
)

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