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

ExportCookieFileW

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

シグネチャ

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

BOOL ExportCookieFileW(
    LPCWSTR szFilename,
    BOOL fAppend
);

パラメーター

名前方向
szFilenameLPCWSTRin
fAppendBOOLin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

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

lib = Fiddle.dlopen('WININET.dll')
ExportCookieFileW = Fiddle::Function.new(
  lib['ExportCookieFileW'],
  [
    Fiddle::TYPE_VOIDP,  # szFilename : LPCWSTR
    Fiddle::TYPE_INT,  # fAppend : BOOL
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "wininet")]
extern "system" {
    fn ExportCookieFileW(
        szFilename: *const u16,  // LPCWSTR
        fAppend: i32  // BOOL
    ) -> 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 ExportCookieFileW([MarshalAs(UnmanagedType.LPWStr)] string szFilename, bool fAppend);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_ExportCookieFileW' -Namespace Win32 -PassThru
# $api::ExportCookieFileW(szFilename, fAppend)
#uselib "WININET.dll"
#func global ExportCookieFileW "ExportCookieFileW" wptr, wptr
; ExportCookieFileW szFilename, fAppend   ; 戻り値は stat
; szFilename : LPCWSTR -> "wptr"
; fAppend : BOOL -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "WININET.dll"
#cfunc global ExportCookieFileW "ExportCookieFileW" wstr, int
; res = ExportCookieFileW(szFilename, fAppend)
; szFilename : LPCWSTR -> "wstr"
; fAppend : BOOL -> "int"
; BOOL ExportCookieFileW(LPCWSTR szFilename, BOOL fAppend)
#uselib "WININET.dll"
#cfunc global ExportCookieFileW "ExportCookieFileW" wstr, int
; res = ExportCookieFileW(szFilename, fAppend)
; szFilename : LPCWSTR -> "wstr"
; fAppend : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procExportCookieFileW = wininet.NewProc("ExportCookieFileW")
)

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