ホーム › Security.Cryptography.UI › CryptUIDlgViewContext
CryptUIDlgViewContext
関数証明書やCRLなどのコンテキストを表示するダイアログを開く。
シグネチャ
// CRYPTUI.dll
#include <windows.h>
BOOL CryptUIDlgViewContext(
DWORD dwContextType,
const void* pvContext,
HWND hwnd, // optional
LPCWSTR pwszTitle, // optional
DWORD dwFlags,
void* pvReserved
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| dwContextType | DWORD | in | pvContextの種別を示す定数。CERT_STORE_CERTIFICATE_CONTEXT/CRL/CTLのいずれか。 |
| pvContext | void* | in | 表示対象のコンテキスト(証明書/CRL/CTL)へのポインタ。dwContextTypeで型が決まる。 |
| hwnd | HWND | inoptional | ダイアログの親ウィンドウハンドル。NULL可。 |
| pwszTitle | LPCWSTR | inoptional | ダイアログのタイトル文字列。NULLで既定タイトルを使用する。 |
| dwFlags | DWORD | in | 表示動作を制御するフラグ。現状は予約で通常0を指定する。 |
| pvReserved | void* | in | 予約パラメータ。NULLを指定する。 |
戻り値の型: BOOL
各言語での呼び出し定義
// CRYPTUI.dll
#include <windows.h>
BOOL CryptUIDlgViewContext(
DWORD dwContextType,
const void* pvContext,
HWND hwnd, // optional
LPCWSTR pwszTitle, // optional
DWORD dwFlags,
void* pvReserved
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPTUI.dll", ExactSpelling = true)]
static extern bool CryptUIDlgViewContext(
uint dwContextType, // DWORD
IntPtr pvContext, // void*
IntPtr hwnd, // HWND optional
[MarshalAs(UnmanagedType.LPWStr)] string pwszTitle, // LPCWSTR optional
uint dwFlags, // DWORD
IntPtr pvReserved // void*
);<DllImport("CRYPTUI.dll", ExactSpelling:=True)>
Public Shared Function CryptUIDlgViewContext(
dwContextType As UInteger, ' DWORD
pvContext As IntPtr, ' void*
hwnd As IntPtr, ' HWND optional
<MarshalAs(UnmanagedType.LPWStr)> pwszTitle As String, ' LPCWSTR optional
dwFlags As UInteger, ' DWORD
pvReserved As IntPtr ' void*
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' dwContextType : DWORD
' pvContext : void*
' hwnd : HWND optional
' pwszTitle : LPCWSTR optional
' dwFlags : DWORD
' pvReserved : void*
Declare PtrSafe Function CryptUIDlgViewContext Lib "cryptui" ( _
ByVal dwContextType As Long, _
ByVal pvContext As LongPtr, _
ByVal hwnd As LongPtr, _
ByVal pwszTitle As LongPtr, _
ByVal dwFlags As Long, _
ByVal pvReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CryptUIDlgViewContext = ctypes.windll.cryptui.CryptUIDlgViewContext
CryptUIDlgViewContext.restype = wintypes.BOOL
CryptUIDlgViewContext.argtypes = [
wintypes.DWORD, # dwContextType : DWORD
ctypes.POINTER(None), # pvContext : void*
wintypes.HANDLE, # hwnd : HWND optional
wintypes.LPCWSTR, # pwszTitle : LPCWSTR optional
wintypes.DWORD, # dwFlags : DWORD
ctypes.POINTER(None), # pvReserved : void*
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('CRYPTUI.dll')
CryptUIDlgViewContext = Fiddle::Function.new(
lib['CryptUIDlgViewContext'],
[
-Fiddle::TYPE_INT, # dwContextType : DWORD
Fiddle::TYPE_VOIDP, # pvContext : void*
Fiddle::TYPE_VOIDP, # hwnd : HWND optional
Fiddle::TYPE_VOIDP, # pwszTitle : LPCWSTR optional
-Fiddle::TYPE_INT, # dwFlags : DWORD
Fiddle::TYPE_VOIDP, # pvReserved : void*
],
Fiddle::TYPE_INT)#[link(name = "cryptui")]
extern "system" {
fn CryptUIDlgViewContext(
dwContextType: u32, // DWORD
pvContext: *const (), // void*
hwnd: *mut core::ffi::c_void, // HWND optional
pwszTitle: *const u16, // LPCWSTR optional
dwFlags: u32, // DWORD
pvReserved: *mut () // void*
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("CRYPTUI.dll")]
public static extern bool CryptUIDlgViewContext(uint dwContextType, IntPtr pvContext, IntPtr hwnd, [MarshalAs(UnmanagedType.LPWStr)] string pwszTitle, uint dwFlags, IntPtr pvReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'CRYPTUI_CryptUIDlgViewContext' -Namespace Win32 -PassThru
# $api::CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)#uselib "CRYPTUI.dll"
#func global CryptUIDlgViewContext "CryptUIDlgViewContext" sptr, sptr, sptr, sptr, sptr, sptr
; CryptUIDlgViewContext dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved ; 戻り値は stat
; dwContextType : DWORD -> "sptr"
; pvContext : void* -> "sptr"
; hwnd : HWND optional -> "sptr"
; pwszTitle : LPCWSTR optional -> "sptr"
; dwFlags : DWORD -> "sptr"
; pvReserved : void* -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "CRYPTUI.dll"
#cfunc global CryptUIDlgViewContext "CryptUIDlgViewContext" int, sptr, sptr, wstr, int, sptr
; res = CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
; dwContextType : DWORD -> "int"
; pvContext : void* -> "sptr"
; hwnd : HWND optional -> "sptr"
; pwszTitle : LPCWSTR optional -> "wstr"
; dwFlags : DWORD -> "int"
; pvReserved : void* -> "sptr"; BOOL CryptUIDlgViewContext(DWORD dwContextType, void* pvContext, HWND hwnd, LPCWSTR pwszTitle, DWORD dwFlags, void* pvReserved)
#uselib "CRYPTUI.dll"
#cfunc global CryptUIDlgViewContext "CryptUIDlgViewContext" int, intptr, intptr, wstr, int, intptr
; res = CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
; dwContextType : DWORD -> "int"
; pvContext : void* -> "intptr"
; hwnd : HWND optional -> "intptr"
; pwszTitle : LPCWSTR optional -> "wstr"
; dwFlags : DWORD -> "int"
; pvReserved : void* -> "intptr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
cryptui = windows.NewLazySystemDLL("CRYPTUI.dll")
procCryptUIDlgViewContext = cryptui.NewProc("CryptUIDlgViewContext")
)
// dwContextType (DWORD), pvContext (void*), hwnd (HWND optional), pwszTitle (LPCWSTR optional), dwFlags (DWORD), pvReserved (void*)
r1, _, err := procCryptUIDlgViewContext.Call(
uintptr(dwContextType),
uintptr(pvContext),
uintptr(hwnd),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszTitle))),
uintptr(dwFlags),
uintptr(pvReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction CryptUIDlgViewContext(
dwContextType: DWORD; // DWORD
pvContext: Pointer; // void*
hwnd: THandle; // HWND optional
pwszTitle: PWideChar; // LPCWSTR optional
dwFlags: DWORD; // DWORD
pvReserved: Pointer // void*
): BOOL; stdcall;
external 'CRYPTUI.dll' name 'CryptUIDlgViewContext';result := DllCall("CRYPTUI\CryptUIDlgViewContext"
, "UInt", dwContextType ; DWORD
, "Ptr", pvContext ; void*
, "Ptr", hwnd ; HWND optional
, "WStr", pwszTitle ; LPCWSTR optional
, "UInt", dwFlags ; DWORD
, "Ptr", pvReserved ; void*
, "Int") ; return: BOOL●CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved) = DLL("CRYPTUI.dll", "bool CryptUIDlgViewContext(dword, void*, void*, char*, dword, void*)")
# 呼び出し: CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
# dwContextType : DWORD -> "dword"
# pvContext : void* -> "void*"
# hwnd : HWND optional -> "void*"
# pwszTitle : LPCWSTR optional -> "char*"
# dwFlags : DWORD -> "dword"
# pvReserved : void* -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "cryptui" fn CryptUIDlgViewContext(
dwContextType: u32, // DWORD
pvContext: ?*anyopaque, // void*
hwnd: ?*anyopaque, // HWND optional
pwszTitle: [*c]const u16, // LPCWSTR optional
dwFlags: u32, // DWORD
pvReserved: ?*anyopaque // void*
) callconv(std.os.windows.WINAPI) i32;proc CryptUIDlgViewContext(
dwContextType: uint32, # DWORD
pvContext: pointer, # void*
hwnd: pointer, # HWND optional
pwszTitle: WideCString, # LPCWSTR optional
dwFlags: uint32, # DWORD
pvReserved: pointer # void*
): int32 {.importc: "CryptUIDlgViewContext", stdcall, dynlib: "CRYPTUI.dll".}pragma(lib, "cryptui");
extern(Windows)
int CryptUIDlgViewContext(
uint dwContextType, // DWORD
void* pvContext, // void*
void* hwnd, // HWND optional
const(wchar)* pwszTitle, // LPCWSTR optional
uint dwFlags, // DWORD
void* pvReserved // void*
);ccall((:CryptUIDlgViewContext, "CRYPTUI.dll"), stdcall, Int32,
(UInt32, Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, UInt32, Ptr{Cvoid}),
dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
# dwContextType : DWORD -> UInt32
# pvContext : void* -> Ptr{Cvoid}
# hwnd : HWND optional -> Ptr{Cvoid}
# pwszTitle : LPCWSTR optional -> Cwstring
# dwFlags : DWORD -> UInt32
# pvReserved : void* -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CryptUIDlgViewContext(
uint32_t dwContextType,
void* pvContext,
void* hwnd,
const uint16_t* pwszTitle,
uint32_t dwFlags,
void* pvReserved);
]]
local cryptui = ffi.load("cryptui")
-- cryptui.CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
-- dwContextType : DWORD
-- pvContext : void*
-- hwnd : HWND optional
-- pwszTitle : LPCWSTR optional
-- dwFlags : DWORD
-- pvReserved : void*
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('CRYPTUI.dll');
const CryptUIDlgViewContext = lib.func('__stdcall', 'CryptUIDlgViewContext', 'int32_t', ['uint32_t', 'void *', 'void *', 'str16', 'uint32_t', 'void *']);
// CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
// dwContextType : DWORD -> 'uint32_t'
// pvContext : void* -> 'void *'
// hwnd : HWND optional -> 'void *'
// pwszTitle : LPCWSTR optional -> 'str16'
// dwFlags : DWORD -> 'uint32_t'
// pvReserved : void* -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("CRYPTUI.dll", {
CryptUIDlgViewContext: { parameters: ["u32", "pointer", "pointer", "buffer", "u32", "pointer"], result: "i32" },
});
// lib.symbols.CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved)
// dwContextType : DWORD -> "u32"
// pvContext : void* -> "pointer"
// hwnd : HWND optional -> "pointer"
// pwszTitle : LPCWSTR optional -> "buffer"
// dwFlags : DWORD -> "u32"
// pvReserved : void* -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CryptUIDlgViewContext(
uint32_t dwContextType,
void* pvContext,
void* hwnd,
const uint16_t* pwszTitle,
uint32_t dwFlags,
void* pvReserved);
C, "CRYPTUI.dll");
// $ffi->CryptUIDlgViewContext(dwContextType, pvContext, hwnd, pwszTitle, dwFlags, pvReserved);
// dwContextType : DWORD
// pvContext : void*
// hwnd : HWND optional
// pwszTitle : LPCWSTR optional
// dwFlags : DWORD
// pvReserved : void*
// 構造体/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 Cryptui extends StdCallLibrary {
Cryptui INSTANCE = Native.load("cryptui", Cryptui.class);
boolean CryptUIDlgViewContext(
int dwContextType, // DWORD
Pointer pvContext, // void*
Pointer hwnd, // HWND optional
WString pwszTitle, // LPCWSTR optional
int dwFlags, // DWORD
Pointer pvReserved // void*
);
}@[Link("cryptui")]
lib LibCRYPTUI
fun CryptUIDlgViewContext = CryptUIDlgViewContext(
dwContextType : UInt32, # DWORD
pvContext : Void*, # void*
hwnd : Void*, # HWND optional
pwszTitle : UInt16*, # LPCWSTR optional
dwFlags : UInt32, # DWORD
pvReserved : Void* # void*
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CryptUIDlgViewContextNative = Int32 Function(Uint32, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Uint32, Pointer<Void>);
typedef CryptUIDlgViewContextDart = int Function(int, Pointer<Void>, Pointer<Void>, Pointer<Utf16>, int, Pointer<Void>);
final CryptUIDlgViewContext = DynamicLibrary.open('CRYPTUI.dll')
.lookupFunction<CryptUIDlgViewContextNative, CryptUIDlgViewContextDart>('CryptUIDlgViewContext');
// dwContextType : DWORD -> Uint32
// pvContext : void* -> Pointer<Void>
// hwnd : HWND optional -> Pointer<Void>
// pwszTitle : LPCWSTR optional -> Pointer<Utf16>
// dwFlags : DWORD -> Uint32
// pvReserved : void* -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CryptUIDlgViewContext(
dwContextType: DWORD; // DWORD
pvContext: Pointer; // void*
hwnd: THandle; // HWND optional
pwszTitle: PWideChar; // LPCWSTR optional
dwFlags: DWORD; // DWORD
pvReserved: Pointer // void*
): BOOL; stdcall;
external 'CRYPTUI.dll' name 'CryptUIDlgViewContext';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CryptUIDlgViewContext"
c_CryptUIDlgViewContext :: Word32 -> Ptr () -> Ptr () -> CWString -> Word32 -> Ptr () -> IO CInt
-- dwContextType : DWORD -> Word32
-- pvContext : void* -> Ptr ()
-- hwnd : HWND optional -> Ptr ()
-- pwszTitle : LPCWSTR optional -> CWString
-- dwFlags : DWORD -> Word32
-- pvReserved : void* -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cryptuidlgviewcontext =
foreign "CryptUIDlgViewContext"
(uint32_t @-> (ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning int32_t)
(* dwContextType : DWORD -> uint32_t *)
(* pvContext : void* -> (ptr void) *)
(* hwnd : HWND optional -> (ptr void) *)
(* pwszTitle : LPCWSTR optional -> (ptr uint16_t) *)
(* dwFlags : DWORD -> uint32_t *)
(* pvReserved : void* -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library cryptui (t "CRYPTUI.dll"))
(cffi:use-foreign-library cryptui)
(cffi:defcfun ("CryptUIDlgViewContext" crypt-uidlg-view-context :convention :stdcall) :int32
(dw-context-type :uint32) ; DWORD
(pv-context :pointer) ; void*
(hwnd :pointer) ; HWND optional
(pwsz-title (:string :encoding :utf-16le)) ; LPCWSTR optional
(dw-flags :uint32) ; DWORD
(pv-reserved :pointer)) ; void*
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CryptUIDlgViewContext = Win32::API::More->new('CRYPTUI',
'BOOL CryptUIDlgViewContext(DWORD dwContextType, LPVOID pvContext, HANDLE hwnd, LPCWSTR pwszTitle, DWORD dwFlags, LPVOID pvReserved)');
# my $ret = $CryptUIDlgViewContext->Call($dwContextType, $pvContext, $hwnd, $pwszTitle, $dwFlags, $pvReserved);
# dwContextType : DWORD -> DWORD
# pvContext : void* -> LPVOID
# hwnd : HWND optional -> HANDLE
# pwszTitle : LPCWSTR optional -> LPCWSTR
# dwFlags : DWORD -> DWORD
# pvReserved : void* -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。