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

SnmpMgrOidToStr

関数
SNMPのOIDをドット区切りの文字列に変換する。
DLLmgmtapi.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL SnmpMgrOidToStr(
    AsnObjectIdentifier* oid,
    LPSTR* string   // optional
);

パラメーター

名前方向
oidAsnObjectIdentifier*inout
stringLPSTR*outoptional

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL SnmpMgrOidToStr(
    AsnObjectIdentifier* oid,
    LPSTR* string   // optional
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("mgmtapi.dll", ExactSpelling = true)]
static extern bool SnmpMgrOidToStr(
    IntPtr oid,   // AsnObjectIdentifier* in/out
    IntPtr string   // LPSTR* optional, out
);
<DllImport("mgmtapi.dll", ExactSpelling:=True)>
Public Shared Function SnmpMgrOidToStr(
    oid As IntPtr,   ' AsnObjectIdentifier* in/out
    [string] As IntPtr   ' LPSTR* optional, out
) As Boolean
End Function
' oid : AsnObjectIdentifier* in/out
' string : LPSTR* optional, out
Declare PtrSafe Function SnmpMgrOidToStr Lib "mgmtapi" ( _
    ByVal oid 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

SnmpMgrOidToStr = ctypes.windll.mgmtapi.SnmpMgrOidToStr
SnmpMgrOidToStr.restype = wintypes.BOOL
SnmpMgrOidToStr.argtypes = [
    ctypes.c_void_p,  # oid : AsnObjectIdentifier* in/out
    ctypes.c_void_p,  # string : LPSTR* optional, out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	mgmtapi = windows.NewLazySystemDLL("mgmtapi.dll")
	procSnmpMgrOidToStr = mgmtapi.NewProc("SnmpMgrOidToStr")
)

// oid (AsnObjectIdentifier* in/out), string (LPSTR* optional, out)
r1, _, err := procSnmpMgrOidToStr.Call(
	uintptr(oid),
	uintptr(string),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function SnmpMgrOidToStr(
  oid: Pointer;   // AsnObjectIdentifier* in/out
  string: PPAnsiChar   // LPSTR* optional, out
): BOOL; stdcall;
  external 'mgmtapi.dll' name 'SnmpMgrOidToStr';
result := DllCall("mgmtapi\SnmpMgrOidToStr"
    , "Ptr", oid   ; AsnObjectIdentifier* in/out
    , "Ptr", string   ; LPSTR* optional, out
    , "Int")   ; return: BOOL
●SnmpMgrOidToStr(oid, string) = DLL("mgmtapi.dll", "bool SnmpMgrOidToStr(void*, void*)")
# 呼び出し: SnmpMgrOidToStr(oid, string)
# oid : AsnObjectIdentifier* in/out -> "void*"
# string : LPSTR* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。