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

InternetLockRequestFile

関数
ダウンロード中のキャッシュファイルをロックして削除を防ぐ。
DLLWININET.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

BOOL InternetLockRequestFile(
    void* hInternet,
    HANDLE* lphLockRequestInfo
);

パラメーター

名前方向
hInternetvoid*in
lphLockRequestInfoHANDLE*out

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

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

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetLockRequestFile = wininet.NewProc("InternetLockRequestFile")
)

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