Win32 API 日本語リファレンス
ホームUI.Shell.PropertiesSystem › PifMgr_OpenProperties

PifMgr_OpenProperties

関数
PIFファイルのプロパティを開いてハンドルを返す。
DLLSHELL32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHELL32.dll
#include <windows.h>

HANDLE PifMgr_OpenProperties(
    LPCWSTR pszApp,
    LPCWSTR pszPIF,   // optional
    DWORD hInf,
    DWORD flOpt
);

パラメーター

名前方向説明
pszAppLPCWSTRin対象アプリケーション(実行ファイル)のパスを表すワイド文字列。
pszPIFLPCWSTRinoptional関連付けるPIFファイルのパスを表すワイド文字列。NULL可。
hInfDWORDinINF情報を示すハンドル値。通常は0を指定する。
flOptDWORDinオープン動作を制御するオプションフラグ。OPENPROPS_NONEなどを指定する。

戻り値の型: HANDLE

各言語での呼び出し定義

// SHELL32.dll
#include <windows.h>

HANDLE PifMgr_OpenProperties(
    LPCWSTR pszApp,
    LPCWSTR pszPIF,   // optional
    DWORD hInf,
    DWORD flOpt
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern IntPtr PifMgr_OpenProperties(
    [MarshalAs(UnmanagedType.LPWStr)] string pszApp,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pszPIF,   // LPCWSTR optional
    uint hInf,   // DWORD
    uint flOpt   // DWORD
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function PifMgr_OpenProperties(
    <MarshalAs(UnmanagedType.LPWStr)> pszApp As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszPIF As String,   ' LPCWSTR optional
    hInf As UInteger,   ' DWORD
    flOpt As UInteger   ' DWORD
) As IntPtr
End Function
' pszApp : LPCWSTR
' pszPIF : LPCWSTR optional
' hInf : DWORD
' flOpt : DWORD
Declare PtrSafe Function PifMgr_OpenProperties Lib "shell32" ( _
    ByVal pszApp As LongPtr, _
    ByVal pszPIF As LongPtr, _
    ByVal hInf As Long, _
    ByVal flOpt As Long) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

PifMgr_OpenProperties = ctypes.windll.shell32.PifMgr_OpenProperties
PifMgr_OpenProperties.restype = ctypes.c_void_p
PifMgr_OpenProperties.argtypes = [
    wintypes.LPCWSTR,  # pszApp : LPCWSTR
    wintypes.LPCWSTR,  # pszPIF : LPCWSTR optional
    wintypes.DWORD,  # hInf : DWORD
    wintypes.DWORD,  # flOpt : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
PifMgr_OpenProperties = Fiddle::Function.new(
  lib['PifMgr_OpenProperties'],
  [
    Fiddle::TYPE_VOIDP,  # pszApp : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pszPIF : LPCWSTR optional
    -Fiddle::TYPE_INT,  # hInf : DWORD
    -Fiddle::TYPE_INT,  # flOpt : DWORD
  ],
  Fiddle::TYPE_VOIDP)
#[link(name = "shell32")]
extern "system" {
    fn PifMgr_OpenProperties(
        pszApp: *const u16,  // LPCWSTR
        pszPIF: *const u16,  // LPCWSTR optional
        hInf: u32,  // DWORD
        flOpt: u32  // DWORD
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern IntPtr PifMgr_OpenProperties([MarshalAs(UnmanagedType.LPWStr)] string pszApp, [MarshalAs(UnmanagedType.LPWStr)] string pszPIF, uint hInf, uint flOpt);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_PifMgr_OpenProperties' -Namespace Win32 -PassThru
# $api::PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
#uselib "SHELL32.dll"
#func global PifMgr_OpenProperties "PifMgr_OpenProperties" sptr, sptr, sptr, sptr
; PifMgr_OpenProperties pszApp, pszPIF, hInf, flOpt   ; 戻り値は stat
; pszApp : LPCWSTR -> "sptr"
; pszPIF : LPCWSTR optional -> "sptr"
; hInf : DWORD -> "sptr"
; flOpt : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global PifMgr_OpenProperties "PifMgr_OpenProperties" wstr, wstr, int, int
; res = PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
; pszApp : LPCWSTR -> "wstr"
; pszPIF : LPCWSTR optional -> "wstr"
; hInf : DWORD -> "int"
; flOpt : DWORD -> "int"
; HANDLE PifMgr_OpenProperties(LPCWSTR pszApp, LPCWSTR pszPIF, DWORD hInf, DWORD flOpt)
#uselib "SHELL32.dll"
#cfunc global PifMgr_OpenProperties "PifMgr_OpenProperties" wstr, wstr, int, int
; res = PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
; pszApp : LPCWSTR -> "wstr"
; pszPIF : LPCWSTR optional -> "wstr"
; hInf : DWORD -> "int"
; flOpt : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procPifMgr_OpenProperties = shell32.NewProc("PifMgr_OpenProperties")
)

// pszApp (LPCWSTR), pszPIF (LPCWSTR optional), hInf (DWORD), flOpt (DWORD)
r1, _, err := procPifMgr_OpenProperties.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszApp))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszPIF))),
	uintptr(hInf),
	uintptr(flOpt),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function PifMgr_OpenProperties(
  pszApp: PWideChar;   // LPCWSTR
  pszPIF: PWideChar;   // LPCWSTR optional
  hInf: DWORD;   // DWORD
  flOpt: DWORD   // DWORD
): THandle; stdcall;
  external 'SHELL32.dll' name 'PifMgr_OpenProperties';
result := DllCall("SHELL32\PifMgr_OpenProperties"
    , "WStr", pszApp   ; LPCWSTR
    , "WStr", pszPIF   ; LPCWSTR optional
    , "UInt", hInf   ; DWORD
    , "UInt", flOpt   ; DWORD
    , "Ptr")   ; return: HANDLE
●PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt) = DLL("SHELL32.dll", "void* PifMgr_OpenProperties(char*, char*, dword, dword)")
# 呼び出し: PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
# pszApp : LPCWSTR -> "char*"
# pszPIF : LPCWSTR optional -> "char*"
# hInf : DWORD -> "dword"
# flOpt : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "shell32" fn PifMgr_OpenProperties(
    pszApp: [*c]const u16, // LPCWSTR
    pszPIF: [*c]const u16, // LPCWSTR optional
    hInf: u32, // DWORD
    flOpt: u32 // DWORD
) callconv(std.os.windows.WINAPI) ?*anyopaque;
proc PifMgr_OpenProperties(
    pszApp: WideCString,  # LPCWSTR
    pszPIF: WideCString,  # LPCWSTR optional
    hInf: uint32,  # DWORD
    flOpt: uint32  # DWORD
): pointer {.importc: "PifMgr_OpenProperties", stdcall, dynlib: "SHELL32.dll".}
pragma(lib, "shell32");
extern(Windows)
void* PifMgr_OpenProperties(
    const(wchar)* pszApp,   // LPCWSTR
    const(wchar)* pszPIF,   // LPCWSTR optional
    uint hInf,   // DWORD
    uint flOpt   // DWORD
);
ccall((:PifMgr_OpenProperties, "SHELL32.dll"), stdcall, Ptr{Cvoid},
      (Cwstring, Cwstring, UInt32, UInt32),
      pszApp, pszPIF, hInf, flOpt)
# pszApp : LPCWSTR -> Cwstring
# pszPIF : LPCWSTR optional -> Cwstring
# hInf : DWORD -> UInt32
# flOpt : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
void* PifMgr_OpenProperties(
    const uint16_t* pszApp,
    const uint16_t* pszPIF,
    uint32_t hInf,
    uint32_t flOpt);
]]
local shell32 = ffi.load("shell32")
-- shell32.PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
-- pszApp : LPCWSTR
-- pszPIF : LPCWSTR optional
-- hInf : DWORD
-- flOpt : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const PifMgr_OpenProperties = lib.func('__stdcall', 'PifMgr_OpenProperties', 'void *', ['str16', 'str16', 'uint32_t', 'uint32_t']);
// PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
// pszApp : LPCWSTR -> 'str16'
// pszPIF : LPCWSTR optional -> 'str16'
// hInf : DWORD -> 'uint32_t'
// flOpt : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SHELL32.dll", {
  PifMgr_OpenProperties: { parameters: ["buffer", "buffer", "u32", "u32"], result: "pointer" },
});
// lib.symbols.PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt)
// pszApp : LPCWSTR -> "buffer"
// pszPIF : LPCWSTR optional -> "buffer"
// hInf : DWORD -> "u32"
// flOpt : DWORD -> "u32"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
void* PifMgr_OpenProperties(
    const uint16_t* pszApp,
    const uint16_t* pszPIF,
    uint32_t hInf,
    uint32_t flOpt);
C, "SHELL32.dll");
// $ffi->PifMgr_OpenProperties(pszApp, pszPIF, hInf, flOpt);
// pszApp : LPCWSTR
// pszPIF : LPCWSTR optional
// hInf : DWORD
// flOpt : DWORD
// 構造体/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);
    Pointer PifMgr_OpenProperties(
        WString pszApp,   // LPCWSTR
        WString pszPIF,   // LPCWSTR optional
        int hInf,   // DWORD
        int flOpt   // DWORD
    );
}
@[Link("shell32")]
lib LibSHELL32
  fun PifMgr_OpenProperties = PifMgr_OpenProperties(
    pszApp : UInt16*,   # LPCWSTR
    pszPIF : UInt16*,   # LPCWSTR optional
    hInf : UInt32,   # DWORD
    flOpt : UInt32   # DWORD
  ) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PifMgr_OpenPropertiesNative = Pointer<Void> Function(Pointer<Utf16>, Pointer<Utf16>, Uint32, Uint32);
typedef PifMgr_OpenPropertiesDart = Pointer<Void> Function(Pointer<Utf16>, Pointer<Utf16>, int, int);
final PifMgr_OpenProperties = DynamicLibrary.open('SHELL32.dll')
    .lookupFunction<PifMgr_OpenPropertiesNative, PifMgr_OpenPropertiesDart>('PifMgr_OpenProperties');
// pszApp : LPCWSTR -> Pointer<Utf16>
// pszPIF : LPCWSTR optional -> Pointer<Utf16>
// hInf : DWORD -> Uint32
// flOpt : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PifMgr_OpenProperties(
  pszApp: PWideChar;   // LPCWSTR
  pszPIF: PWideChar;   // LPCWSTR optional
  hInf: DWORD;   // DWORD
  flOpt: DWORD   // DWORD
): THandle; stdcall;
  external 'SHELL32.dll' name 'PifMgr_OpenProperties';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PifMgr_OpenProperties"
  c_PifMgr_OpenProperties :: CWString -> CWString -> Word32 -> Word32 -> IO (Ptr ())
-- pszApp : LPCWSTR -> CWString
-- pszPIF : LPCWSTR optional -> CWString
-- hInf : DWORD -> Word32
-- flOpt : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pifmgr_openproperties =
  foreign "PifMgr_OpenProperties"
    ((ptr uint16_t) @-> (ptr uint16_t) @-> uint32_t @-> uint32_t @-> returning (ptr void))
(* pszApp : LPCWSTR -> (ptr uint16_t) *)
(* pszPIF : LPCWSTR optional -> (ptr uint16_t) *)
(* hInf : DWORD -> uint32_t *)
(* flOpt : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)

(cffi:defcfun ("PifMgr_OpenProperties" pif-mgr-open-properties :convention :stdcall) :pointer
  (psz-app (:string :encoding :utf-16le))   ; LPCWSTR
  (psz-pif (:string :encoding :utf-16le))   ; LPCWSTR optional
  (h-inf :uint32)   ; DWORD
  (fl-opt :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PifMgr_OpenProperties = Win32::API::More->new('SHELL32',
    'HANDLE PifMgr_OpenProperties(LPCWSTR pszApp, LPCWSTR pszPIF, DWORD hInf, DWORD flOpt)');
# my $ret = $PifMgr_OpenProperties->Call($pszApp, $pszPIF, $hInf, $flOpt);
# pszApp : LPCWSTR -> LPCWSTR
# pszPIF : LPCWSTR optional -> LPCWSTR
# hInf : DWORD -> DWORD
# flOpt : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。