Win32 API 日本語リファレンス
ホームUI.Shell › UrlIsA

UrlIsA

関数
URLが指定した種別の条件を満たすかどうかを判定する。
DLLSHLWAPI.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHLWAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL UrlIsA(
    LPCSTR pszUrl,
    URLIS UrlIs
);

パラメーター

名前方向説明
pszUrlLPCSTRinURL を含む、最大長 INTERNET_MAX_URL_LENGTH の null 終端文字列です。
UrlIsURLISin

テスト対象とする URL の種類です。このパラメーターには次の値のいずれかを指定できます。

URLIS_APPLIABLE

URL の有効なスキームを判別しようとします。

URLIS_DIRECTORY

URL 文字列がディレクトリで終わっているかどうか。

URLIS_FILEURL

URL がファイル URL かどうか。

URLIS_HASQUERY

URL にクエリ文字列が付加されているかどうか。

URLIS_NOHISTORY

URL が通常ナビゲーション履歴に記録されない種類の URL かどうか。

URLIS_OPAQUE

URL が 不透明 (opaque) かどうか。

URLIS_URL

URL が有効かどうか。

戻り値の型: BOOL

公式ドキュメント

URL が指定された種類かどうかをテストします。(ANSI)

戻り値

型: BOOL

1 つを除くすべての URL の種類について、UrlIs は URL が指定された種類であれば TRUE を、そうでなければ FALSE を返します。

UrlIsURLIS_APPLIABLE が設定されている場合、UrlIs は URL のスキームを判別しようとします。スキームを判別できた場合は TRUE を、そうでない場合は FALSE を返します。

解説(Remarks)

メモ

shlwapi.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして UrlIs を定義します。エンコーディング中立なエイリアスの使用を、エンコーディング中立でないコードと混在させると、不一致が生じてコンパイルエラーや実行時エラーの原因となることがあります。詳細については、関数プロトタイプの規則 を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

// SHLWAPI.dll  (ANSI / -A)
#include <windows.h>

BOOL UrlIsA(
    LPCSTR pszUrl,
    URLIS UrlIs
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool UrlIsA(
    [MarshalAs(UnmanagedType.LPStr)] string pszUrl,   // LPCSTR
    int UrlIs   // URLIS
);
<DllImport("SHLWAPI.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function UrlIsA(
    <MarshalAs(UnmanagedType.LPStr)> pszUrl As String,   ' LPCSTR
    UrlIs As Integer   ' URLIS
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pszUrl : LPCSTR
' UrlIs : URLIS
Declare PtrSafe Function UrlIsA Lib "shlwapi" ( _
    ByVal pszUrl As String, _
    ByVal UrlIs As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UrlIsA = ctypes.windll.shlwapi.UrlIsA
UrlIsA.restype = wintypes.BOOL
UrlIsA.argtypes = [
    wintypes.LPCSTR,  # pszUrl : LPCSTR
    ctypes.c_int,  # UrlIs : URLIS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
UrlIsA = Fiddle::Function.new(
  lib['UrlIsA'],
  [
    Fiddle::TYPE_VOIDP,  # pszUrl : LPCSTR
    Fiddle::TYPE_INT,  # UrlIs : URLIS
  ],
  Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn UrlIsA(
        pszUrl: *const u8,  // LPCSTR
        UrlIs: i32  // URLIS
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHLWAPI.dll", CharSet = CharSet.Ansi)]
public static extern bool UrlIsA([MarshalAs(UnmanagedType.LPStr)] string pszUrl, int UrlIs);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_UrlIsA' -Namespace Win32 -PassThru
# $api::UrlIsA(pszUrl, UrlIs)
#uselib "SHLWAPI.dll"
#func global UrlIsA "UrlIsA" sptr, sptr
; UrlIsA pszUrl, UrlIs   ; 戻り値は stat
; pszUrl : LPCSTR -> "sptr"
; UrlIs : URLIS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global UrlIsA "UrlIsA" str, int
; res = UrlIsA(pszUrl, UrlIs)
; pszUrl : LPCSTR -> "str"
; UrlIs : URLIS -> "int"
; BOOL UrlIsA(LPCSTR pszUrl, URLIS UrlIs)
#uselib "SHLWAPI.dll"
#cfunc global UrlIsA "UrlIsA" str, int
; res = UrlIsA(pszUrl, UrlIs)
; pszUrl : LPCSTR -> "str"
; UrlIs : URLIS -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procUrlIsA = shlwapi.NewProc("UrlIsA")
)

// pszUrl (LPCSTR), UrlIs (URLIS)
r1, _, err := procUrlIsA.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(pszUrl))),
	uintptr(UrlIs),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function UrlIsA(
  pszUrl: PAnsiChar;   // LPCSTR
  UrlIs: Integer   // URLIS
): BOOL; stdcall;
  external 'SHLWAPI.dll' name 'UrlIsA';
result := DllCall("SHLWAPI\UrlIsA"
    , "AStr", pszUrl   ; LPCSTR
    , "Int", UrlIs   ; URLIS
    , "Int")   ; return: BOOL
●UrlIsA(pszUrl, UrlIs) = DLL("SHLWAPI.dll", "bool UrlIsA(char*, int)")
# 呼び出し: UrlIsA(pszUrl, UrlIs)
# pszUrl : LPCSTR -> "char*"
# UrlIs : URLIS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "shlwapi" fn UrlIsA(
    pszUrl: [*c]const u8, // LPCSTR
    UrlIs: i32 // URLIS
) callconv(std.os.windows.WINAPI) i32;
proc UrlIsA(
    pszUrl: cstring,  # LPCSTR
    UrlIs: int32  # URLIS
): int32 {.importc: "UrlIsA", stdcall, dynlib: "SHLWAPI.dll".}
pragma(lib, "shlwapi");
extern(Windows)
int UrlIsA(
    const(char)* pszUrl,   // LPCSTR
    int UrlIs   // URLIS
);
ccall((:UrlIsA, "SHLWAPI.dll"), stdcall, Int32,
      (Cstring, Int32),
      pszUrl, UrlIs)
# pszUrl : LPCSTR -> Cstring
# UrlIs : URLIS -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t UrlIsA(
    const char* pszUrl,
    int32_t UrlIs);
]]
local shlwapi = ffi.load("shlwapi")
-- shlwapi.UrlIsA(pszUrl, UrlIs)
-- pszUrl : LPCSTR
-- UrlIs : URLIS
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SHLWAPI.dll');
const UrlIsA = lib.func('__stdcall', 'UrlIsA', 'int32_t', ['str', 'int32_t']);
// UrlIsA(pszUrl, UrlIs)
// pszUrl : LPCSTR -> 'str'
// UrlIs : URLIS -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SHLWAPI.dll", {
  UrlIsA: { parameters: ["buffer", "i32"], result: "i32" },
});
// lib.symbols.UrlIsA(pszUrl, UrlIs)
// pszUrl : LPCSTR -> "buffer"
// UrlIs : URLIS -> "i32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t UrlIsA(
    const char* pszUrl,
    int32_t UrlIs);
C, "SHLWAPI.dll");
// $ffi->UrlIsA(pszUrl, UrlIs);
// pszUrl : LPCSTR
// UrlIs : URLIS
// 構造体/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 Shlwapi extends StdCallLibrary {
    Shlwapi INSTANCE = Native.load("shlwapi", Shlwapi.class, W32APIOptions.ASCII_OPTIONS);
    boolean UrlIsA(
        String pszUrl,   // LPCSTR
        int UrlIs   // URLIS
    );
}
@[Link("shlwapi")]
lib LibSHLWAPI
  fun UrlIsA = UrlIsA(
    pszUrl : UInt8*,   # LPCSTR
    UrlIs : Int32   # URLIS
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef UrlIsANative = Int32 Function(Pointer<Utf8>, Int32);
typedef UrlIsADart = int Function(Pointer<Utf8>, int);
final UrlIsA = DynamicLibrary.open('SHLWAPI.dll')
    .lookupFunction<UrlIsANative, UrlIsADart>('UrlIsA');
// pszUrl : LPCSTR -> Pointer<Utf8>
// UrlIs : URLIS -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function UrlIsA(
  pszUrl: PAnsiChar;   // LPCSTR
  UrlIs: Integer   // URLIS
): BOOL; stdcall;
  external 'SHLWAPI.dll' name 'UrlIsA';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "UrlIsA"
  c_UrlIsA :: CString -> Int32 -> IO CInt
-- pszUrl : LPCSTR -> CString
-- UrlIs : URLIS -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let urlisa =
  foreign "UrlIsA"
    (string @-> int32_t @-> returning int32_t)
(* pszUrl : LPCSTR -> string *)
(* UrlIs : URLIS -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shlwapi (t "SHLWAPI.dll"))
(cffi:use-foreign-library shlwapi)

(cffi:defcfun ("UrlIsA" url-is-a :convention :stdcall) :int32
  (psz-url :string)   ; LPCSTR
  (url-is :int32))   ; URLIS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $UrlIsA = Win32::API::More->new('SHLWAPI',
    'BOOL UrlIsA(LPCSTR pszUrl, int UrlIs)');
# my $ret = $UrlIsA->Call($pszUrl, $UrlIs);
# pszUrl : LPCSTR -> LPCSTR
# UrlIs : URLIS -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

文字セット違い
公式の関連項目
使用する型