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

SnmpStrToEntity

関数
エンティティ名文字列からWinSNMPエンティティを生成する。
DLLwsnmp32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

INT_PTR SnmpStrToEntity(
    INT_PTR session,
    LPCSTR string
);

パラメーター

名前方向
sessionINT_PTRin
stringLPCSTRin

戻り値の型: INT_PTR

各言語での呼び出し定義

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

INT_PTR SnmpStrToEntity(
    INT_PTR session,
    LPCSTR string
);
[DllImport("wsnmp32.dll", ExactSpelling = true)]
static extern IntPtr SnmpStrToEntity(
    IntPtr session,   // INT_PTR
    [MarshalAs(UnmanagedType.LPStr)] string string   // LPCSTR
);
<DllImport("wsnmp32.dll", ExactSpelling:=True)>
Public Shared Function SnmpStrToEntity(
    session As IntPtr,   ' INT_PTR
    <MarshalAs(UnmanagedType.LPStr)> [string] As String   ' LPCSTR
) As IntPtr
End Function
' session : INT_PTR
' string : LPCSTR
Declare PtrSafe Function SnmpStrToEntity Lib "wsnmp32" ( _
    ByVal session As LongPtr, _
    ByVal string As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SnmpStrToEntity = ctypes.windll.wsnmp32.SnmpStrToEntity
SnmpStrToEntity.restype = ctypes.c_ssize_t
SnmpStrToEntity.argtypes = [
    ctypes.c_ssize_t,  # session : INT_PTR
    wintypes.LPCSTR,  # string : LPCSTR
]
require 'fiddle'
require 'fiddle/import'

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

var (
	wsnmp32 = windows.NewLazySystemDLL("wsnmp32.dll")
	procSnmpStrToEntity = wsnmp32.NewProc("SnmpStrToEntity")
)

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