SHAssocEnumHandlersForProtocolByApplication
関数プロトコルに対応するアプリ別ハンドラーを列挙する。
シグネチャ
// SHELL32.dll
#include <windows.h>
HRESULT SHAssocEnumHandlersForProtocolByApplication(
LPCWSTR protocol,
const GUID* riid,
void** enumHandlers
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| protocol | LPCWSTR | in | プロトコルを指定する文字列へのポインター。 |
| riid | GUID* | in | enumHandlers を通じて取得するインターフェイスの IID への参照。通常は IID_IEnumAssocHandlers です。 |
| enumHandlers | void** | out | このメソッドが返るとき、riid で要求されたインターフェイスポインターが格納されます。通常は IEnumAssocHandlers です。 |
戻り値の型: HRESULT
公式ドキュメント
指定したプロトコルに関連付けられたハンドラーへのアクセスを提供する列挙インターフェイスを取得します。
戻り値
型: HRESULT
この関数が成功した場合は S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。
解説(Remarks)
riid パラメーターと enumHandlers パラメーターをまとめるには、Objbase.h で定義されている IID_PPV_ARGS マクロを使用することをお勧めします。このマクロは enumHandlers の値が指すインターフェイスに基づいて正しい IID を提供するため、コーディングエラーの可能性を排除できます。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
HRESULT SHAssocEnumHandlersForProtocolByApplication(
LPCWSTR protocol,
const GUID* riid,
void** enumHandlers
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHAssocEnumHandlersForProtocolByApplication(
[MarshalAs(UnmanagedType.LPWStr)] string protocol, // LPCWSTR
ref Guid riid, // GUID*
IntPtr enumHandlers // void** out
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHAssocEnumHandlersForProtocolByApplication(
<MarshalAs(UnmanagedType.LPWStr)> protocol As String, ' LPCWSTR
ByRef riid As Guid, ' GUID*
enumHandlers As IntPtr ' void** out
) As Integer
End Function' protocol : LPCWSTR
' riid : GUID*
' enumHandlers : void** out
Declare PtrSafe Function SHAssocEnumHandlersForProtocolByApplication Lib "shell32" ( _
ByVal protocol As LongPtr, _
ByVal riid As LongPtr, _
ByVal enumHandlers As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
SHAssocEnumHandlersForProtocolByApplication = ctypes.windll.shell32.SHAssocEnumHandlersForProtocolByApplication
SHAssocEnumHandlersForProtocolByApplication.restype = ctypes.c_int
SHAssocEnumHandlersForProtocolByApplication.argtypes = [
wintypes.LPCWSTR, # protocol : LPCWSTR
ctypes.c_void_p, # riid : GUID*
ctypes.c_void_p, # enumHandlers : void** out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
SHAssocEnumHandlersForProtocolByApplication = Fiddle::Function.new(
lib['SHAssocEnumHandlersForProtocolByApplication'],
[
Fiddle::TYPE_VOIDP, # protocol : LPCWSTR
Fiddle::TYPE_VOIDP, # riid : GUID*
Fiddle::TYPE_VOIDP, # enumHandlers : void** out
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn SHAssocEnumHandlersForProtocolByApplication(
protocol: *const u16, // LPCWSTR
riid: *const GUID, // GUID*
enumHandlers: *mut *mut () // void** out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHAssocEnumHandlersForProtocolByApplication([MarshalAs(UnmanagedType.LPWStr)] string protocol, ref Guid riid, IntPtr enumHandlers);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHAssocEnumHandlersForProtocolByApplication' -Namespace Win32 -PassThru
# $api::SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers)#uselib "SHELL32.dll"
#func global SHAssocEnumHandlersForProtocolByApplication "SHAssocEnumHandlersForProtocolByApplication" sptr, sptr, sptr
; SHAssocEnumHandlersForProtocolByApplication protocol, varptr(riid), enumHandlers ; 戻り値は stat
; protocol : LPCWSTR -> "sptr"
; riid : GUID* -> "sptr"
; enumHandlers : void** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "SHELL32.dll" #cfunc global SHAssocEnumHandlersForProtocolByApplication "SHAssocEnumHandlersForProtocolByApplication" wstr, var, sptr ; res = SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers) ; protocol : LPCWSTR -> "wstr" ; riid : GUID* -> "var" ; enumHandlers : void** out -> "sptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #cfunc global SHAssocEnumHandlersForProtocolByApplication "SHAssocEnumHandlersForProtocolByApplication" wstr, sptr, sptr ; res = SHAssocEnumHandlersForProtocolByApplication(protocol, varptr(riid), enumHandlers) ; protocol : LPCWSTR -> "wstr" ; riid : GUID* -> "sptr" ; enumHandlers : void** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT SHAssocEnumHandlersForProtocolByApplication(LPCWSTR protocol, GUID* riid, void** enumHandlers) #uselib "SHELL32.dll" #cfunc global SHAssocEnumHandlersForProtocolByApplication "SHAssocEnumHandlersForProtocolByApplication" wstr, var, intptr ; res = SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers) ; protocol : LPCWSTR -> "wstr" ; riid : GUID* -> "var" ; enumHandlers : void** out -> "intptr" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT SHAssocEnumHandlersForProtocolByApplication(LPCWSTR protocol, GUID* riid, void** enumHandlers) #uselib "SHELL32.dll" #cfunc global SHAssocEnumHandlersForProtocolByApplication "SHAssocEnumHandlersForProtocolByApplication" wstr, intptr, intptr ; res = SHAssocEnumHandlersForProtocolByApplication(protocol, varptr(riid), enumHandlers) ; protocol : LPCWSTR -> "wstr" ; riid : GUID* -> "intptr" ; enumHandlers : void** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procSHAssocEnumHandlersForProtocolByApplication = shell32.NewProc("SHAssocEnumHandlersForProtocolByApplication")
)
// protocol (LPCWSTR), riid (GUID*), enumHandlers (void** out)
r1, _, err := procSHAssocEnumHandlersForProtocolByApplication.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(protocol))),
uintptr(riid),
uintptr(enumHandlers),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction SHAssocEnumHandlersForProtocolByApplication(
protocol: PWideChar; // LPCWSTR
riid: PGUID; // GUID*
enumHandlers: Pointer // void** out
): Integer; stdcall;
external 'SHELL32.dll' name 'SHAssocEnumHandlersForProtocolByApplication';result := DllCall("SHELL32\SHAssocEnumHandlersForProtocolByApplication"
, "WStr", protocol ; LPCWSTR
, "Ptr", riid ; GUID*
, "Ptr", enumHandlers ; void** out
, "Int") ; return: HRESULT●SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers) = DLL("SHELL32.dll", "int SHAssocEnumHandlersForProtocolByApplication(char*, void*, void*)")
# 呼び出し: SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers)
# protocol : LPCWSTR -> "char*"
# riid : GUID* -> "void*"
# enumHandlers : void** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn SHAssocEnumHandlersForProtocolByApplication(
protocol: [*c]const u16, // LPCWSTR
riid: [*c]GUID, // GUID*
enumHandlers: ?*anyopaque // void** out
) callconv(std.os.windows.WINAPI) i32;proc SHAssocEnumHandlersForProtocolByApplication(
protocol: WideCString, # LPCWSTR
riid: ptr GUID, # GUID*
enumHandlers: pointer # void** out
): int32 {.importc: "SHAssocEnumHandlersForProtocolByApplication", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int SHAssocEnumHandlersForProtocolByApplication(
const(wchar)* protocol, // LPCWSTR
GUID* riid, // GUID*
void** enumHandlers // void** out
);ccall((:SHAssocEnumHandlersForProtocolByApplication, "SHELL32.dll"), stdcall, Int32,
(Cwstring, Ptr{GUID}, Ptr{Cvoid}),
protocol, riid, enumHandlers)
# protocol : LPCWSTR -> Cwstring
# riid : GUID* -> Ptr{GUID}
# enumHandlers : void** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t SHAssocEnumHandlersForProtocolByApplication(
const uint16_t* protocol,
void* riid,
void** enumHandlers);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers)
-- protocol : LPCWSTR
-- riid : GUID*
-- enumHandlers : void** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHAssocEnumHandlersForProtocolByApplication = lib.func('__stdcall', 'SHAssocEnumHandlersForProtocolByApplication', 'int32_t', ['str16', 'void *', 'void *']);
// SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers)
// protocol : LPCWSTR -> 'str16'
// riid : GUID* -> 'void *'
// enumHandlers : void** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
SHAssocEnumHandlersForProtocolByApplication: { parameters: ["buffer", "pointer", "pointer"], result: "i32" },
});
// lib.symbols.SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers)
// protocol : LPCWSTR -> "buffer"
// riid : GUID* -> "pointer"
// enumHandlers : void** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t SHAssocEnumHandlersForProtocolByApplication(
const uint16_t* protocol,
void* riid,
void** enumHandlers);
C, "SHELL32.dll");
// $ffi->SHAssocEnumHandlersForProtocolByApplication(protocol, riid, enumHandlers);
// protocol : LPCWSTR
// riid : GUID*
// enumHandlers : void** out
// 構造体/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 Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class);
int SHAssocEnumHandlersForProtocolByApplication(
WString protocol, // LPCWSTR
Pointer riid, // GUID*
Pointer enumHandlers // void** out
);
}@[Link("shell32")]
lib LibSHELL32
fun SHAssocEnumHandlersForProtocolByApplication = SHAssocEnumHandlersForProtocolByApplication(
protocol : UInt16*, # LPCWSTR
riid : GUID*, # GUID*
enumHandlers : Void** # void** out
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef SHAssocEnumHandlersForProtocolByApplicationNative = Int32 Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
typedef SHAssocEnumHandlersForProtocolByApplicationDart = int Function(Pointer<Utf16>, Pointer<Void>, Pointer<Void>);
final SHAssocEnumHandlersForProtocolByApplication = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<SHAssocEnumHandlersForProtocolByApplicationNative, SHAssocEnumHandlersForProtocolByApplicationDart>('SHAssocEnumHandlersForProtocolByApplication');
// protocol : LPCWSTR -> Pointer<Utf16>
// riid : GUID* -> Pointer<Void>
// enumHandlers : void** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function SHAssocEnumHandlersForProtocolByApplication(
protocol: PWideChar; // LPCWSTR
riid: PGUID; // GUID*
enumHandlers: Pointer // void** out
): Integer; stdcall;
external 'SHELL32.dll' name 'SHAssocEnumHandlersForProtocolByApplication';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "SHAssocEnumHandlersForProtocolByApplication"
c_SHAssocEnumHandlersForProtocolByApplication :: CWString -> Ptr () -> Ptr () -> IO Int32
-- protocol : LPCWSTR -> CWString
-- riid : GUID* -> Ptr ()
-- enumHandlers : void** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let shassocenumhandlersforprotocolbyapplication =
foreign "SHAssocEnumHandlersForProtocolByApplication"
((ptr uint16_t) @-> (ptr void) @-> (ptr void) @-> returning int32_t)
(* protocol : LPCWSTR -> (ptr uint16_t) *)
(* riid : GUID* -> (ptr void) *)
(* enumHandlers : void** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("SHAssocEnumHandlersForProtocolByApplication" shassoc-enum-handlers-for-protocol-by-application :convention :stdcall) :int32
(protocol (:string :encoding :utf-16le)) ; LPCWSTR
(riid :pointer) ; GUID*
(enum-handlers :pointer)) ; void** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $SHAssocEnumHandlersForProtocolByApplication = Win32::API::More->new('SHELL32',
'int SHAssocEnumHandlersForProtocolByApplication(LPCWSTR protocol, LPVOID riid, LPVOID enumHandlers)');
# my $ret = $SHAssocEnumHandlersForProtocolByApplication->Call($protocol, $riid, $enumHandlers);
# protocol : LPCWSTR -> LPCWSTR
# riid : GUID* -> LPVOID
# enumHandlers : void** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。