ホーム › Devices.DeviceQuery › DevFindProperty
DevFindProperty
関数プロパティ配列から指定キーのプロパティを検索する。
シグネチャ
// api-ms-win-devices-query-l1-1-0.dll
#include <windows.h>
DEVPROPERTY* DevFindProperty(
const DEVPROPKEY* pKey,
DEVPROPSTORE Store,
LPCWSTR pszLocaleName,
DWORD cProperties,
const DEVPROPERTY* pProperties // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| pKey | DEVPROPKEY* | in |
| Store | DEVPROPSTORE | in |
| pszLocaleName | LPCWSTR | in |
| cProperties | DWORD | in |
| pProperties | DEVPROPERTY* | inoptional |
戻り値の型: DEVPROPERTY*
各言語での呼び出し定義
// api-ms-win-devices-query-l1-1-0.dll
#include <windows.h>
DEVPROPERTY* DevFindProperty(
const DEVPROPKEY* pKey,
DEVPROPSTORE Store,
LPCWSTR pszLocaleName,
DWORD cProperties,
const DEVPROPERTY* pProperties // optional
);[DllImport("api-ms-win-devices-query-l1-1-0.dll", ExactSpelling = true)]
static extern IntPtr DevFindProperty(
IntPtr pKey, // DEVPROPKEY*
int Store, // DEVPROPSTORE
[MarshalAs(UnmanagedType.LPWStr)] string pszLocaleName, // LPCWSTR
uint cProperties, // DWORD
IntPtr pProperties // DEVPROPERTY* optional
);<DllImport("api-ms-win-devices-query-l1-1-0.dll", ExactSpelling:=True)>
Public Shared Function DevFindProperty(
pKey As IntPtr, ' DEVPROPKEY*
Store As Integer, ' DEVPROPSTORE
<MarshalAs(UnmanagedType.LPWStr)> pszLocaleName As String, ' LPCWSTR
cProperties As UInteger, ' DWORD
pProperties As IntPtr ' DEVPROPERTY* optional
) As IntPtr
End Function' pKey : DEVPROPKEY*
' Store : DEVPROPSTORE
' pszLocaleName : LPCWSTR
' cProperties : DWORD
' pProperties : DEVPROPERTY* optional
Declare PtrSafe Function DevFindProperty Lib "api-ms-win-devices-query-l1-1-0" ( _
ByVal pKey As LongPtr, _
ByVal Store As Long, _
ByVal pszLocaleName As LongPtr, _
ByVal cProperties As Long, _
ByVal pProperties As LongPtr) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
DevFindProperty = ctypes.windll.LoadLibrary("api-ms-win-devices-query-l1-1-0.dll").DevFindProperty
DevFindProperty.restype = ctypes.c_void_p
DevFindProperty.argtypes = [
ctypes.c_void_p, # pKey : DEVPROPKEY*
ctypes.c_int, # Store : DEVPROPSTORE
wintypes.LPCWSTR, # pszLocaleName : LPCWSTR
wintypes.DWORD, # cProperties : DWORD
ctypes.c_void_p, # pProperties : DEVPROPERTY* optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-devices-query-l1-1-0.dll')
DevFindProperty = Fiddle::Function.new(
lib['DevFindProperty'],
[
Fiddle::TYPE_VOIDP, # pKey : DEVPROPKEY*
Fiddle::TYPE_INT, # Store : DEVPROPSTORE
Fiddle::TYPE_VOIDP, # pszLocaleName : LPCWSTR
-Fiddle::TYPE_INT, # cProperties : DWORD
Fiddle::TYPE_VOIDP, # pProperties : DEVPROPERTY* optional
],
Fiddle::TYPE_VOIDP)#[link(name = "api-ms-win-devices-query-l1-1-0")]
extern "system" {
fn DevFindProperty(
pKey: *const DEVPROPKEY, // DEVPROPKEY*
Store: i32, // DEVPROPSTORE
pszLocaleName: *const u16, // LPCWSTR
cProperties: u32, // DWORD
pProperties: *const DEVPROPERTY // DEVPROPERTY* optional
) -> *mut DEVPROPERTY;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("api-ms-win-devices-query-l1-1-0.dll")]
public static extern IntPtr DevFindProperty(IntPtr pKey, int Store, [MarshalAs(UnmanagedType.LPWStr)] string pszLocaleName, uint cProperties, IntPtr pProperties);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-devices-query-l1-1-0_DevFindProperty' -Namespace Win32 -PassThru
# $api::DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties)#uselib "api-ms-win-devices-query-l1-1-0.dll"
#func global DevFindProperty "DevFindProperty" sptr, sptr, sptr, sptr, sptr
; DevFindProperty varptr(pKey), Store, pszLocaleName, cProperties, varptr(pProperties) ; 戻り値は stat
; pKey : DEVPROPKEY* -> "sptr"
; Store : DEVPROPSTORE -> "sptr"
; pszLocaleName : LPCWSTR -> "sptr"
; cProperties : DWORD -> "sptr"
; pProperties : DEVPROPERTY* optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-devices-query-l1-1-0.dll" #cfunc global DevFindProperty "DevFindProperty" var, int, wstr, int, var ; res = DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties) ; pKey : DEVPROPKEY* -> "var" ; Store : DEVPROPSTORE -> "int" ; pszLocaleName : LPCWSTR -> "wstr" ; cProperties : DWORD -> "int" ; pProperties : DEVPROPERTY* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-devices-query-l1-1-0.dll" #cfunc global DevFindProperty "DevFindProperty" sptr, int, wstr, int, sptr ; res = DevFindProperty(varptr(pKey), Store, pszLocaleName, cProperties, varptr(pProperties)) ; pKey : DEVPROPKEY* -> "sptr" ; Store : DEVPROPSTORE -> "int" ; pszLocaleName : LPCWSTR -> "wstr" ; cProperties : DWORD -> "int" ; pProperties : DEVPROPERTY* optional -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DEVPROPERTY* DevFindProperty(DEVPROPKEY* pKey, DEVPROPSTORE Store, LPCWSTR pszLocaleName, DWORD cProperties, DEVPROPERTY* pProperties) #uselib "api-ms-win-devices-query-l1-1-0.dll" #cfunc global DevFindProperty "DevFindProperty" var, int, wstr, int, var ; res = DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties) ; pKey : DEVPROPKEY* -> "var" ; Store : DEVPROPSTORE -> "int" ; pszLocaleName : LPCWSTR -> "wstr" ; cProperties : DWORD -> "int" ; pProperties : DEVPROPERTY* optional -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DEVPROPERTY* DevFindProperty(DEVPROPKEY* pKey, DEVPROPSTORE Store, LPCWSTR pszLocaleName, DWORD cProperties, DEVPROPERTY* pProperties) #uselib "api-ms-win-devices-query-l1-1-0.dll" #cfunc global DevFindProperty "DevFindProperty" intptr, int, wstr, int, intptr ; res = DevFindProperty(varptr(pKey), Store, pszLocaleName, cProperties, varptr(pProperties)) ; pKey : DEVPROPKEY* -> "intptr" ; Store : DEVPROPSTORE -> "int" ; pszLocaleName : LPCWSTR -> "wstr" ; cProperties : DWORD -> "int" ; pProperties : DEVPROPERTY* optional -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
api_ms_win_devices_query_l1_1_0 = windows.NewLazySystemDLL("api-ms-win-devices-query-l1-1-0.dll")
procDevFindProperty = api_ms_win_devices_query_l1_1_0.NewProc("DevFindProperty")
)
// pKey (DEVPROPKEY*), Store (DEVPROPSTORE), pszLocaleName (LPCWSTR), cProperties (DWORD), pProperties (DEVPROPERTY* optional)
r1, _, err := procDevFindProperty.Call(
uintptr(pKey),
uintptr(Store),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszLocaleName))),
uintptr(cProperties),
uintptr(pProperties),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DEVPROPERTY*function DevFindProperty(
pKey: Pointer; // DEVPROPKEY*
Store: Integer; // DEVPROPSTORE
pszLocaleName: PWideChar; // LPCWSTR
cProperties: DWORD; // DWORD
pProperties: Pointer // DEVPROPERTY* optional
): Pointer; stdcall;
external 'api-ms-win-devices-query-l1-1-0.dll' name 'DevFindProperty';result := DllCall("api-ms-win-devices-query-l1-1-0\DevFindProperty"
, "Ptr", pKey ; DEVPROPKEY*
, "Int", Store ; DEVPROPSTORE
, "WStr", pszLocaleName ; LPCWSTR
, "UInt", cProperties ; DWORD
, "Ptr", pProperties ; DEVPROPERTY* optional
, "Ptr") ; return: DEVPROPERTY*●DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties) = DLL("api-ms-win-devices-query-l1-1-0.dll", "void* DevFindProperty(void*, int, char*, dword, void*)")
# 呼び出し: DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties)
# pKey : DEVPROPKEY* -> "void*"
# Store : DEVPROPSTORE -> "int"
# pszLocaleName : LPCWSTR -> "char*"
# cProperties : DWORD -> "dword"
# pProperties : DEVPROPERTY* optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。