ホーム › System.EventNotificationService › IsDestinationReachableA
IsDestinationReachableA
関数指定宛先への到達可能性を確認する(ANSI版)。
シグネチャ
// SensApi.dll (ANSI / -A)
#include <windows.h>
BOOL IsDestinationReachableA(
LPCSTR lpszDestination,
QOCINFO* lpQOCInfo
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpszDestination | LPCSTR | in |
| lpQOCInfo | QOCINFO* | inout |
戻り値の型: BOOL
各言語での呼び出し定義
// SensApi.dll (ANSI / -A)
#include <windows.h>
BOOL IsDestinationReachableA(
LPCSTR lpszDestination,
QOCINFO* lpQOCInfo
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SensApi.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern bool IsDestinationReachableA(
[MarshalAs(UnmanagedType.LPStr)] string lpszDestination, // LPCSTR
IntPtr lpQOCInfo // QOCINFO* in/out
);<DllImport("SensApi.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function IsDestinationReachableA(
<MarshalAs(UnmanagedType.LPStr)> lpszDestination As String, ' LPCSTR
lpQOCInfo As IntPtr ' QOCINFO* in/out
) As Boolean
End Function' lpszDestination : LPCSTR
' lpQOCInfo : QOCINFO* in/out
Declare PtrSafe Function IsDestinationReachableA Lib "sensapi" ( _
ByVal lpszDestination As String, _
ByVal lpQOCInfo As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsDestinationReachableA = ctypes.windll.sensapi.IsDestinationReachableA
IsDestinationReachableA.restype = wintypes.BOOL
IsDestinationReachableA.argtypes = [
wintypes.LPCSTR, # lpszDestination : LPCSTR
ctypes.c_void_p, # lpQOCInfo : QOCINFO* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SensApi.dll')
IsDestinationReachableA = Fiddle::Function.new(
lib['IsDestinationReachableA'],
[
Fiddle::TYPE_VOIDP, # lpszDestination : LPCSTR
Fiddle::TYPE_VOIDP, # lpQOCInfo : QOCINFO* in/out
],
Fiddle::TYPE_INT)#[link(name = "sensapi")]
extern "system" {
fn IsDestinationReachableA(
lpszDestination: *const u8, // LPCSTR
lpQOCInfo: *mut QOCINFO // QOCINFO* in/out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SensApi.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern bool IsDestinationReachableA([MarshalAs(UnmanagedType.LPStr)] string lpszDestination, IntPtr lpQOCInfo);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SensApi_IsDestinationReachableA' -Namespace Win32 -PassThru
# $api::IsDestinationReachableA(lpszDestination, lpQOCInfo)#uselib "SensApi.dll"
#func global IsDestinationReachableA "IsDestinationReachableA" sptr, sptr
; IsDestinationReachableA lpszDestination, varptr(lpQOCInfo) ; 戻り値は stat
; lpszDestination : LPCSTR -> "sptr"
; lpQOCInfo : QOCINFO* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SensApi.dll" #cfunc global IsDestinationReachableA "IsDestinationReachableA" str, var ; res = IsDestinationReachableA(lpszDestination, lpQOCInfo) ; lpszDestination : LPCSTR -> "str" ; lpQOCInfo : QOCINFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SensApi.dll" #cfunc global IsDestinationReachableA "IsDestinationReachableA" str, sptr ; res = IsDestinationReachableA(lpszDestination, varptr(lpQOCInfo)) ; lpszDestination : LPCSTR -> "str" ; lpQOCInfo : QOCINFO* in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL IsDestinationReachableA(LPCSTR lpszDestination, QOCINFO* lpQOCInfo) #uselib "SensApi.dll" #cfunc global IsDestinationReachableA "IsDestinationReachableA" str, var ; res = IsDestinationReachableA(lpszDestination, lpQOCInfo) ; lpszDestination : LPCSTR -> "str" ; lpQOCInfo : QOCINFO* in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL IsDestinationReachableA(LPCSTR lpszDestination, QOCINFO* lpQOCInfo) #uselib "SensApi.dll" #cfunc global IsDestinationReachableA "IsDestinationReachableA" str, intptr ; res = IsDestinationReachableA(lpszDestination, varptr(lpQOCInfo)) ; lpszDestination : LPCSTR -> "str" ; lpQOCInfo : QOCINFO* in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
sensapi = windows.NewLazySystemDLL("SensApi.dll")
procIsDestinationReachableA = sensapi.NewProc("IsDestinationReachableA")
)
// lpszDestination (LPCSTR), lpQOCInfo (QOCINFO* in/out)
r1, _, err := procIsDestinationReachableA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpszDestination))),
uintptr(lpQOCInfo),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsDestinationReachableA(
lpszDestination: PAnsiChar; // LPCSTR
lpQOCInfo: Pointer // QOCINFO* in/out
): BOOL; stdcall;
external 'SensApi.dll' name 'IsDestinationReachableA';result := DllCall("SensApi\IsDestinationReachableA"
, "AStr", lpszDestination ; LPCSTR
, "Ptr", lpQOCInfo ; QOCINFO* in/out
, "Int") ; return: BOOL●IsDestinationReachableA(lpszDestination, lpQOCInfo) = DLL("SensApi.dll", "bool IsDestinationReachableA(char*, void*)")
# 呼び出し: IsDestinationReachableA(lpszDestination, lpQOCInfo)
# lpszDestination : LPCSTR -> "char*"
# lpQOCInfo : QOCINFO* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。