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

IsValidURL

関数
指定した文字列が有効なURLかどうかを判定する。
DLLurlmon.dll呼出規約winapi

シグネチャ

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

HRESULT IsValidURL(
    IBindCtx* pBC,   // optional
    LPCWSTR szURL,
    DWORD dwReserved
);

パラメーター

名前方向
pBCIBindCtx*inoptional
szURLLPCWSTRin
dwReservedDWORDin

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

IsValidURL = ctypes.windll.urlmon.IsValidURL
IsValidURL.restype = ctypes.c_int
IsValidURL.argtypes = [
    ctypes.c_void_p,  # pBC : IBindCtx* optional
    wintypes.LPCWSTR,  # szURL : LPCWSTR
    wintypes.DWORD,  # dwReserved : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('urlmon.dll')
IsValidURL = Fiddle::Function.new(
  lib['IsValidURL'],
  [
    Fiddle::TYPE_VOIDP,  # pBC : IBindCtx* optional
    Fiddle::TYPE_VOIDP,  # szURL : LPCWSTR
    -Fiddle::TYPE_INT,  # dwReserved : DWORD
  ],
  Fiddle::TYPE_INT)
#[link(name = "urlmon")]
extern "system" {
    fn IsValidURL(
        pBC: *mut core::ffi::c_void,  // IBindCtx* optional
        szURL: *const u16,  // LPCWSTR
        dwReserved: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("urlmon.dll")]
public static extern int IsValidURL(IntPtr pBC, [MarshalAs(UnmanagedType.LPWStr)] string szURL, uint dwReserved);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_IsValidURL' -Namespace Win32 -PassThru
# $api::IsValidURL(pBC, szURL, dwReserved)
#uselib "urlmon.dll"
#func global IsValidURL "IsValidURL" sptr, sptr, sptr
; IsValidURL pBC, szURL, dwReserved   ; 戻り値は stat
; pBC : IBindCtx* optional -> "sptr"
; szURL : LPCWSTR -> "sptr"
; dwReserved : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "urlmon.dll"
#cfunc global IsValidURL "IsValidURL" sptr, wstr, int
; res = IsValidURL(pBC, szURL, dwReserved)
; pBC : IBindCtx* optional -> "sptr"
; szURL : LPCWSTR -> "wstr"
; dwReserved : DWORD -> "int"
; HRESULT IsValidURL(IBindCtx* pBC, LPCWSTR szURL, DWORD dwReserved)
#uselib "urlmon.dll"
#cfunc global IsValidURL "IsValidURL" intptr, wstr, int
; res = IsValidURL(pBC, szURL, dwReserved)
; pBC : IBindCtx* optional -> "intptr"
; szURL : LPCWSTR -> "wstr"
; dwReserved : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	urlmon = windows.NewLazySystemDLL("urlmon.dll")
	procIsValidURL = urlmon.NewProc("IsValidURL")
)

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