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

SetIpTTL

関数
送信IPパケットの既定のTTL(生存時間)値を設定する。
DLLIPHLPAPI.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD SetIpTTL(
    DWORD nTTL
);

パラメーター

名前方向
nTTLDWORDin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD SetIpTTL(
    DWORD nTTL
);
[DllImport("IPHLPAPI.dll", ExactSpelling = true)]
static extern uint SetIpTTL(
    uint nTTL   // DWORD
);
<DllImport("IPHLPAPI.dll", ExactSpelling:=True)>
Public Shared Function SetIpTTL(
    nTTL As UInteger   ' DWORD
) As UInteger
End Function
' nTTL : DWORD
Declare PtrSafe Function SetIpTTL Lib "iphlpapi" ( _
    ByVal nTTL As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SetIpTTL = ctypes.windll.iphlpapi.SetIpTTL
SetIpTTL.restype = wintypes.DWORD
SetIpTTL.argtypes = [
    wintypes.DWORD,  # nTTL : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('IPHLPAPI.dll')
SetIpTTL = Fiddle::Function.new(
  lib['SetIpTTL'],
  [
    -Fiddle::TYPE_INT,  # nTTL : DWORD
  ],
  -Fiddle::TYPE_INT)
#[link(name = "iphlpapi")]
extern "system" {
    fn SetIpTTL(
        nTTL: u32  // DWORD
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("IPHLPAPI.dll")]
public static extern uint SetIpTTL(uint nTTL);
"@
$api = Add-Type -MemberDefinition $sig -Name 'IPHLPAPI_SetIpTTL' -Namespace Win32 -PassThru
# $api::SetIpTTL(nTTL)
#uselib "IPHLPAPI.dll"
#func global SetIpTTL "SetIpTTL" sptr
; SetIpTTL nTTL   ; 戻り値は stat
; nTTL : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "IPHLPAPI.dll"
#cfunc global SetIpTTL "SetIpTTL" int
; res = SetIpTTL(nTTL)
; nTTL : DWORD -> "int"
; DWORD SetIpTTL(DWORD nTTL)
#uselib "IPHLPAPI.dll"
#cfunc global SetIpTTL "SetIpTTL" int
; res = SetIpTTL(nTTL)
; nTTL : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	iphlpapi = windows.NewLazySystemDLL("IPHLPAPI.dll")
	procSetIpTTL = iphlpapi.NewProc("SetIpTTL")
)

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