ホーム › Networking.Clustering › ResUtilFindLongProperty
ResUtilFindLongProperty
関数プロパティリストからLONGプロパティを名前で検索する。
シグネチャ
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilFindLongProperty(
const void* pPropertyList,
DWORD cbPropertyListSize,
LPCWSTR pszPropertyName,
INT* plPropertyValue
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pPropertyList | void* | in | 検索対象のプロパティリストバッファーへのポインター。 |
| cbPropertyListSize | DWORD | in | プロパティリストの総バイト数。 |
| pszPropertyName | LPCWSTR | in | 検索するLONG(符号付き32ビット)プロパティの名前。 |
| plPropertyValue | INT* | out | 見つかったLONG値を受け取る変数へのポインター。 |
戻り値の型: DWORD
各言語での呼び出し定義
// RESUTILS.dll
#include <windows.h>
DWORD ResUtilFindLongProperty(
const void* pPropertyList,
DWORD cbPropertyListSize,
LPCWSTR pszPropertyName,
INT* plPropertyValue
);[DllImport("RESUTILS.dll", ExactSpelling = true)]
static extern uint ResUtilFindLongProperty(
IntPtr pPropertyList, // void*
uint cbPropertyListSize, // DWORD
[MarshalAs(UnmanagedType.LPWStr)] string pszPropertyName, // LPCWSTR
out int plPropertyValue // INT* out
);<DllImport("RESUTILS.dll", ExactSpelling:=True)>
Public Shared Function ResUtilFindLongProperty(
pPropertyList As IntPtr, ' void*
cbPropertyListSize As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPWStr)> pszPropertyName As String, ' LPCWSTR
<Out> ByRef plPropertyValue As Integer ' INT* out
) As UInteger
End Function' pPropertyList : void*
' cbPropertyListSize : DWORD
' pszPropertyName : LPCWSTR
' plPropertyValue : INT* out
Declare PtrSafe Function ResUtilFindLongProperty Lib "resutils" ( _
ByVal pPropertyList As LongPtr, _
ByVal cbPropertyListSize As Long, _
ByVal pszPropertyName As LongPtr, _
ByRef plPropertyValue As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
ResUtilFindLongProperty = ctypes.windll.resutils.ResUtilFindLongProperty
ResUtilFindLongProperty.restype = wintypes.DWORD
ResUtilFindLongProperty.argtypes = [
ctypes.POINTER(None), # pPropertyList : void*
wintypes.DWORD, # cbPropertyListSize : DWORD
wintypes.LPCWSTR, # pszPropertyName : LPCWSTR
ctypes.POINTER(ctypes.c_int), # plPropertyValue : INT* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RESUTILS.dll')
ResUtilFindLongProperty = Fiddle::Function.new(
lib['ResUtilFindLongProperty'],
[
Fiddle::TYPE_VOIDP, # pPropertyList : void*
-Fiddle::TYPE_INT, # cbPropertyListSize : DWORD
Fiddle::TYPE_VOIDP, # pszPropertyName : LPCWSTR
Fiddle::TYPE_VOIDP, # plPropertyValue : INT* out
],
-Fiddle::TYPE_INT)#[link(name = "resutils")]
extern "system" {
fn ResUtilFindLongProperty(
pPropertyList: *const (), // void*
cbPropertyListSize: u32, // DWORD
pszPropertyName: *const u16, // LPCWSTR
plPropertyValue: *mut i32 // INT* out
) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RESUTILS.dll")]
public static extern uint ResUtilFindLongProperty(IntPtr pPropertyList, uint cbPropertyListSize, [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyName, out int plPropertyValue);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RESUTILS_ResUtilFindLongProperty' -Namespace Win32 -PassThru
# $api::ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue)#uselib "RESUTILS.dll"
#func global ResUtilFindLongProperty "ResUtilFindLongProperty" sptr, sptr, sptr, sptr
; ResUtilFindLongProperty pPropertyList, cbPropertyListSize, pszPropertyName, varptr(plPropertyValue) ; 戻り値は stat
; pPropertyList : void* -> "sptr"
; cbPropertyListSize : DWORD -> "sptr"
; pszPropertyName : LPCWSTR -> "sptr"
; plPropertyValue : INT* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RESUTILS.dll" #cfunc global ResUtilFindLongProperty "ResUtilFindLongProperty" sptr, int, wstr, var ; res = ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue) ; pPropertyList : void* -> "sptr" ; cbPropertyListSize : DWORD -> "int" ; pszPropertyName : LPCWSTR -> "wstr" ; plPropertyValue : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RESUTILS.dll" #cfunc global ResUtilFindLongProperty "ResUtilFindLongProperty" sptr, int, wstr, sptr ; res = ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, varptr(plPropertyValue)) ; pPropertyList : void* -> "sptr" ; cbPropertyListSize : DWORD -> "int" ; pszPropertyName : LPCWSTR -> "wstr" ; plPropertyValue : INT* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; DWORD ResUtilFindLongProperty(void* pPropertyList, DWORD cbPropertyListSize, LPCWSTR pszPropertyName, INT* plPropertyValue) #uselib "RESUTILS.dll" #cfunc global ResUtilFindLongProperty "ResUtilFindLongProperty" intptr, int, wstr, var ; res = ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue) ; pPropertyList : void* -> "intptr" ; cbPropertyListSize : DWORD -> "int" ; pszPropertyName : LPCWSTR -> "wstr" ; plPropertyValue : INT* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; DWORD ResUtilFindLongProperty(void* pPropertyList, DWORD cbPropertyListSize, LPCWSTR pszPropertyName, INT* plPropertyValue) #uselib "RESUTILS.dll" #cfunc global ResUtilFindLongProperty "ResUtilFindLongProperty" intptr, int, wstr, intptr ; res = ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, varptr(plPropertyValue)) ; pPropertyList : void* -> "intptr" ; cbPropertyListSize : DWORD -> "int" ; pszPropertyName : LPCWSTR -> "wstr" ; plPropertyValue : INT* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
resutils = windows.NewLazySystemDLL("RESUTILS.dll")
procResUtilFindLongProperty = resutils.NewProc("ResUtilFindLongProperty")
)
// pPropertyList (void*), cbPropertyListSize (DWORD), pszPropertyName (LPCWSTR), plPropertyValue (INT* out)
r1, _, err := procResUtilFindLongProperty.Call(
uintptr(pPropertyList),
uintptr(cbPropertyListSize),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPropertyName))),
uintptr(plPropertyValue),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // DWORDfunction ResUtilFindLongProperty(
pPropertyList: Pointer; // void*
cbPropertyListSize: DWORD; // DWORD
pszPropertyName: PWideChar; // LPCWSTR
plPropertyValue: Pointer // INT* out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilFindLongProperty';result := DllCall("RESUTILS\ResUtilFindLongProperty"
, "Ptr", pPropertyList ; void*
, "UInt", cbPropertyListSize ; DWORD
, "WStr", pszPropertyName ; LPCWSTR
, "Ptr", plPropertyValue ; INT* out
, "UInt") ; return: DWORD●ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue) = DLL("RESUTILS.dll", "dword ResUtilFindLongProperty(void*, dword, char*, void*)")
# 呼び出し: ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue)
# pPropertyList : void* -> "void*"
# cbPropertyListSize : DWORD -> "dword"
# pszPropertyName : LPCWSTR -> "char*"
# plPropertyValue : INT* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "resutils" fn ResUtilFindLongProperty(
pPropertyList: ?*anyopaque, // void*
cbPropertyListSize: u32, // DWORD
pszPropertyName: [*c]const u16, // LPCWSTR
plPropertyValue: [*c]i32 // INT* out
) callconv(std.os.windows.WINAPI) u32;proc ResUtilFindLongProperty(
pPropertyList: pointer, # void*
cbPropertyListSize: uint32, # DWORD
pszPropertyName: WideCString, # LPCWSTR
plPropertyValue: ptr int32 # INT* out
): uint32 {.importc: "ResUtilFindLongProperty", stdcall, dynlib: "RESUTILS.dll".}pragma(lib, "resutils");
extern(Windows)
uint ResUtilFindLongProperty(
void* pPropertyList, // void*
uint cbPropertyListSize, // DWORD
const(wchar)* pszPropertyName, // LPCWSTR
int* plPropertyValue // INT* out
);ccall((:ResUtilFindLongProperty, "RESUTILS.dll"), stdcall, UInt32,
(Ptr{Cvoid}, UInt32, Cwstring, Ptr{Int32}),
pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue)
# pPropertyList : void* -> Ptr{Cvoid}
# cbPropertyListSize : DWORD -> UInt32
# pszPropertyName : LPCWSTR -> Cwstring
# plPropertyValue : INT* out -> Ptr{Int32}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t ResUtilFindLongProperty(
void* pPropertyList,
uint32_t cbPropertyListSize,
const uint16_t* pszPropertyName,
int32_t* plPropertyValue);
]]
local resutils = ffi.load("resutils")
-- resutils.ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue)
-- pPropertyList : void*
-- cbPropertyListSize : DWORD
-- pszPropertyName : LPCWSTR
-- plPropertyValue : INT* out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RESUTILS.dll');
const ResUtilFindLongProperty = lib.func('__stdcall', 'ResUtilFindLongProperty', 'uint32_t', ['void *', 'uint32_t', 'str16', 'int32_t *']);
// ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue)
// pPropertyList : void* -> 'void *'
// cbPropertyListSize : DWORD -> 'uint32_t'
// pszPropertyName : LPCWSTR -> 'str16'
// plPropertyValue : INT* out -> 'int32_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RESUTILS.dll", {
ResUtilFindLongProperty: { parameters: ["pointer", "u32", "buffer", "pointer"], result: "u32" },
});
// lib.symbols.ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue)
// pPropertyList : void* -> "pointer"
// cbPropertyListSize : DWORD -> "u32"
// pszPropertyName : LPCWSTR -> "buffer"
// plPropertyValue : INT* out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t ResUtilFindLongProperty(
void* pPropertyList,
uint32_t cbPropertyListSize,
const uint16_t* pszPropertyName,
int32_t* plPropertyValue);
C, "RESUTILS.dll");
// $ffi->ResUtilFindLongProperty(pPropertyList, cbPropertyListSize, pszPropertyName, plPropertyValue);
// pPropertyList : void*
// cbPropertyListSize : DWORD
// pszPropertyName : LPCWSTR
// plPropertyValue : INT* 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 Resutils extends StdCallLibrary {
Resutils INSTANCE = Native.load("resutils", Resutils.class);
int ResUtilFindLongProperty(
Pointer pPropertyList, // void*
int cbPropertyListSize, // DWORD
WString pszPropertyName, // LPCWSTR
IntByReference plPropertyValue // INT* out
);
}@[Link("resutils")]
lib LibRESUTILS
fun ResUtilFindLongProperty = ResUtilFindLongProperty(
pPropertyList : Void*, # void*
cbPropertyListSize : UInt32, # DWORD
pszPropertyName : UInt16*, # LPCWSTR
plPropertyValue : Int32* # INT* out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef ResUtilFindLongPropertyNative = Uint32 Function(Pointer<Void>, Uint32, Pointer<Utf16>, Pointer<Int32>);
typedef ResUtilFindLongPropertyDart = int Function(Pointer<Void>, int, Pointer<Utf16>, Pointer<Int32>);
final ResUtilFindLongProperty = DynamicLibrary.open('RESUTILS.dll')
.lookupFunction<ResUtilFindLongPropertyNative, ResUtilFindLongPropertyDart>('ResUtilFindLongProperty');
// pPropertyList : void* -> Pointer<Void>
// cbPropertyListSize : DWORD -> Uint32
// pszPropertyName : LPCWSTR -> Pointer<Utf16>
// plPropertyValue : INT* out -> Pointer<Int32>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function ResUtilFindLongProperty(
pPropertyList: Pointer; // void*
cbPropertyListSize: DWORD; // DWORD
pszPropertyName: PWideChar; // LPCWSTR
plPropertyValue: Pointer // INT* out
): DWORD; stdcall;
external 'RESUTILS.dll' name 'ResUtilFindLongProperty';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "ResUtilFindLongProperty"
c_ResUtilFindLongProperty :: Ptr () -> Word32 -> CWString -> Ptr Int32 -> IO Word32
-- pPropertyList : void* -> Ptr ()
-- cbPropertyListSize : DWORD -> Word32
-- pszPropertyName : LPCWSTR -> CWString
-- plPropertyValue : INT* out -> Ptr Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let resutilfindlongproperty =
foreign "ResUtilFindLongProperty"
((ptr void) @-> uint32_t @-> (ptr uint16_t) @-> (ptr int32_t) @-> returning uint32_t)
(* pPropertyList : void* -> (ptr void) *)
(* cbPropertyListSize : DWORD -> uint32_t *)
(* pszPropertyName : LPCWSTR -> (ptr uint16_t) *)
(* plPropertyValue : INT* out -> (ptr int32_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library resutils (t "RESUTILS.dll"))
(cffi:use-foreign-library resutils)
(cffi:defcfun ("ResUtilFindLongProperty" res-util-find-long-property :convention :stdcall) :uint32
(p-property-list :pointer) ; void*
(cb-property-list-size :uint32) ; DWORD
(psz-property-name (:string :encoding :utf-16le)) ; LPCWSTR
(pl-property-value :pointer)) ; INT* out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $ResUtilFindLongProperty = Win32::API::More->new('RESUTILS',
'DWORD ResUtilFindLongProperty(LPVOID pPropertyList, DWORD cbPropertyListSize, LPCWSTR pszPropertyName, LPVOID plPropertyValue)');
# my $ret = $ResUtilFindLongProperty->Call($pPropertyList, $cbPropertyListSize, $pszPropertyName, $plPropertyValue);
# pPropertyList : void* -> LPVOID
# cbPropertyListSize : DWORD -> DWORD
# pszPropertyName : LPCWSTR -> LPCWSTR
# plPropertyValue : INT* out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。