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

InternetGetLastResponseInfoW

関数
直近のWinINet操作のエラー応答テキストを取得する(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL InternetGetLastResponseInfoW(
    DWORD* lpdwError,
    LPWSTR lpszBuffer,   // optional
    DWORD* lpdwBufferLength
);

パラメーター

名前方向
lpdwErrorDWORD*out
lpszBufferLPWSTRoutoptional
lpdwBufferLengthDWORD*inout

戻り値の型: BOOL

各言語での呼び出し定義

// WININET.dll  (Unicode / -W)
#include <windows.h>

BOOL InternetGetLastResponseInfoW(
    DWORD* lpdwError,
    LPWSTR lpszBuffer,   // optional
    DWORD* lpdwBufferLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern bool InternetGetLastResponseInfoW(
    out uint lpdwError,   // DWORD* out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszBuffer,   // LPWSTR optional, out
    ref uint lpdwBufferLength   // DWORD* in/out
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function InternetGetLastResponseInfoW(
    <Out> ByRef lpdwError As UInteger,   ' DWORD* out
    <MarshalAs(UnmanagedType.LPWStr)> lpszBuffer As System.Text.StringBuilder,   ' LPWSTR optional, out
    ByRef lpdwBufferLength As UInteger   ' DWORD* in/out
) As Boolean
End Function
' lpdwError : DWORD* out
' lpszBuffer : LPWSTR optional, out
' lpdwBufferLength : DWORD* in/out
Declare PtrSafe Function InternetGetLastResponseInfoW Lib "wininet" ( _
    ByRef lpdwError As Long, _
    ByVal lpszBuffer As LongPtr, _
    ByRef lpdwBufferLength As Long) As Long
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

InternetGetLastResponseInfoW = ctypes.windll.wininet.InternetGetLastResponseInfoW
InternetGetLastResponseInfoW.restype = wintypes.BOOL
InternetGetLastResponseInfoW.argtypes = [
    ctypes.POINTER(wintypes.DWORD),  # lpdwError : DWORD* out
    wintypes.LPWSTR,  # lpszBuffer : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # lpdwBufferLength : DWORD* in/out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
InternetGetLastResponseInfoW = Fiddle::Function.new(
  lib['InternetGetLastResponseInfoW'],
  [
    Fiddle::TYPE_VOIDP,  # lpdwError : DWORD* out
    Fiddle::TYPE_VOIDP,  # lpszBuffer : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # lpdwBufferLength : DWORD* in/out
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn InternetGetLastResponseInfoW(
        lpdwError: *mut u32,  // DWORD* out
        lpszBuffer: *mut u16,  // LPWSTR optional, out
        lpdwBufferLength: *mut u32  // DWORD* in/out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool InternetGetLastResponseInfoW(out uint lpdwError, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszBuffer, ref uint lpdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetGetLastResponseInfoW' -Namespace Win32 -PassThru
# $api::InternetGetLastResponseInfoW(lpdwError, lpszBuffer, lpdwBufferLength)
#uselib "WININET.dll"
#func global InternetGetLastResponseInfoW "InternetGetLastResponseInfoW" wptr, wptr, wptr
; InternetGetLastResponseInfoW varptr(lpdwError), varptr(lpszBuffer), varptr(lpdwBufferLength)   ; 戻り値は stat
; lpdwError : DWORD* out -> "wptr"
; lpszBuffer : LPWSTR optional, out -> "wptr"
; lpdwBufferLength : DWORD* in/out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global InternetGetLastResponseInfoW "InternetGetLastResponseInfoW" var, var, var
; res = InternetGetLastResponseInfoW(lpdwError, lpszBuffer, lpdwBufferLength)
; lpdwError : DWORD* out -> "var"
; lpszBuffer : LPWSTR optional, out -> "var"
; lpdwBufferLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL InternetGetLastResponseInfoW(DWORD* lpdwError, LPWSTR lpszBuffer, DWORD* lpdwBufferLength)
#uselib "WININET.dll"
#cfunc global InternetGetLastResponseInfoW "InternetGetLastResponseInfoW" var, var, var
; res = InternetGetLastResponseInfoW(lpdwError, lpszBuffer, lpdwBufferLength)
; lpdwError : DWORD* out -> "var"
; lpszBuffer : LPWSTR optional, out -> "var"
; lpdwBufferLength : DWORD* in/out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetGetLastResponseInfoW = wininet.NewProc("InternetGetLastResponseInfoW")
)

// lpdwError (DWORD* out), lpszBuffer (LPWSTR optional, out), lpdwBufferLength (DWORD* in/out)
r1, _, err := procInternetGetLastResponseInfoW.Call(
	uintptr(lpdwError),
	uintptr(lpszBuffer),
	uintptr(lpdwBufferLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InternetGetLastResponseInfoW(
  lpdwError: Pointer;   // DWORD* out
  lpszBuffer: PWideChar;   // LPWSTR optional, out
  lpdwBufferLength: Pointer   // DWORD* in/out
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetGetLastResponseInfoW';
result := DllCall("WININET\InternetGetLastResponseInfoW"
    , "Ptr", lpdwError   ; DWORD* out
    , "Ptr", lpszBuffer   ; LPWSTR optional, out
    , "Ptr", lpdwBufferLength   ; DWORD* in/out
    , "Int")   ; return: BOOL
●InternetGetLastResponseInfoW(lpdwError, lpszBuffer, lpdwBufferLength) = DLL("WININET.dll", "bool InternetGetLastResponseInfoW(void*, char*, void*)")
# 呼び出し: InternetGetLastResponseInfoW(lpdwError, lpszBuffer, lpdwBufferLength)
# lpdwError : DWORD* out -> "void*"
# lpszBuffer : LPWSTR optional, out -> "char*"
# lpdwBufferLength : DWORD* in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。