ホーム › Networking.WinInet › PrivacyGetZonePreferenceW
PrivacyGetZonePreferenceW
関数セキュリティゾーンのプライバシー設定を取得する(Unicode版)。
シグネチャ
// WININET.dll
#include <windows.h>
DWORD PrivacyGetZonePreferenceW(
DWORD dwZone,
DWORD dwType,
DWORD* pdwTemplate, // optional
LPWSTR pszBuffer, // optional
DWORD* pdwBufferLength // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwZone | DWORD | in | プライバシー設定を取得する対象の URLZONE を指定する DWORD 型の値です。 |
| dwType | DWORD | in | プライバシー設定を取得する対象の PrivacyType を指定する DWORD 型の値です。 |
| pdwTemplate | DWORD* | outoptional | この dwZone および dwType に対して使用されている PrivacyTemplates を格納した DWORD へのポインターを返す LPDWORD です。 |
| pszBuffer | LPWSTR | outoptional | pdwTemplate の文字列表現を表す LPCWSTR、または pdwTemplate が PRIVACY_TEMPLATE_CUSTOM に設定されている場合はカスタマイズされた文字列を格納するバッファーを指す LPWSTR です。カスタマイズされたプライバシー設定文字列の説明については、PrivacySetZonePreferenceW を参照してください。 |
| pdwBufferLength | DWORD* | inoutoptional | バッファーの長さを文字数で格納する LPDWORD です。バッファーの長さが不足している場合、PrivacyGetZonePreferenceW はこのパラメーターに必要な文字数を設定し、戻り値 ERROR_MORE_DATA を返します。 |
戻り値の型: DWORD
公式ドキュメント
PrivacyGetZonePreferenceW (Unicode) 関数 (wininet.h) は、指定された URLZONE と PrivacyType に対するプライバシー設定を取得します。
戻り値
成功した場合は 0 を返します。それ以外の場合は、winerr.h で定義されているエラーメッセージのいずれかを返します。
解説(Remarks)
インターネットゾーンに対するこれらのプライバシー設定は、[インターネット オプション] ダイアログ ボックスの [プライバシー] タブにあります。
WinINet API の他のすべての要素と同様に、この関数は DllMain 内やグローバルオブジェクトのコンストラクター・デストラクター内から安全に呼び出すことはできません。
注意 WinINet はサーバー実装をサポートしていません。また、サービスから使用することも避けてください。サーバー実装やサービスでは、Microsoft Windows HTTP Services (WinHTTP) を使用してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は 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
#include <windows.h>
DWORD PrivacyGetZonePreferenceW(
DWORD dwZone,
DWORD dwType,
DWORD* pdwTemplate, // optional
LPWSTR pszBuffer, // optional
DWORD* pdwBufferLength // optional
);[DllImport("WININET.dll", ExactSpelling = true)]
static extern uint PrivacyGetZonePreferenceW(
uint dwZone, // DWORD
uint dwType, // DWORD
IntPtr pdwTemplate, // DWORD* optional, out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszBuffer, // LPWSTR optional, out
IntPtr pdwBufferLength // DWORD* optional, in/out
);<DllImport("WININET.dll", ExactSpelling:=True)>
Public Shared Function PrivacyGetZonePreferenceW(
dwZone As UInteger, ' DWORD
dwType As UInteger, ' DWORD
pdwTemplate As IntPtr, ' DWORD* optional, out
<MarshalAs(UnmanagedType.LPWStr)> pszBuffer As System.Text.StringBuilder, ' LPWSTR optional, out
pdwBufferLength As IntPtr ' DWORD* optional, in/out
) As UInteger
End Function' dwZone : DWORD
' dwType : DWORD
' pdwTemplate : DWORD* optional, out
' pszBuffer : LPWSTR optional, out
' pdwBufferLength : DWORD* optional, in/out
Declare PtrSafe Function PrivacyGetZonePreferenceW Lib "wininet" ( _
ByVal dwZone As Long, _
ByVal dwType As Long, _
ByVal pdwTemplate As LongPtr, _
ByVal pszBuffer As LongPtr, _
ByVal pdwBufferLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PrivacyGetZonePreferenceW = ctypes.windll.wininet.PrivacyGetZonePreferenceW
PrivacyGetZonePreferenceW.restype = wintypes.DWORD
PrivacyGetZonePreferenceW.argtypes = [
wintypes.DWORD, # dwZone : DWORD
wintypes.DWORD, # dwType : DWORD
ctypes.POINTER(wintypes.DWORD), # pdwTemplate : DWORD* optional, out
wintypes.LPWSTR, # pszBuffer : LPWSTR optional, out
ctypes.POINTER(wintypes.DWORD), # pdwBufferLength : DWORD* optional, in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('WININET.dll')
PrivacyGetZonePreferenceW = Fiddle::Function.new(
lib['PrivacyGetZonePreferenceW'],
[
-Fiddle::TYPE_INT, # dwZone : DWORD
-Fiddle::TYPE_INT, # dwType : DWORD
Fiddle::TYPE_VOIDP, # pdwTemplate : DWORD* optional, out
Fiddle::TYPE_VOIDP, # pszBuffer : LPWSTR optional, out
Fiddle::TYPE_VOIDP, # pdwBufferLength : DWORD* optional, in/out
],
-Fiddle::TYPE_INT)#[link(name = "wininet")]
extern "system" {
fn PrivacyGetZonePreferenceW(
dwZone: u32, // DWORD
dwType: u32, // DWORD
pdwTemplate: *mut u32, // DWORD* optional, out
pszBuffer: *mut u16, // LPWSTR optional, out
pdwBufferLength: *mut u32 // DWORD* optional, in/out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("WININET.dll")]
public static extern uint PrivacyGetZonePreferenceW(uint dwZone, uint dwType, IntPtr pdwTemplate, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszBuffer, IntPtr pdwBufferLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'WININET_PrivacyGetZonePreferenceW' -Namespace Win32 -PassThru
# $api::PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength)#uselib "WININET.dll"
#func global PrivacyGetZonePreferenceW "PrivacyGetZonePreferenceW" sptr, sptr, sptr, sptr, sptr
; PrivacyGetZonePreferenceW dwZone, dwType, varptr(pdwTemplate), varptr(pszBuffer), varptr(pdwBufferLength) ; 戻り値は stat
; dwZone : DWORD -> "sptr"
; dwType : DWORD -> "sptr"
; pdwTemplate : DWORD* optional, out -> "sptr"
; pszBuffer : LPWSTR optional, out -> "sptr"
; pdwBufferLength : DWORD* optional, in/out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "WININET.dll" #cfunc global PrivacyGetZonePreferenceW "PrivacyGetZonePreferenceW" int, int, var, var, var ; res = PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength) ; dwZone : DWORD -> "int" ; dwType : DWORD -> "int" ; pdwTemplate : DWORD* optional, out -> "var" ; pszBuffer : LPWSTR optional, out -> "var" ; pdwBufferLength : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "WININET.dll" #cfunc global PrivacyGetZonePreferenceW "PrivacyGetZonePreferenceW" int, int, sptr, sptr, sptr ; res = PrivacyGetZonePreferenceW(dwZone, dwType, varptr(pdwTemplate), varptr(pszBuffer), varptr(pdwBufferLength)) ; dwZone : DWORD -> "int" ; dwType : DWORD -> "int" ; pdwTemplate : DWORD* optional, out -> "sptr" ; pszBuffer : LPWSTR optional, out -> "sptr" ; pdwBufferLength : DWORD* optional, in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD PrivacyGetZonePreferenceW(DWORD dwZone, DWORD dwType, DWORD* pdwTemplate, LPWSTR pszBuffer, DWORD* pdwBufferLength) #uselib "WININET.dll" #cfunc global PrivacyGetZonePreferenceW "PrivacyGetZonePreferenceW" int, int, var, var, var ; res = PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength) ; dwZone : DWORD -> "int" ; dwType : DWORD -> "int" ; pdwTemplate : DWORD* optional, out -> "var" ; pszBuffer : LPWSTR optional, out -> "var" ; pdwBufferLength : DWORD* optional, in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD PrivacyGetZonePreferenceW(DWORD dwZone, DWORD dwType, DWORD* pdwTemplate, LPWSTR pszBuffer, DWORD* pdwBufferLength) #uselib "WININET.dll" #cfunc global PrivacyGetZonePreferenceW "PrivacyGetZonePreferenceW" int, int, intptr, intptr, intptr ; res = PrivacyGetZonePreferenceW(dwZone, dwType, varptr(pdwTemplate), varptr(pszBuffer), varptr(pdwBufferLength)) ; dwZone : DWORD -> "int" ; dwType : DWORD -> "int" ; pdwTemplate : DWORD* optional, out -> "intptr" ; pszBuffer : LPWSTR optional, out -> "intptr" ; pdwBufferLength : DWORD* optional, in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
wininet = windows.NewLazySystemDLL("WININET.dll")
procPrivacyGetZonePreferenceW = wininet.NewProc("PrivacyGetZonePreferenceW")
)
// dwZone (DWORD), dwType (DWORD), pdwTemplate (DWORD* optional, out), pszBuffer (LPWSTR optional, out), pdwBufferLength (DWORD* optional, in/out)
r1, _, err := procPrivacyGetZonePreferenceW.Call(
uintptr(dwZone),
uintptr(dwType),
uintptr(pdwTemplate),
uintptr(pszBuffer),
uintptr(pdwBufferLength),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction PrivacyGetZonePreferenceW(
dwZone: DWORD; // DWORD
dwType: DWORD; // DWORD
pdwTemplate: Pointer; // DWORD* optional, out
pszBuffer: PWideChar; // LPWSTR optional, out
pdwBufferLength: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'WININET.dll' name 'PrivacyGetZonePreferenceW';result := DllCall("WININET\PrivacyGetZonePreferenceW"
, "UInt", dwZone ; DWORD
, "UInt", dwType ; DWORD
, "Ptr", pdwTemplate ; DWORD* optional, out
, "Ptr", pszBuffer ; LPWSTR optional, out
, "Ptr", pdwBufferLength ; DWORD* optional, in/out
, "UInt") ; return: DWORD●PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength) = DLL("WININET.dll", "dword PrivacyGetZonePreferenceW(dword, dword, void*, char*, void*)")
# 呼び出し: PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength)
# dwZone : DWORD -> "dword"
# dwType : DWORD -> "dword"
# pdwTemplate : DWORD* optional, out -> "void*"
# pszBuffer : LPWSTR optional, out -> "char*"
# pdwBufferLength : DWORD* optional, in/out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "wininet" fn PrivacyGetZonePreferenceW(
dwZone: u32, // DWORD
dwType: u32, // DWORD
pdwTemplate: [*c]u32, // DWORD* optional, out
pszBuffer: [*c]u16, // LPWSTR optional, out
pdwBufferLength: [*c]u32 // DWORD* optional, in/out
) callconv(std.os.windows.WINAPI) u32;proc PrivacyGetZonePreferenceW(
dwZone: uint32, # DWORD
dwType: uint32, # DWORD
pdwTemplate: ptr uint32, # DWORD* optional, out
pszBuffer: ptr uint16, # LPWSTR optional, out
pdwBufferLength: ptr uint32 # DWORD* optional, in/out
): uint32 {.importc: "PrivacyGetZonePreferenceW", stdcall, dynlib: "WININET.dll".}pragma(lib, "wininet");
extern(Windows)
uint PrivacyGetZonePreferenceW(
uint dwZone, // DWORD
uint dwType, // DWORD
uint* pdwTemplate, // DWORD* optional, out
wchar* pszBuffer, // LPWSTR optional, out
uint* pdwBufferLength // DWORD* optional, in/out
);ccall((:PrivacyGetZonePreferenceW, "WININET.dll"), stdcall, UInt32,
(UInt32, UInt32, Ptr{UInt32}, Ptr{UInt16}, Ptr{UInt32}),
dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength)
# dwZone : DWORD -> UInt32
# dwType : DWORD -> UInt32
# pdwTemplate : DWORD* optional, out -> Ptr{UInt32}
# pszBuffer : LPWSTR optional, out -> Ptr{UInt16}
# pdwBufferLength : DWORD* optional, in/out -> Ptr{UInt32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t PrivacyGetZonePreferenceW(
uint32_t dwZone,
uint32_t dwType,
uint32_t* pdwTemplate,
uint16_t* pszBuffer,
uint32_t* pdwBufferLength);
]]
local wininet = ffi.load("wininet")
-- wininet.PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength)
-- dwZone : DWORD
-- dwType : DWORD
-- pdwTemplate : DWORD* optional, out
-- pszBuffer : LPWSTR optional, out
-- pdwBufferLength : DWORD* optional, in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('WININET.dll');
const PrivacyGetZonePreferenceW = lib.func('__stdcall', 'PrivacyGetZonePreferenceW', 'uint32_t', ['uint32_t', 'uint32_t', 'uint32_t *', 'uint16_t *', 'uint32_t *']);
// PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength)
// dwZone : DWORD -> 'uint32_t'
// dwType : DWORD -> 'uint32_t'
// pdwTemplate : DWORD* optional, out -> 'uint32_t *'
// pszBuffer : LPWSTR optional, out -> 'uint16_t *'
// pdwBufferLength : DWORD* optional, in/out -> 'uint32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("WININET.dll", {
PrivacyGetZonePreferenceW: { parameters: ["u32", "u32", "pointer", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength)
// dwZone : DWORD -> "u32"
// dwType : DWORD -> "u32"
// pdwTemplate : DWORD* optional, out -> "pointer"
// pszBuffer : LPWSTR optional, out -> "buffer"
// pdwBufferLength : DWORD* optional, in/out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t PrivacyGetZonePreferenceW(
uint32_t dwZone,
uint32_t dwType,
uint32_t* pdwTemplate,
uint16_t* pszBuffer,
uint32_t* pdwBufferLength);
C, "WININET.dll");
// $ffi->PrivacyGetZonePreferenceW(dwZone, dwType, pdwTemplate, pszBuffer, pdwBufferLength);
// dwZone : DWORD
// dwType : DWORD
// pdwTemplate : DWORD* optional, out
// pszBuffer : LPWSTR optional, out
// pdwBufferLength : DWORD* optional, in/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);
int PrivacyGetZonePreferenceW(
int dwZone, // DWORD
int dwType, // DWORD
IntByReference pdwTemplate, // DWORD* optional, out
char[] pszBuffer, // LPWSTR optional, out
IntByReference pdwBufferLength // DWORD* optional, in/out
);
}@[Link("wininet")]
lib LibWININET
fun PrivacyGetZonePreferenceW = PrivacyGetZonePreferenceW(
dwZone : UInt32, # DWORD
dwType : UInt32, # DWORD
pdwTemplate : UInt32*, # DWORD* optional, out
pszBuffer : UInt16*, # LPWSTR optional, out
pdwBufferLength : UInt32* # DWORD* optional, in/out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PrivacyGetZonePreferenceWNative = Uint32 Function(Uint32, Uint32, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>);
typedef PrivacyGetZonePreferenceWDart = int Function(int, int, Pointer<Uint32>, Pointer<Utf16>, Pointer<Uint32>);
final PrivacyGetZonePreferenceW = DynamicLibrary.open('WININET.dll')
.lookupFunction<PrivacyGetZonePreferenceWNative, PrivacyGetZonePreferenceWDart>('PrivacyGetZonePreferenceW');
// dwZone : DWORD -> Uint32
// dwType : DWORD -> Uint32
// pdwTemplate : DWORD* optional, out -> Pointer<Uint32>
// pszBuffer : LPWSTR optional, out -> Pointer<Utf16>
// pdwBufferLength : DWORD* optional, in/out -> Pointer<Uint32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PrivacyGetZonePreferenceW(
dwZone: DWORD; // DWORD
dwType: DWORD; // DWORD
pdwTemplate: Pointer; // DWORD* optional, out
pszBuffer: PWideChar; // LPWSTR optional, out
pdwBufferLength: Pointer // DWORD* optional, in/out
): DWORD; stdcall;
external 'WININET.dll' name 'PrivacyGetZonePreferenceW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PrivacyGetZonePreferenceW"
c_PrivacyGetZonePreferenceW :: Word32 -> Word32 -> Ptr Word32 -> CWString -> Ptr Word32 -> IO Word32
-- dwZone : DWORD -> Word32
-- dwType : DWORD -> Word32
-- pdwTemplate : DWORD* optional, out -> Ptr Word32
-- pszBuffer : LPWSTR optional, out -> CWString
-- pdwBufferLength : DWORD* optional, in/out -> Ptr Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let privacygetzonepreferencew =
foreign "PrivacyGetZonePreferenceW"
(uint32_t @-> uint32_t @-> (ptr uint32_t) @-> (ptr uint16_t) @-> (ptr uint32_t) @-> returning uint32_t)
(* dwZone : DWORD -> uint32_t *)
(* dwType : DWORD -> uint32_t *)
(* pdwTemplate : DWORD* optional, out -> (ptr uint32_t) *)
(* pszBuffer : LPWSTR optional, out -> (ptr uint16_t) *)
(* pdwBufferLength : DWORD* optional, in/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 ("PrivacyGetZonePreferenceW" privacy-get-zone-preference-w :convention :stdcall) :uint32
(dw-zone :uint32) ; DWORD
(dw-type :uint32) ; DWORD
(pdw-template :pointer) ; DWORD* optional, out
(psz-buffer :pointer) ; LPWSTR optional, out
(pdw-buffer-length :pointer)) ; DWORD* optional, in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PrivacyGetZonePreferenceW = Win32::API::More->new('WININET',
'DWORD PrivacyGetZonePreferenceW(DWORD dwZone, DWORD dwType, LPVOID pdwTemplate, LPWSTR pszBuffer, LPVOID pdwBufferLength)');
# my $ret = $PrivacyGetZonePreferenceW->Call($dwZone, $dwType, $pdwTemplate, $pszBuffer, $pdwBufferLength);
# dwZone : DWORD -> DWORD
# dwType : DWORD -> DWORD
# pdwTemplate : DWORD* optional, out -> LPVOID
# pszBuffer : LPWSTR optional, out -> LPWSTR
# pdwBufferLength : DWORD* optional, in/out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
公式の関連項目
- f InternetClearAllPerSiteCookieDecisions — 全サイトのCookie許可設定をクリアする。
- f InternetEnumPerSiteCookieDecisionW — サイト別Cookie許可設定を順に列挙する(Unicode版)。
- f InternetGetPerSiteCookieDecisionW — サイト別のCookie許可設定を取得する(Unicode版)。
- f InternetSetPerSiteCookieDecisionW — サイト別のCookie許可設定を行う(Unicode版)。
- f PrivacySetZonePreferenceW — セキュリティゾーンのプライバシー設定を行う(Unicode版)。