Win32 API 日本語リファレンス
ホームSystem.Com.Urlmon › CoInternetGetSecurityUrl

CoInternetGetSecurityUrl

関数
指定URLからセキュリティゾーン判定用のセキュリティURLを取得する。
DLLurlmon.dll呼出規約winapi

シグネチャ

// urlmon.dll
#include <windows.h>

HRESULT CoInternetGetSecurityUrl(
    LPCWSTR pwszUrl,
    LPWSTR* ppwszSecUrl,
    PSUACTION psuAction,
    DWORD dwReserved   // optional
);

パラメーター

名前方向
pwszUrlLPCWSTRin
ppwszSecUrlLPWSTR*out
psuActionPSUACTIONin
dwReservedDWORDoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// urlmon.dll
#include <windows.h>

HRESULT CoInternetGetSecurityUrl(
    LPCWSTR pwszUrl,
    LPWSTR* ppwszSecUrl,
    PSUACTION psuAction,
    DWORD dwReserved   // optional
);
[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int CoInternetGetSecurityUrl(
    [MarshalAs(UnmanagedType.LPWStr)] string pwszUrl,   // LPCWSTR
    IntPtr ppwszSecUrl,   // LPWSTR* out
    int psuAction,   // PSUACTION
    uint dwReserved   // DWORD optional
);
<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function CoInternetGetSecurityUrl(
    <MarshalAs(UnmanagedType.LPWStr)> pwszUrl As String,   ' LPCWSTR
    ppwszSecUrl As IntPtr,   ' LPWSTR* out
    psuAction As Integer,   ' PSUACTION
    dwReserved As UInteger   ' DWORD optional
) As Integer
End Function
' pwszUrl : LPCWSTR
' ppwszSecUrl : LPWSTR* out
' psuAction : PSUACTION
' dwReserved : DWORD optional
Declare PtrSafe Function CoInternetGetSecurityUrl Lib "urlmon" ( _
    ByVal pwszUrl As LongPtr, _
    ByVal ppwszSecUrl As LongPtr, _
    ByVal psuAction As Long, _
    ByVal dwReserved As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CoInternetGetSecurityUrl = ctypes.windll.urlmon.CoInternetGetSecurityUrl
CoInternetGetSecurityUrl.restype = ctypes.c_int
CoInternetGetSecurityUrl.argtypes = [
    wintypes.LPCWSTR,  # pwszUrl : LPCWSTR
    ctypes.c_void_p,  # ppwszSecUrl : LPWSTR* out
    ctypes.c_int,  # psuAction : PSUACTION
    wintypes.DWORD,  # dwReserved : DWORD optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('urlmon.dll')
CoInternetGetSecurityUrl = Fiddle::Function.new(
  lib['CoInternetGetSecurityUrl'],
  [
    Fiddle::TYPE_VOIDP,  # pwszUrl : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ppwszSecUrl : LPWSTR* out
    Fiddle::TYPE_INT,  # psuAction : PSUACTION
    -Fiddle::TYPE_INT,  # dwReserved : DWORD optional
  ],
  Fiddle::TYPE_INT)
#[link(name = "urlmon")]
extern "system" {
    fn CoInternetGetSecurityUrl(
        pwszUrl: *const u16,  // LPCWSTR
        ppwszSecUrl: *mut *mut u16,  // LPWSTR* out
        psuAction: i32,  // PSUACTION
        dwReserved: u32  // DWORD optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("urlmon.dll")]
public static extern int CoInternetGetSecurityUrl([MarshalAs(UnmanagedType.LPWStr)] string pwszUrl, IntPtr ppwszSecUrl, int psuAction, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_CoInternetGetSecurityUrl' -Namespace Win32 -PassThru
# $api::CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
#uselib "urlmon.dll"
#func global CoInternetGetSecurityUrl "CoInternetGetSecurityUrl" sptr, sptr, sptr, sptr
; CoInternetGetSecurityUrl pwszUrl, varptr(ppwszSecUrl), psuAction, dwReserved   ; 戻り値は stat
; pwszUrl : LPCWSTR -> "sptr"
; ppwszSecUrl : LPWSTR* out -> "sptr"
; psuAction : PSUACTION -> "sptr"
; dwReserved : DWORD optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "urlmon.dll"
#cfunc global CoInternetGetSecurityUrl "CoInternetGetSecurityUrl" wstr, var, int, int
; res = CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
; pwszUrl : LPCWSTR -> "wstr"
; ppwszSecUrl : LPWSTR* out -> "var"
; psuAction : PSUACTION -> "int"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT CoInternetGetSecurityUrl(LPCWSTR pwszUrl, LPWSTR* ppwszSecUrl, PSUACTION psuAction, DWORD dwReserved)
#uselib "urlmon.dll"
#cfunc global CoInternetGetSecurityUrl "CoInternetGetSecurityUrl" wstr, var, int, int
; res = CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
; pwszUrl : LPCWSTR -> "wstr"
; ppwszSecUrl : LPWSTR* out -> "var"
; psuAction : PSUACTION -> "int"
; dwReserved : DWORD optional -> "int"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	urlmon = windows.NewLazySystemDLL("urlmon.dll")
	procCoInternetGetSecurityUrl = urlmon.NewProc("CoInternetGetSecurityUrl")
)

// pwszUrl (LPCWSTR), ppwszSecUrl (LPWSTR* out), psuAction (PSUACTION), dwReserved (DWORD optional)
r1, _, err := procCoInternetGetSecurityUrl.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwszUrl))),
	uintptr(ppwszSecUrl),
	uintptr(psuAction),
	uintptr(dwReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function CoInternetGetSecurityUrl(
  pwszUrl: PWideChar;   // LPCWSTR
  ppwszSecUrl: PPWideChar;   // LPWSTR* out
  psuAction: Integer;   // PSUACTION
  dwReserved: DWORD   // DWORD optional
): Integer; stdcall;
  external 'urlmon.dll' name 'CoInternetGetSecurityUrl';
result := DllCall("urlmon\CoInternetGetSecurityUrl"
    , "WStr", pwszUrl   ; LPCWSTR
    , "Ptr", ppwszSecUrl   ; LPWSTR* out
    , "Int", psuAction   ; PSUACTION
    , "UInt", dwReserved   ; DWORD optional
    , "Int")   ; return: HRESULT
●CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved) = DLL("urlmon.dll", "int CoInternetGetSecurityUrl(char*, void*, int, dword)")
# 呼び出し: CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
# pwszUrl : LPCWSTR -> "char*"
# ppwszSecUrl : LPWSTR* out -> "void*"
# psuAction : PSUACTION -> "int"
# dwReserved : DWORD optional -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。