ホーム › 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 | 検索したいプロパティを識別するDEVPROPKEYへのポインター。 |
| Store | DEVPROPSTORE | in | プロパティの格納先を示すDEVPROPSTORE列挙値。システムまたはユーザーを指定する。 |
| pszLocaleName | LPCWSTR | in | ローカライズされたプロパティ用のロケール名文字列(Unicode)。NULL可。 |
| cProperties | DWORD | in | 検索対象のpProperties配列の要素数。 |
| pProperties | DEVPROPERTY* | inoptional | 検索対象となるDEVPROPERTY配列へのポインター。一致した要素を返す。 |
戻り値の型: 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)。const std = @import("std");
extern "api-ms-win-devices-query-l1-1-0" fn DevFindProperty(
pKey: [*c]DEVPROPKEY, // DEVPROPKEY*
Store: i32, // DEVPROPSTORE
pszLocaleName: [*c]const u16, // LPCWSTR
cProperties: u32, // DWORD
pProperties: [*c]DEVPROPERTY // DEVPROPERTY* optional
) callconv(std.os.windows.WINAPI) [*c]DEVPROPERTY;proc DevFindProperty(
pKey: ptr DEVPROPKEY, # DEVPROPKEY*
Store: int32, # DEVPROPSTORE
pszLocaleName: WideCString, # LPCWSTR
cProperties: uint32, # DWORD
pProperties: ptr DEVPROPERTY # DEVPROPERTY* optional
): ptr DEVPROPERTY {.importc: "DevFindProperty", stdcall, dynlib: "api-ms-win-devices-query-l1-1-0.dll".}pragma(lib, "api-ms-win-devices-query-l1-1-0");
extern(Windows)
DEVPROPERTY* DevFindProperty(
DEVPROPKEY* pKey, // DEVPROPKEY*
int Store, // DEVPROPSTORE
const(wchar)* pszLocaleName, // LPCWSTR
uint cProperties, // DWORD
DEVPROPERTY* pProperties // DEVPROPERTY* optional
);ccall((:DevFindProperty, "api-ms-win-devices-query-l1-1-0.dll"), stdcall, Ptr{DEVPROPERTY},
(Ptr{DEVPROPKEY}, Int32, Cwstring, UInt32, Ptr{DEVPROPERTY}),
pKey, Store, pszLocaleName, cProperties, pProperties)
# pKey : DEVPROPKEY* -> Ptr{DEVPROPKEY}
# Store : DEVPROPSTORE -> Int32
# pszLocaleName : LPCWSTR -> Cwstring
# cProperties : DWORD -> UInt32
# pProperties : DEVPROPERTY* optional -> Ptr{DEVPROPERTY}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* DevFindProperty(
void* pKey,
int32_t Store,
const uint16_t* pszLocaleName,
uint32_t cProperties,
void* pProperties);
]]
local api-ms-win-devices-query-l1-1-0 = ffi.load("api-ms-win-devices-query-l1-1-0")
-- api-ms-win-devices-query-l1-1-0.DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties)
-- pKey : DEVPROPKEY*
-- Store : DEVPROPSTORE
-- pszLocaleName : LPCWSTR
-- cProperties : DWORD
-- pProperties : DEVPROPERTY* optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-devices-query-l1-1-0.dll');
const DevFindProperty = lib.func('__stdcall', 'DevFindProperty', 'void *', ['void *', 'int32_t', 'str16', 'uint32_t', 'void *']);
// DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties)
// pKey : DEVPROPKEY* -> 'void *'
// Store : DEVPROPSTORE -> 'int32_t'
// pszLocaleName : LPCWSTR -> 'str16'
// cProperties : DWORD -> 'uint32_t'
// pProperties : DEVPROPERTY* optional -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-devices-query-l1-1-0.dll", {
DevFindProperty: { parameters: ["pointer", "i32", "buffer", "u32", "pointer"], result: "pointer" },
});
// lib.symbols.DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties)
// pKey : DEVPROPKEY* -> "pointer"
// Store : DEVPROPSTORE -> "i32"
// pszLocaleName : LPCWSTR -> "buffer"
// cProperties : DWORD -> "u32"
// pProperties : DEVPROPERTY* optional -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* DevFindProperty(
void* pKey,
int32_t Store,
const uint16_t* pszLocaleName,
uint32_t cProperties,
void* pProperties);
C, "api-ms-win-devices-query-l1-1-0.dll");
// $ffi->DevFindProperty(pKey, Store, pszLocaleName, cProperties, pProperties);
// pKey : DEVPROPKEY*
// Store : DEVPROPSTORE
// pszLocaleName : LPCWSTR
// cProperties : DWORD
// pProperties : DEVPROPERTY* optional
// 構造体/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 Api-ms-win-devices-query-l1-1-0 extends StdCallLibrary {
Api-ms-win-devices-query-l1-1-0 INSTANCE = Native.load("api-ms-win-devices-query-l1-1-0", Api-ms-win-devices-query-l1-1-0.class);
Pointer DevFindProperty(
Pointer pKey, // DEVPROPKEY*
int Store, // DEVPROPSTORE
WString pszLocaleName, // LPCWSTR
int cProperties, // DWORD
Pointer pProperties // DEVPROPERTY* optional
);
}@[Link("api-ms-win-devices-query-l1-1-0")]
lib Libapi-ms-win-devices-query-l1-1-0
fun DevFindProperty = DevFindProperty(
pKey : DEVPROPKEY*, # DEVPROPKEY*
Store : Int32, # DEVPROPSTORE
pszLocaleName : UInt16*, # LPCWSTR
cProperties : UInt32, # DWORD
pProperties : DEVPROPERTY* # DEVPROPERTY* optional
) : DEVPROPERTY*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef DevFindPropertyNative = Pointer<Void> Function(Pointer<Void>, Int32, Pointer<Utf16>, Uint32, Pointer<Void>);
typedef DevFindPropertyDart = Pointer<Void> Function(Pointer<Void>, int, Pointer<Utf16>, int, Pointer<Void>);
final DevFindProperty = DynamicLibrary.open('api-ms-win-devices-query-l1-1-0.dll')
.lookupFunction<DevFindPropertyNative, DevFindPropertyDart>('DevFindProperty');
// pKey : DEVPROPKEY* -> Pointer<Void>
// Store : DEVPROPSTORE -> Int32
// pszLocaleName : LPCWSTR -> Pointer<Utf16>
// cProperties : DWORD -> Uint32
// pProperties : DEVPROPERTY* optional -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "DevFindProperty"
c_DevFindProperty :: Ptr () -> Int32 -> CWString -> Word32 -> Ptr () -> IO (Ptr ())
-- pKey : DEVPROPKEY* -> Ptr ()
-- Store : DEVPROPSTORE -> Int32
-- pszLocaleName : LPCWSTR -> CWString
-- cProperties : DWORD -> Word32
-- pProperties : DEVPROPERTY* optional -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let devfindproperty =
foreign "DevFindProperty"
((ptr void) @-> int32_t @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning (ptr void))
(* pKey : DEVPROPKEY* -> (ptr void) *)
(* Store : DEVPROPSTORE -> int32_t *)
(* pszLocaleName : LPCWSTR -> (ptr uint16_t) *)
(* cProperties : DWORD -> uint32_t *)
(* pProperties : DEVPROPERTY* optional -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-devices-query-l1-1-0 (t "api-ms-win-devices-query-l1-1-0.dll"))
(cffi:use-foreign-library api-ms-win-devices-query-l1-1-0)
(cffi:defcfun ("DevFindProperty" dev-find-property :convention :stdcall) :pointer
(p-key :pointer) ; DEVPROPKEY*
(store :int32) ; DEVPROPSTORE
(psz-locale-name (:string :encoding :utf-16le)) ; LPCWSTR
(c-properties :uint32) ; DWORD
(p-properties :pointer)) ; DEVPROPERTY* optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $DevFindProperty = Win32::API::More->new('api-ms-win-devices-query-l1-1-0',
'LPVOID DevFindProperty(LPVOID pKey, int Store, LPCWSTR pszLocaleName, DWORD cProperties, LPVOID pProperties)');
# my $ret = $DevFindProperty->Call($pKey, $Store, $pszLocaleName, $cProperties, $pProperties);
# pKey : DEVPROPKEY* -> LPVOID
# Store : DEVPROPSTORE -> int
# pszLocaleName : LPCWSTR -> LPCWSTR
# cProperties : DWORD -> DWORD
# pProperties : DEVPROPERTY* optional -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。