Win32 API 日本語リファレンス
ホームNetworking.WinHttp › WinHttpCloseHandle

WinHttpCloseHandle

関数
WinHTTPハンドルを閉じてリソースを解放する。
DLLWINHTTP.dll呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

BOOL WinHttpCloseHandle(
    void* hInternet
);

パラメーター

名前方向
hInternetvoid*inout

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL WinHttpCloseHandle(
    void* hInternet
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINHTTP.dll", SetLastError = true, ExactSpelling = true)]
static extern bool WinHttpCloseHandle(
    IntPtr hInternet   // void* in/out
);
<DllImport("WINHTTP.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function WinHttpCloseHandle(
    hInternet As IntPtr   ' void* in/out
) As Boolean
End Function
' hInternet : void* in/out
Declare PtrSafe Function WinHttpCloseHandle Lib "winhttp" ( _
    ByVal hInternet As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

WinHttpCloseHandle = ctypes.windll.winhttp.WinHttpCloseHandle
WinHttpCloseHandle.restype = wintypes.BOOL
WinHttpCloseHandle.argtypes = [
    ctypes.POINTER(None),  # hInternet : void* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WINHTTP.dll')
WinHttpCloseHandle = Fiddle::Function.new(
  lib['WinHttpCloseHandle'],
  [
    Fiddle::TYPE_VOIDP,  # hInternet : void* in/out
  ],
  Fiddle::TYPE_INT)
#[link(name = "winhttp")]
extern "system" {
    fn WinHttpCloseHandle(
        hInternet: *mut ()  // void* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WINHTTP.dll", SetLastError = true)]
public static extern bool WinHttpCloseHandle(IntPtr hInternet);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WINHTTP_WinHttpCloseHandle' -Namespace Win32 -PassThru
# $api::WinHttpCloseHandle(hInternet)
#uselib "WINHTTP.dll"
#func global WinHttpCloseHandle "WinHttpCloseHandle" sptr
; WinHttpCloseHandle hInternet   ; 戻り値は stat
; hInternet : void* in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WINHTTP.dll"
#cfunc global WinHttpCloseHandle "WinHttpCloseHandle" sptr
; res = WinHttpCloseHandle(hInternet)
; hInternet : void* in/out -> "sptr"
; BOOL WinHttpCloseHandle(void* hInternet)
#uselib "WINHTTP.dll"
#cfunc global WinHttpCloseHandle "WinHttpCloseHandle" intptr
; res = WinHttpCloseHandle(hInternet)
; hInternet : void* in/out -> "intptr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	winhttp = windows.NewLazySystemDLL("WINHTTP.dll")
	procWinHttpCloseHandle = winhttp.NewProc("WinHttpCloseHandle")
)

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