ホーム › System.Com.Urlmon › CoInternetGetProtocolFlags
CoInternetGetProtocolFlags
関数指定したURLのプロトコルに関するフラグを取得する。
シグネチャ
// urlmon.dll
#include <windows.h>
HRESULT CoInternetGetProtocolFlags(
LPCWSTR pwzUrl,
DWORD* pdwFlags,
DWORD dwReserved
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pwzUrl | LPCWSTR | in |
| pdwFlags | DWORD* | out |
| dwReserved | DWORD | in |
戻り値の型: HRESULT
各言語での呼び出し定義
// urlmon.dll
#include <windows.h>
HRESULT CoInternetGetProtocolFlags(
LPCWSTR pwzUrl,
DWORD* pdwFlags,
DWORD dwReserved
);[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int CoInternetGetProtocolFlags(
[MarshalAs(UnmanagedType.LPWStr)] string pwzUrl, // LPCWSTR
out uint pdwFlags, // DWORD* out
uint dwReserved // DWORD
);<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function CoInternetGetProtocolFlags(
<MarshalAs(UnmanagedType.LPWStr)> pwzUrl As String, ' LPCWSTR
<Out> ByRef pdwFlags As UInteger, ' DWORD* out
dwReserved As UInteger ' DWORD
) As Integer
End Function' pwzUrl : LPCWSTR
' pdwFlags : DWORD* out
' dwReserved : DWORD
Declare PtrSafe Function CoInternetGetProtocolFlags Lib "urlmon" ( _
ByVal pwzUrl As LongPtr, _
ByRef pdwFlags 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
CoInternetGetProtocolFlags = ctypes.windll.urlmon.CoInternetGetProtocolFlags
CoInternetGetProtocolFlags.restype = ctypes.c_int
CoInternetGetProtocolFlags.argtypes = [
wintypes.LPCWSTR, # pwzUrl : LPCWSTR
ctypes.POINTER(wintypes.DWORD), # pdwFlags : DWORD* out
wintypes.DWORD, # dwReserved : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('urlmon.dll')
CoInternetGetProtocolFlags = Fiddle::Function.new(
lib['CoInternetGetProtocolFlags'],
[
Fiddle::TYPE_VOIDP, # pwzUrl : LPCWSTR
Fiddle::TYPE_VOIDP, # pdwFlags : DWORD* out
-Fiddle::TYPE_INT, # dwReserved : DWORD
],
Fiddle::TYPE_INT)#[link(name = "urlmon")]
extern "system" {
fn CoInternetGetProtocolFlags(
pwzUrl: *const u16, // LPCWSTR
pdwFlags: *mut u32, // DWORD* out
dwReserved: u32 // DWORD
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("urlmon.dll")]
public static extern int CoInternetGetProtocolFlags([MarshalAs(UnmanagedType.LPWStr)] string pwzUrl, out uint pdwFlags, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_CoInternetGetProtocolFlags' -Namespace Win32 -PassThru
# $api::CoInternetGetProtocolFlags(pwzUrl, pdwFlags, dwReserved)#uselib "urlmon.dll"
#func global CoInternetGetProtocolFlags "CoInternetGetProtocolFlags" sptr, sptr, sptr
; CoInternetGetProtocolFlags pwzUrl, varptr(pdwFlags), dwReserved ; 戻り値は stat
; pwzUrl : LPCWSTR -> "sptr"
; pdwFlags : DWORD* out -> "sptr"
; dwReserved : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "urlmon.dll" #cfunc global CoInternetGetProtocolFlags "CoInternetGetProtocolFlags" wstr, var, int ; res = CoInternetGetProtocolFlags(pwzUrl, pdwFlags, dwReserved) ; pwzUrl : LPCWSTR -> "wstr" ; pdwFlags : DWORD* out -> "var" ; dwReserved : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "urlmon.dll" #cfunc global CoInternetGetProtocolFlags "CoInternetGetProtocolFlags" wstr, sptr, int ; res = CoInternetGetProtocolFlags(pwzUrl, varptr(pdwFlags), dwReserved) ; pwzUrl : LPCWSTR -> "wstr" ; pdwFlags : DWORD* out -> "sptr" ; dwReserved : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT CoInternetGetProtocolFlags(LPCWSTR pwzUrl, DWORD* pdwFlags, DWORD dwReserved) #uselib "urlmon.dll" #cfunc global CoInternetGetProtocolFlags "CoInternetGetProtocolFlags" wstr, var, int ; res = CoInternetGetProtocolFlags(pwzUrl, pdwFlags, dwReserved) ; pwzUrl : LPCWSTR -> "wstr" ; pdwFlags : DWORD* out -> "var" ; dwReserved : DWORD -> "int" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT CoInternetGetProtocolFlags(LPCWSTR pwzUrl, DWORD* pdwFlags, DWORD dwReserved) #uselib "urlmon.dll" #cfunc global CoInternetGetProtocolFlags "CoInternetGetProtocolFlags" wstr, intptr, int ; res = CoInternetGetProtocolFlags(pwzUrl, varptr(pdwFlags), dwReserved) ; pwzUrl : LPCWSTR -> "wstr" ; pdwFlags : DWORD* out -> "intptr" ; dwReserved : DWORD -> "int" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
urlmon = windows.NewLazySystemDLL("urlmon.dll")
procCoInternetGetProtocolFlags = urlmon.NewProc("CoInternetGetProtocolFlags")
)
// pwzUrl (LPCWSTR), pdwFlags (DWORD* out), dwReserved (DWORD)
r1, _, err := procCoInternetGetProtocolFlags.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pwzUrl))),
uintptr(pdwFlags),
uintptr(dwReserved),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction CoInternetGetProtocolFlags(
pwzUrl: PWideChar; // LPCWSTR
pdwFlags: Pointer; // DWORD* out
dwReserved: DWORD // DWORD
): Integer; stdcall;
external 'urlmon.dll' name 'CoInternetGetProtocolFlags';result := DllCall("urlmon\CoInternetGetProtocolFlags"
, "WStr", pwzUrl ; LPCWSTR
, "Ptr", pdwFlags ; DWORD* out
, "UInt", dwReserved ; DWORD
, "Int") ; return: HRESULT●CoInternetGetProtocolFlags(pwzUrl, pdwFlags, dwReserved) = DLL("urlmon.dll", "int CoInternetGetProtocolFlags(char*, void*, dword)")
# 呼び出し: CoInternetGetProtocolFlags(pwzUrl, pdwFlags, dwReserved)
# pwzUrl : LPCWSTR -> "char*"
# pdwFlags : DWORD* out -> "void*"
# dwReserved : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。