ホーム › NetworkManagement.Snmp › SnmpMgrOidToStr
SnmpMgrOidToStr
関数SNMPのOIDをドット区切りの文字列に変換する。
シグネチャ
// mgmtapi.dll
#include <windows.h>
BOOL SnmpMgrOidToStr(
AsnObjectIdentifier* oid,
LPSTR* string // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| oid | AsnObjectIdentifier* | inout |
| string | LPSTR* | 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 方式にも切替可。#uselib "mgmtapi.dll" #cfunc global SnmpMgrOidToStr "SnmpMgrOidToStr" sptr, sptr ; res = SnmpMgrOidToStr(varptr(oid), varptr(string)) ; oid : AsnObjectIdentifier* in/out -> "sptr" ; string : LPSTR* optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; BOOL SnmpMgrOidToStr(AsnObjectIdentifier* oid, LPSTR* string) #uselib "mgmtapi.dll" #cfunc global SnmpMgrOidToStr "SnmpMgrOidToStr" intptr, intptr ; res = SnmpMgrOidToStr(varptr(oid), varptr(string)) ; oid : AsnObjectIdentifier* in/out -> "intptr" ; string : LPSTR* optional, out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // BOOLfunction 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)。