ホーム › Networking.WinInet › InternetGetPerSiteCookieDecisionW
InternetGetPerSiteCookieDecisionW
関数サイト別のCookie許可設定を取得する(Unicode版)。
シグネチャ
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL InternetGetPerSiteCookieDecisionW(
LPCWSTR pchHostName,
DWORD* pResult
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pchHostName | LPCWSTR | in | ドメインを格納した文字列を指すLPCTSTR。 |
| pResult | DWORD* | out | InternetCookieState 列挙体の値のいずれか1つを格納するunsigned longへのポインター。 |
戻り値の型: BOOL
公式ドキュメント
指定されたドメインに対する Cookie の判定結果を取得します。(Unicode)
戻り値
判定結果を取得できた場合はTRUE、それ以外の場合はFALSEを返します。
解説(Remarks)
戻り値がFALSEの場合は、ドメイン pchHostName にサイト固有の Cookie 規制が設定されていない可能性があります。
WinINet は pchHostName パラメーターで指定されたドメインを最小化し、有効な最小のドメインに Cookie ポリシーを設定します。たとえば、指定されたホスト名が widgets.microsoft.com の場合、ポリシーは最小化されたホスト名 microsoft.com に設定されます。
WinINet API の他のすべての側面と同様に、この関数を DllMain やグローバルオブジェクトのコンストラクター・デストラクター内から安全に呼び出すことはできません。
Note WinINet はサーバー実装をサポートしていません。また、サービスからも使用しないでください。サーバー実装やサービスでは Microsoft Windows HTTP Services (WinHTTP) を使用してください。
メモ
wininet.h ヘッダーは InternetGetPerSiteCookieDecision を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義します。エンコーディング中立のエイリアスの使用を、エンコーディング中立でないコードと混在させると、不整合が生じてコンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// WININET.dll (Unicode / -W)
#include <windows.h>
BOOL InternetGetPerSiteCookieDecisionW(
LPCWSTR pchHostName,
DWORD* pResult
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool InternetGetPerSiteCookieDecisionW(
[MarshalAs(UnmanagedType.LPWStr)] string pchHostName, // LPCWSTR
out uint pResult // DWORD* out
);<DllImport("WININET.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function InternetGetPerSiteCookieDecisionW(
<MarshalAs(UnmanagedType.LPWStr)> pchHostName As String, ' LPCWSTR
<Out> ByRef pResult As UInteger ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pchHostName : LPCWSTR
' pResult : DWORD* out
Declare PtrSafe Function InternetGetPerSiteCookieDecisionW Lib "wininet" ( _
ByVal pchHostName As LongPtr, _
ByRef pResult 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
InternetGetPerSiteCookieDecisionW = ctypes.windll.wininet.InternetGetPerSiteCookieDecisionW
InternetGetPerSiteCookieDecisionW.restype = wintypes.BOOL
InternetGetPerSiteCookieDecisionW.argtypes = [
wintypes.LPCWSTR, # pchHostName : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # pResult : DWORD* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
InternetGetPerSiteCookieDecisionW = Fiddle::Function.new(
lib['InternetGetPerSiteCookieDecisionW'],
[
Fiddle::TYPE_VOIDP, # pchHostName : LPCWSTR
Fiddle::TYPE_VOIDP, # pResult : DWORD* out
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "wininet")]
extern "system" {
fn InternetGetPerSiteCookieDecisionW(
pchHostName: *const u16, // LPCWSTR
pResult: *mut u32 // DWORD* out
) -> 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 InternetGetPerSiteCookieDecisionW([MarshalAs(UnmanagedType.LPWStr)] string pchHostName, out uint pResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetGetPerSiteCookieDecisionW' -Namespace Win32 -PassThru
# $api::InternetGetPerSiteCookieDecisionW(pchHostName, pResult)#uselib "WININET.dll"
#func global InternetGetPerSiteCookieDecisionW "InternetGetPerSiteCookieDecisionW" wptr, wptr
; InternetGetPerSiteCookieDecisionW pchHostName, varptr(pResult) ; 戻り値は stat
; pchHostName : LPCWSTR -> "wptr"
; pResult : DWORD* out -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global InternetGetPerSiteCookieDecisionW "InternetGetPerSiteCookieDecisionW" wstr, var ; res = InternetGetPerSiteCookieDecisionW(pchHostName, pResult) ; pchHostName : LPCWSTR -> "wstr" ; pResult : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global InternetGetPerSiteCookieDecisionW "InternetGetPerSiteCookieDecisionW" wstr, sptr ; res = InternetGetPerSiteCookieDecisionW(pchHostName, varptr(pResult)) ; pchHostName : LPCWSTR -> "wstr" ; pResult : DWORD* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; BOOL InternetGetPerSiteCookieDecisionW(LPCWSTR pchHostName, DWORD* pResult) #uselib "WININET.dll" #cfunc global InternetGetPerSiteCookieDecisionW "InternetGetPerSiteCookieDecisionW" wstr, var ; res = InternetGetPerSiteCookieDecisionW(pchHostName, pResult) ; pchHostName : LPCWSTR -> "wstr" ; pResult : DWORD* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; BOOL InternetGetPerSiteCookieDecisionW(LPCWSTR pchHostName, DWORD* pResult) #uselib "WININET.dll" #cfunc global InternetGetPerSiteCookieDecisionW "InternetGetPerSiteCookieDecisionW" wstr, intptr ; res = InternetGetPerSiteCookieDecisionW(pchHostName, varptr(pResult)) ; pchHostName : LPCWSTR -> "wstr" ; pResult : DWORD* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procInternetGetPerSiteCookieDecisionW = wininet.NewProc("InternetGetPerSiteCookieDecisionW")
)
// pchHostName (LPCWSTR), pResult (DWORD* out)
r1, _, err := procInternetGetPerSiteCookieDecisionW.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pchHostName))),
uintptr(pResult),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction InternetGetPerSiteCookieDecisionW(
pchHostName: PWideChar; // LPCWSTR
pResult: Pointer // DWORD* out
): BOOL; stdcall;
external 'WININET.dll' name 'InternetGetPerSiteCookieDecisionW';result := DllCall("WININET\InternetGetPerSiteCookieDecisionW"
, "WStr", pchHostName ; LPCWSTR
, "Ptr", pResult ; DWORD* out
, "Int") ; return: BOOL●InternetGetPerSiteCookieDecisionW(pchHostName, pResult) = DLL("WININET.dll", "bool InternetGetPerSiteCookieDecisionW(char*, void*)")
# 呼び出し: InternetGetPerSiteCookieDecisionW(pchHostName, pResult)
# pchHostName : LPCWSTR -> "char*"
# pResult : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "wininet" fn InternetGetPerSiteCookieDecisionW(
pchHostName: [*c]const u16, // LPCWSTR
pResult: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc InternetGetPerSiteCookieDecisionW(
pchHostName: WideCString, # LPCWSTR
pResult: ptr uint32 # DWORD* out
): int32 {.importc: "InternetGetPerSiteCookieDecisionW", stdcall, dynlib: "WININET.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "wininet");
extern(Windows)
int InternetGetPerSiteCookieDecisionW(
const(wchar)* pchHostName, // LPCWSTR
uint* pResult // DWORD* out
);ccall((:InternetGetPerSiteCookieDecisionW, "WININET.dll"), stdcall, Int32,
(Cwstring, Ptr{UInt32}),
pchHostName, pResult)
# pchHostName : LPCWSTR -> Cwstring
# pResult : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t InternetGetPerSiteCookieDecisionW(
const uint16_t* pchHostName,
uint32_t* pResult);
]]
local wininet = ffi.load("wininet")
-- wininet.InternetGetPerSiteCookieDecisionW(pchHostName, pResult)
-- pchHostName : LPCWSTR
-- pResult : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const InternetGetPerSiteCookieDecisionW = lib.func('__stdcall', 'InternetGetPerSiteCookieDecisionW', 'int32_t', ['str16', 'uint32_t *']);
// InternetGetPerSiteCookieDecisionW(pchHostName, pResult)
// pchHostName : LPCWSTR -> 'str16'
// pResult : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
InternetGetPerSiteCookieDecisionW: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.InternetGetPerSiteCookieDecisionW(pchHostName, pResult)
// pchHostName : LPCWSTR -> "buffer"
// pResult : DWORD* out -> "pointer"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t InternetGetPerSiteCookieDecisionW(
const uint16_t* pchHostName,
uint32_t* pResult);
C, "WININET.dll");
// $ffi->InternetGetPerSiteCookieDecisionW(pchHostName, pResult);
// pchHostName : LPCWSTR
// pResult : DWORD* out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Wininet extends StdCallLibrary {
Wininet INSTANCE = Native.load("wininet", Wininet.class, W32APIOptions.UNICODE_OPTIONS);
boolean InternetGetPerSiteCookieDecisionW(
WString pchHostName, // LPCWSTR
IntByReference pResult // DWORD* out
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("wininet")]
lib LibWININET
fun InternetGetPerSiteCookieDecisionW = InternetGetPerSiteCookieDecisionW(
pchHostName : UInt16*, # LPCWSTR
pResult : UInt32* # DWORD* out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef InternetGetPerSiteCookieDecisionWNative = Int32 Function(Pointer<Utf16>, Pointer<Uint32>);
typedef InternetGetPerSiteCookieDecisionWDart = int Function(Pointer<Utf16>, Pointer<Uint32>);
final InternetGetPerSiteCookieDecisionW = DynamicLibrary.open('WININET.dll')
.lookupFunction<InternetGetPerSiteCookieDecisionWNative, InternetGetPerSiteCookieDecisionWDart>('InternetGetPerSiteCookieDecisionW');
// pchHostName : LPCWSTR -> Pointer<Utf16>
// pResult : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function InternetGetPerSiteCookieDecisionW(
pchHostName: PWideChar; // LPCWSTR
pResult: Pointer // DWORD* out
): BOOL; stdcall;
external 'WININET.dll' name 'InternetGetPerSiteCookieDecisionW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "InternetGetPerSiteCookieDecisionW"
c_InternetGetPerSiteCookieDecisionW :: CWString -> Ptr Word32 -> IO CInt
-- pchHostName : LPCWSTR -> CWString
-- pResult : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let internetgetpersitecookiedecisionw =
foreign "InternetGetPerSiteCookieDecisionW"
((ptr uint16_t) @-> (ptr uint32_t) @-> returning int32_t)
(* pchHostName : LPCWSTR -> (ptr uint16_t) *)
(* pResult : DWORD* out -> (ptr uint32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library wininet (t "WININET.dll"))
(cffi:use-foreign-library wininet)
(cffi:defcfun ("InternetGetPerSiteCookieDecisionW" internet-get-per-site-cookie-decision-w :convention :stdcall) :int32
(pch-host-name (:string :encoding :utf-16le)) ; LPCWSTR
(p-result :pointer)) ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $InternetGetPerSiteCookieDecisionW = Win32::API::More->new('WININET',
'BOOL InternetGetPerSiteCookieDecisionW(LPCWSTR pchHostName, LPVOID pResult)');
# my $ret = $InternetGetPerSiteCookieDecisionW->Call($pchHostName, $pResult);
# pchHostName : LPCWSTR -> LPCWSTR
# pResult : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f InternetGetPerSiteCookieDecisionA (ANSI版) — サイト別のCookie許可設定を取得する(ANSI版)。
公式の関連項目
- f InternetClearAllPerSiteCookieDecisions — 全サイトのCookie許可設定をクリアする。
- f InternetEnumPerSiteCookieDecisionW — サイト別Cookie許可設定を順に列挙する(Unicode版)。
- f InternetSetPerSiteCookieDecisionW — サイト別のCookie許可設定を行う(Unicode版)。
- f PrivacyGetZonePreferenceW — セキュリティゾーンのプライバシー設定を取得する(Unicode版)。
- f PrivacySetZonePreferenceW — セキュリティゾーンのプライバシー設定を行う(Unicode版)。