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

ImportCookieFileW

関数
指定ファイルからクッキーをインポートする(Unicode版)。
DLLWININET.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

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

BOOL ImportCookieFileW(
    LPCWSTR szFilename
);

パラメーター

名前方向
szFilenameLPCWSTRin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL ImportCookieFileW(
    LPCWSTR szFilename
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool ImportCookieFileW(
    [MarshalAs(UnmanagedType.LPWStr)] string szFilename   // LPCWSTR
);
<DllImport("WININET.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function ImportCookieFileW(
    <MarshalAs(UnmanagedType.LPWStr)> szFilename As String   ' LPCWSTR
) As Boolean
End Function
' szFilename : LPCWSTR
Declare PtrSafe Function ImportCookieFileW Lib "wininet" ( _
    ByVal szFilename As LongPtr) 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

ImportCookieFileW = ctypes.windll.wininet.ImportCookieFileW
ImportCookieFileW.restype = wintypes.BOOL
ImportCookieFileW.argtypes = [
    wintypes.LPCWSTR,  # szFilename : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
ImportCookieFileW = Fiddle::Function.new(
  lib['ImportCookieFileW'],
  [
    Fiddle::TYPE_VOIDP,  # szFilename : LPCWSTR
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn ImportCookieFileW(
        szFilename: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode)]
public static extern bool ImportCookieFileW([MarshalAs(UnmanagedType.LPWStr)] string szFilename);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_ImportCookieFileW' -Namespace Win32 -PassThru
# $api::ImportCookieFileW(szFilename)
#uselib "WININET.dll"
#func global ImportCookieFileW "ImportCookieFileW" wptr
; ImportCookieFileW szFilename   ; 戻り値は stat
; szFilename : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global ImportCookieFileW "ImportCookieFileW" wstr
; res = ImportCookieFileW(szFilename)
; szFilename : LPCWSTR -> "wstr"
; BOOL ImportCookieFileW(LPCWSTR szFilename)
#uselib "WININET.dll"
#cfunc global ImportCookieFileW "ImportCookieFileW" wstr
; res = ImportCookieFileW(szFilename)
; szFilename : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procImportCookieFileW = wininet.NewProc("ImportCookieFileW")
)

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