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