ホーム › System.Com.Urlmon › CoInternetGetSecurityUrl
CoInternetGetSecurityUrl
関数指定URLからセキュリティゾーン判定用のセキュリティURLを取得する。
シグネチャ
// urlmon.dll
#include <windows.h>
HRESULT CoInternetGetSecurityUrl(
LPCWSTR pwszUrl,
LPWSTR* ppwszSecUrl,
PSUACTION psuAction,
DWORD dwReserved // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pwszUrl | LPCWSTR | in | セキュリティ用URLを導出する元のURL文字列。 |
| ppwszSecUrl | LPWSTR* | out | 導出されたセキュリティURL文字列を受け取る出力ポインタ。解放が必要。 |
| psuAction | PSUACTION | in | 導出方法を指定するPSUACTION値。セキュリティゾーン等の決定方式を選ぶ。 |
| dwReserved | DWORD | optional | 予約パラメータ。0を指定する必要がある。 |
戻り値の型: 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 方式にも切替可。#uselib "urlmon.dll" #cfunc global CoInternetGetSecurityUrl "CoInternetGetSecurityUrl" wstr, sptr, int, int ; res = CoInternetGetSecurityUrl(pwszUrl, varptr(ppwszSecUrl), psuAction, dwReserved) ; pwszUrl : LPCWSTR -> "wstr" ; ppwszSecUrl : LPWSTR* out -> "sptr" ; psuAction : PSUACTION -> "int" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; HRESULT CoInternetGetSecurityUrl(LPCWSTR pwszUrl, LPWSTR* ppwszSecUrl, PSUACTION psuAction, DWORD dwReserved) #uselib "urlmon.dll" #cfunc global CoInternetGetSecurityUrl "CoInternetGetSecurityUrl" wstr, intptr, int, int ; res = CoInternetGetSecurityUrl(pwszUrl, varptr(ppwszSecUrl), psuAction, dwReserved) ; pwszUrl : LPCWSTR -> "wstr" ; ppwszSecUrl : LPWSTR* out -> "intptr" ; psuAction : PSUACTION -> "int" ; dwReserved : DWORD optional -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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 // HRESULTfunction 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)。const std = @import("std");
extern "urlmon" fn CoInternetGetSecurityUrl(
pwszUrl: [*c]const u16, // LPCWSTR
ppwszSecUrl: [*c][*c]u16, // LPWSTR* out
psuAction: i32, // PSUACTION
dwReserved: u32 // DWORD optional
) callconv(std.os.windows.WINAPI) i32;proc CoInternetGetSecurityUrl(
pwszUrl: WideCString, # LPCWSTR
ppwszSecUrl: ptr WideCString, # LPWSTR* out
psuAction: int32, # PSUACTION
dwReserved: uint32 # DWORD optional
): int32 {.importc: "CoInternetGetSecurityUrl", stdcall, dynlib: "urlmon.dll".}pragma(lib, "urlmon");
extern(Windows)
int CoInternetGetSecurityUrl(
const(wchar)* pwszUrl, // LPCWSTR
wchar** ppwszSecUrl, // LPWSTR* out
int psuAction, // PSUACTION
uint dwReserved // DWORD optional
);ccall((:CoInternetGetSecurityUrl, "urlmon.dll"), stdcall, Int32,
(Cwstring, Ptr{Ptr{UInt16}}, Int32, UInt32),
pwszUrl, ppwszSecUrl, psuAction, dwReserved)
# pwszUrl : LPCWSTR -> Cwstring
# ppwszSecUrl : LPWSTR* out -> Ptr{Ptr{UInt16}}
# psuAction : PSUACTION -> Int32
# dwReserved : DWORD optional -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t CoInternetGetSecurityUrl(
const uint16_t* pwszUrl,
uint16_t** ppwszSecUrl,
int32_t psuAction,
uint32_t dwReserved);
]]
local urlmon = ffi.load("urlmon")
-- urlmon.CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
-- pwszUrl : LPCWSTR
-- ppwszSecUrl : LPWSTR* out
-- psuAction : PSUACTION
-- dwReserved : DWORD optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('urlmon.dll');
const CoInternetGetSecurityUrl = lib.func('__stdcall', 'CoInternetGetSecurityUrl', 'int32_t', ['str16', 'void *', 'int32_t', 'uint32_t']);
// CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
// pwszUrl : LPCWSTR -> 'str16'
// ppwszSecUrl : LPWSTR* out -> 'void *'
// psuAction : PSUACTION -> 'int32_t'
// dwReserved : DWORD optional -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("urlmon.dll", {
CoInternetGetSecurityUrl: { parameters: ["buffer", "pointer", "i32", "u32"], result: "i32" },
});
// lib.symbols.CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved)
// pwszUrl : LPCWSTR -> "buffer"
// ppwszSecUrl : LPWSTR* out -> "pointer"
// psuAction : PSUACTION -> "i32"
// dwReserved : DWORD optional -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t CoInternetGetSecurityUrl(
const uint16_t* pwszUrl,
uint16_t** ppwszSecUrl,
int32_t psuAction,
uint32_t dwReserved);
C, "urlmon.dll");
// $ffi->CoInternetGetSecurityUrl(pwszUrl, ppwszSecUrl, psuAction, dwReserved);
// pwszUrl : LPCWSTR
// ppwszSecUrl : LPWSTR* out
// psuAction : PSUACTION
// dwReserved : DWORD optional
// 構造体/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 Urlmon extends StdCallLibrary {
Urlmon INSTANCE = Native.load("urlmon", Urlmon.class);
int CoInternetGetSecurityUrl(
WString pwszUrl, // LPCWSTR
PointerByReference ppwszSecUrl, // LPWSTR* out
int psuAction, // PSUACTION
int dwReserved // DWORD optional
);
}@[Link("urlmon")]
lib Liburlmon
fun CoInternetGetSecurityUrl = CoInternetGetSecurityUrl(
pwszUrl : UInt16*, # LPCWSTR
ppwszSecUrl : UInt16**, # LPWSTR* out
psuAction : Int32, # PSUACTION
dwReserved : UInt32 # DWORD optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef CoInternetGetSecurityUrlNative = Int32 Function(Pointer<Utf16>, Pointer<Pointer<Utf16>>, Int32, Uint32);
typedef CoInternetGetSecurityUrlDart = int Function(Pointer<Utf16>, Pointer<Pointer<Utf16>>, int, int);
final CoInternetGetSecurityUrl = DynamicLibrary.open('urlmon.dll')
.lookupFunction<CoInternetGetSecurityUrlNative, CoInternetGetSecurityUrlDart>('CoInternetGetSecurityUrl');
// pwszUrl : LPCWSTR -> Pointer<Utf16>
// ppwszSecUrl : LPWSTR* out -> Pointer<Pointer<Utf16>>
// psuAction : PSUACTION -> Int32
// dwReserved : DWORD optional -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function CoInternetGetSecurityUrl(
pwszUrl: PWideChar; // LPCWSTR
ppwszSecUrl: PPWideChar; // LPWSTR* out
psuAction: Integer; // PSUACTION
dwReserved: DWORD // DWORD optional
): Integer; stdcall;
external 'urlmon.dll' name 'CoInternetGetSecurityUrl';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "CoInternetGetSecurityUrl"
c_CoInternetGetSecurityUrl :: CWString -> Ptr CWString -> Int32 -> Word32 -> IO Int32
-- pwszUrl : LPCWSTR -> CWString
-- ppwszSecUrl : LPWSTR* out -> Ptr CWString
-- psuAction : PSUACTION -> Int32
-- dwReserved : DWORD optional -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let cointernetgetsecurityurl =
foreign "CoInternetGetSecurityUrl"
((ptr uint16_t) @-> (ptr (ptr uint16_t)) @-> int32_t @-> uint32_t @-> returning int32_t)
(* pwszUrl : LPCWSTR -> (ptr uint16_t) *)
(* ppwszSecUrl : LPWSTR* out -> (ptr (ptr uint16_t)) *)
(* psuAction : PSUACTION -> int32_t *)
(* dwReserved : DWORD optional -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library urlmon (t "urlmon.dll"))
(cffi:use-foreign-library urlmon)
(cffi:defcfun ("CoInternetGetSecurityUrl" co-internet-get-security-url :convention :stdcall) :int32
(pwsz-url (:string :encoding :utf-16le)) ; LPCWSTR
(ppwsz-sec-url :pointer) ; LPWSTR* out
(psu-action :int32) ; PSUACTION
(dw-reserved :uint32)) ; DWORD optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $CoInternetGetSecurityUrl = Win32::API::More->new('urlmon',
'int CoInternetGetSecurityUrl(LPCWSTR pwszUrl, LPVOID ppwszSecUrl, int psuAction, DWORD dwReserved)');
# my $ret = $CoInternetGetSecurityUrl->Call($pwszUrl, $ppwszSecUrl, $psuAction, $dwReserved);
# pwszUrl : LPCWSTR -> LPCWSTR
# ppwszSecUrl : LPWSTR* out -> LPVOID
# psuAction : PSUACTION -> int
# dwReserved : DWORD optional -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
類似 API
- f CoInternetGetSecurityUrlEx — 指定URIからセキュリティ判定用のセキュリティURIを取得する。
使用する型