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

InternetGetPerSiteCookieDecisionA

関数
サイト別のCookie許可設定を取得する(ANSI版)。
DLLWININET.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL InternetGetPerSiteCookieDecisionA(
    LPCSTR pchHostName,
    DWORD* pResult
);

パラメーター

名前方向説明
pchHostNameLPCSTRinドメインを含む文字列を指す LPCTSTR です。
pResultDWORD*outInternetCookieState 列挙値のいずれかを格納する unsigned long へのポインターです。

戻り値の型: BOOL

公式ドキュメント

指定したドメインに対する Cookie の判定を取得します。(ANSI)

戻り値

判定を取得できた場合は 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 ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして InternetGetPerSiteCookieDecision を定義しています。エンコーディング非依存のエイリアスを、エンコーディング非依存ではないコードと混在させて使用すると、不一致が生じ、コンパイルエラーやランタイムエラーを引き起こす可能性があります。詳細については、Conventions for Function Prototypes を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// WININET.dll  (ANSI / -A)
#include <windows.h>

BOOL InternetGetPerSiteCookieDecisionA(
    LPCSTR pchHostName,
    DWORD* pResult
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("WININET.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool InternetGetPerSiteCookieDecisionA(
    [MarshalAs(UnmanagedType.LPStr)] string pchHostName,   // LPCSTR
    out uint pResult   // DWORD* out
);
<DllImport("WININET.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function InternetGetPerSiteCookieDecisionA(
    <MarshalAs(UnmanagedType.LPStr)> pchHostName As String,   ' LPCSTR
    <Out> ByRef pResult As UInteger   ' DWORD* out
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pchHostName : LPCSTR
' pResult : DWORD* out
Declare PtrSafe Function InternetGetPerSiteCookieDecisionA Lib "wininet" ( _
    ByVal pchHostName As String, _
    ByRef pResult As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

InternetGetPerSiteCookieDecisionA = ctypes.windll.wininet.InternetGetPerSiteCookieDecisionA
InternetGetPerSiteCookieDecisionA.restype = wintypes.BOOL
InternetGetPerSiteCookieDecisionA.argtypes = [
    wintypes.LPCSTR,  # pchHostName : LPCSTR
    ctypes.POINTER(wintypes.DWORD),  # pResult : DWORD* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('WININET.dll')
InternetGetPerSiteCookieDecisionA = Fiddle::Function.new(
  lib['InternetGetPerSiteCookieDecisionA'],
  [
    Fiddle::TYPE_VOIDP,  # pchHostName : LPCSTR
    Fiddle::TYPE_VOIDP,  # pResult : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "wininet")]
extern "system" {
    fn InternetGetPerSiteCookieDecisionA(
        pchHostName: *const u8,  // LPCSTR
        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.Ansi)]
public static extern bool InternetGetPerSiteCookieDecisionA([MarshalAs(UnmanagedType.LPStr)] string pchHostName, out uint pResult);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_InternetGetPerSiteCookieDecisionA' -Namespace Win32 -PassThru
# $api::InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
#uselib "WININET.dll"
#func global InternetGetPerSiteCookieDecisionA "InternetGetPerSiteCookieDecisionA" sptr, sptr
; InternetGetPerSiteCookieDecisionA pchHostName, varptr(pResult)   ; 戻り値は stat
; pchHostName : LPCSTR -> "sptr"
; pResult : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "WININET.dll"
#cfunc global InternetGetPerSiteCookieDecisionA "InternetGetPerSiteCookieDecisionA" str, var
; res = InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
; pchHostName : LPCSTR -> "str"
; pResult : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL InternetGetPerSiteCookieDecisionA(LPCSTR pchHostName, DWORD* pResult)
#uselib "WININET.dll"
#cfunc global InternetGetPerSiteCookieDecisionA "InternetGetPerSiteCookieDecisionA" str, var
; res = InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
; pchHostName : LPCSTR -> "str"
; pResult : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	wininet = windows.NewLazySystemDLL("WININET.dll")
	procInternetGetPerSiteCookieDecisionA = wininet.NewProc("InternetGetPerSiteCookieDecisionA")
)

// pchHostName (LPCSTR), pResult (DWORD* out)
r1, _, err := procInternetGetPerSiteCookieDecisionA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pchHostName))),
	uintptr(pResult),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function InternetGetPerSiteCookieDecisionA(
  pchHostName: PAnsiChar;   // LPCSTR
  pResult: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetGetPerSiteCookieDecisionA';
result := DllCall("WININET\InternetGetPerSiteCookieDecisionA"
    , "AStr", pchHostName   ; LPCSTR
    , "Ptr", pResult   ; DWORD* out
    , "Int")   ; return: BOOL
●InternetGetPerSiteCookieDecisionA(pchHostName, pResult) = DLL("WININET.dll", "bool InternetGetPerSiteCookieDecisionA(char*, void*)")
# 呼び出し: InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
# pchHostName : LPCSTR -> "char*"
# pResult : DWORD* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "wininet" fn InternetGetPerSiteCookieDecisionA(
    pchHostName: [*c]const u8, // LPCSTR
    pResult: [*c]u32 // DWORD* out
) callconv(std.os.windows.WINAPI) i32;
proc InternetGetPerSiteCookieDecisionA(
    pchHostName: cstring,  # LPCSTR
    pResult: ptr uint32  # DWORD* out
): int32 {.importc: "InternetGetPerSiteCookieDecisionA", stdcall, dynlib: "WININET.dll".}
pragma(lib, "wininet");
extern(Windows)
int InternetGetPerSiteCookieDecisionA(
    const(char)* pchHostName,   // LPCSTR
    uint* pResult   // DWORD* out
);
ccall((:InternetGetPerSiteCookieDecisionA, "WININET.dll"), stdcall, Int32,
      (Cstring, Ptr{UInt32}),
      pchHostName, pResult)
# pchHostName : LPCSTR -> Cstring
# pResult : DWORD* out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t InternetGetPerSiteCookieDecisionA(
    const char* pchHostName,
    uint32_t* pResult);
]]
local wininet = ffi.load("wininet")
-- wininet.InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
-- pchHostName : LPCSTR
-- pResult : DWORD* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const InternetGetPerSiteCookieDecisionA = lib.func('__stdcall', 'InternetGetPerSiteCookieDecisionA', 'int32_t', ['str', 'uint32_t *']);
// InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
// pchHostName : LPCSTR -> 'str'
// pResult : DWORD* out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("WININET.dll", {
  InternetGetPerSiteCookieDecisionA: { parameters: ["buffer", "pointer"], result: "i32" },
});
// lib.symbols.InternetGetPerSiteCookieDecisionA(pchHostName, pResult)
// pchHostName : LPCSTR -> "buffer"
// pResult : DWORD* out -> "pointer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t InternetGetPerSiteCookieDecisionA(
    const char* pchHostName,
    uint32_t* pResult);
C, "WININET.dll");
// $ffi->InternetGetPerSiteCookieDecisionA(pchHostName, pResult);
// pchHostName : LPCSTR
// 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.ASCII_OPTIONS);
    boolean InternetGetPerSiteCookieDecisionA(
        String pchHostName,   // LPCSTR
        IntByReference pResult   // DWORD* out
    );
}
@[Link("wininet")]
lib LibWININET
  fun InternetGetPerSiteCookieDecisionA = InternetGetPerSiteCookieDecisionA(
    pchHostName : UInt8*,   # LPCSTR
    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 InternetGetPerSiteCookieDecisionANative = Int32 Function(Pointer<Utf8>, Pointer<Uint32>);
typedef InternetGetPerSiteCookieDecisionADart = int Function(Pointer<Utf8>, Pointer<Uint32>);
final InternetGetPerSiteCookieDecisionA = DynamicLibrary.open('WININET.dll')
    .lookupFunction<InternetGetPerSiteCookieDecisionANative, InternetGetPerSiteCookieDecisionADart>('InternetGetPerSiteCookieDecisionA');
// pchHostName : LPCSTR -> Pointer<Utf8>
// pResult : DWORD* out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function InternetGetPerSiteCookieDecisionA(
  pchHostName: PAnsiChar;   // LPCSTR
  pResult: Pointer   // DWORD* out
): BOOL; stdcall;
  external 'WININET.dll' name 'InternetGetPerSiteCookieDecisionA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "InternetGetPerSiteCookieDecisionA"
  c_InternetGetPerSiteCookieDecisionA :: CString -> Ptr Word32 -> IO CInt
-- pchHostName : LPCSTR -> CString
-- pResult : DWORD* out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let internetgetpersitecookiedecisiona =
  foreign "InternetGetPerSiteCookieDecisionA"
    (string @-> (ptr uint32_t) @-> returning int32_t)
(* pchHostName : LPCSTR -> string *)
(* 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 ("InternetGetPerSiteCookieDecisionA" internet-get-per-site-cookie-decision-a :convention :stdcall) :int32
  (pch-host-name :string)   ; LPCSTR
  (p-result :pointer))   ; DWORD* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $InternetGetPerSiteCookieDecisionA = Win32::API::More->new('WININET',
    'BOOL InternetGetPerSiteCookieDecisionA(LPCSTR pchHostName, LPVOID pResult)');
# my $ret = $InternetGetPerSiteCookieDecisionA->Call($pchHostName, $pResult);
# pchHostName : LPCSTR -> LPCSTR
# pResult : DWORD* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
公式の関連項目