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

SnmpContextToStr

関数
WinSNMPコンテキストをオクテット文字列に変換する。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD SnmpContextToStr(
    INT_PTR context,
    smiOCTETS* string
);

パラメーター

名前方向
contextINT_PTRin
stringsmiOCTETS*inout

戻り値の型: DWORD

各言語での呼び出し定義

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

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

SnmpContextToStr = ctypes.windll.wsnmp32.SnmpContextToStr
SnmpContextToStr.restype = wintypes.DWORD
SnmpContextToStr.argtypes = [
    ctypes.c_ssize_t,  # context : INT_PTR
    ctypes.c_void_p,  # string : smiOCTETS* in/out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('wsnmp32.dll')
SnmpContextToStr = Fiddle::Function.new(
  lib['SnmpContextToStr'],
  [
    Fiddle::TYPE_INTPTR_T,  # context : INT_PTR
    Fiddle::TYPE_VOIDP,  # string : smiOCTETS* in/out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "wsnmp32")]
extern "system" {
    fn SnmpContextToStr(
        context: isize,  // INT_PTR
        string: *mut smiOCTETS  // smiOCTETS* in/out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("wsnmp32.dll")]
public static extern uint SnmpContextToStr(IntPtr context, IntPtr string);
"@
$api = Add-Type -MemberDefinition $sig -Name 'wsnmp32_SnmpContextToStr' -Namespace Win32 -PassThru
# $api::SnmpContextToStr(context, string)
#uselib "wsnmp32.dll"
#func global SnmpContextToStr "SnmpContextToStr" sptr, sptr
; SnmpContextToStr context, varptr(string)   ; 戻り値は stat
; context : INT_PTR -> "sptr"
; string : smiOCTETS* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "wsnmp32.dll"
#cfunc global SnmpContextToStr "SnmpContextToStr" sptr, var
; res = SnmpContextToStr(context, string)
; context : INT_PTR -> "sptr"
; string : smiOCTETS* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD SnmpContextToStr(INT_PTR context, smiOCTETS* string)
#uselib "wsnmp32.dll"
#cfunc global SnmpContextToStr "SnmpContextToStr" intptr, var
; res = SnmpContextToStr(context, string)
; context : INT_PTR -> "intptr"
; string : smiOCTETS* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
	procSnmpContextToStr = wsnmp32.NewProc("SnmpContextToStr")
)

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