ホーム › NetworkManagement.Snmp › SnmpSetPort
SnmpSetPort
関数指定したエンティティが使用する通信ポート番号を設定する。
シグネチャ
// wsnmp32.dll
#include <windows.h>
DWORD SnmpSetPort(
INT_PTR hEntity,
DWORD nPort
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hEntity | INT_PTR | in |
| nPort | DWORD | in |
戻り値の型: DWORD
各言語での呼び出し定義
// wsnmp32.dll
#include <windows.h>
DWORD SnmpSetPort(
INT_PTR hEntity,
DWORD nPort
);[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern uint SnmpSetPort(
IntPtr hEntity, // INT_PTR
uint nPort // DWORD
);<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpSetPort(
hEntity As IntPtr, ' INT_PTR
nPort As UInteger ' DWORD
) As UInteger
End Function' hEntity : INT_PTR
' nPort : DWORD
Declare PtrSafe Function SnmpSetPort Lib "wsnmp32" ( _
ByVal hEntity As LongPtr, _
ByVal nPort As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SnmpSetPort = ctypes.windll.wsnmp32.SnmpSetPort
SnmpSetPort.restype = wintypes.DWORD
SnmpSetPort.argtypes = [
ctypes.c_ssize_t, # hEntity : INT_PTR
wintypes.DWORD, # nPort : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('wsnmp32.dll')
SnmpSetPort = Fiddle::Function.new(
lib['SnmpSetPort'],
[
Fiddle::TYPE_INTPTR_T, # hEntity : INT_PTR
-Fiddle::TYPE_INT, # nPort : DWORD
],
-Fiddle::TYPE_INT)#[link(name = "wsnmp32")]
extern "system" {
fn SnmpSetPort(
hEntity: isize, // INT_PTR
nPort: u32 // DWORD
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("wsnmp32.dll")]
public static extern uint SnmpSetPort(IntPtr hEntity, uint nPort);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpSetPort' -Namespace Win32 -PassThru
# $api::SnmpSetPort(hEntity, nPort)#uselib "wsnmp32.dll"
#func global SnmpSetPort "SnmpSetPort" sptr, sptr
; SnmpSetPort hEntity, nPort ; 戻り値は stat
; hEntity : INT_PTR -> "sptr"
; nPort : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "wsnmp32.dll"
#cfunc global SnmpSetPort "SnmpSetPort" sptr, int
; res = SnmpSetPort(hEntity, nPort)
; hEntity : INT_PTR -> "sptr"
; nPort : DWORD -> "int"; DWORD SnmpSetPort(INT_PTR hEntity, DWORD nPort)
#uselib "wsnmp32.dll"
#cfunc global SnmpSetPort "SnmpSetPort" intptr, int
; res = SnmpSetPort(hEntity, nPort)
; hEntity : INT_PTR -> "intptr"
; nPort : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
procSnmpSetPort = wsnmp32.NewProc("SnmpSetPort")
)
// hEntity (INT_PTR), nPort (DWORD)
r1, _, err := procSnmpSetPort.Call(
uintptr(hEntity),
uintptr(nPort),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction SnmpSetPort(
hEntity: NativeInt; // INT_PTR
nPort: DWORD // DWORD
): DWORD; stdcall;
external 'wsnmp32.dll' name 'SnmpSetPort';result := DllCall("wsnmp32\SnmpSetPort"
, "Ptr", hEntity ; INT_PTR
, "UInt", nPort ; DWORD
, "UInt") ; return: DWORD●SnmpSetPort(hEntity, nPort) = DLL("wsnmp32.dll", "dword SnmpSetPort(int, dword)")
# 呼び出し: SnmpSetPort(hEntity, nPort)
# hEntity : INT_PTR -> "int"
# nPort : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。