Win32 API 日本語リファレンス
ホームStorage.Packaging.Appx › OpenPackageInfoByFullNameForUser

OpenPackageInfoByFullNameForUser

関数
指定ユーザー向けにフルネームからパッケージ情報参照を開く。
DLLapi-ms-win-appmodel-runtime-l1-1-1.dll呼出規約winapi

シグネチャ

// api-ms-win-appmodel-runtime-l1-1-1.dll
#include <windows.h>

WIN32_ERROR OpenPackageInfoByFullNameForUser(
    PSID userSid,   // optional
    LPCWSTR packageFullName,
    DWORD reserved,   // optional
    _PACKAGE_INFO_REFERENCE** packageInfoReference
);

パラメーター

名前方向
userSidPSIDinoptional
packageFullNameLPCWSTRin
reservedDWORDoptional
packageInfoReference_PACKAGE_INFO_REFERENCE**out

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

// api-ms-win-appmodel-runtime-l1-1-1.dll
#include <windows.h>

WIN32_ERROR OpenPackageInfoByFullNameForUser(
    PSID userSid,   // optional
    LPCWSTR packageFullName,
    DWORD reserved,   // optional
    _PACKAGE_INFO_REFERENCE** packageInfoReference
);
[DllImport("api-ms-win-appmodel-runtime-l1-1-1.dll", ExactSpelling = true)]
static extern uint OpenPackageInfoByFullNameForUser(
    IntPtr userSid,   // PSID optional
    [MarshalAs(UnmanagedType.LPWStr)] string packageFullName,   // LPCWSTR
    uint reserved,   // DWORD optional
    IntPtr packageInfoReference   // _PACKAGE_INFO_REFERENCE** out
);
<DllImport("api-ms-win-appmodel-runtime-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function OpenPackageInfoByFullNameForUser(
    userSid As IntPtr,   ' PSID optional
    <MarshalAs(UnmanagedType.LPWStr)> packageFullName As String,   ' LPCWSTR
    reserved As UInteger,   ' DWORD optional
    packageInfoReference As IntPtr   ' _PACKAGE_INFO_REFERENCE** out
) As UInteger
End Function
' userSid : PSID optional
' packageFullName : LPCWSTR
' reserved : DWORD optional
' packageInfoReference : _PACKAGE_INFO_REFERENCE** out
Declare PtrSafe Function OpenPackageInfoByFullNameForUser Lib "api-ms-win-appmodel-runtime-l1-1-1" ( _
    ByVal userSid As LongPtr, _
    ByVal packageFullName As LongPtr, _
    ByVal reserved As Long, _
    ByVal packageInfoReference As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

OpenPackageInfoByFullNameForUser = ctypes.windll.LoadLibrary("api-ms-win-appmodel-runtime-l1-1-1.dll").OpenPackageInfoByFullNameForUser
OpenPackageInfoByFullNameForUser.restype = wintypes.DWORD
OpenPackageInfoByFullNameForUser.argtypes = [
    wintypes.HANDLE,  # userSid : PSID optional
    wintypes.LPCWSTR,  # packageFullName : LPCWSTR
    wintypes.DWORD,  # reserved : DWORD optional
    ctypes.c_void_p,  # packageInfoReference : _PACKAGE_INFO_REFERENCE** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-appmodel-runtime-l1-1-1.dll')
OpenPackageInfoByFullNameForUser = Fiddle::Function.new(
  lib['OpenPackageInfoByFullNameForUser'],
  [
    Fiddle::TYPE_VOIDP,  # userSid : PSID optional
    Fiddle::TYPE_VOIDP,  # packageFullName : LPCWSTR
    -Fiddle::TYPE_INT,  # reserved : DWORD optional
    Fiddle::TYPE_VOIDP,  # packageInfoReference : _PACKAGE_INFO_REFERENCE** out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "api-ms-win-appmodel-runtime-l1-1-1")]
extern "system" {
    fn OpenPackageInfoByFullNameForUser(
        userSid: *mut core::ffi::c_void,  // PSID optional
        packageFullName: *const u16,  // LPCWSTR
        reserved: u32,  // DWORD optional
        packageInfoReference: *mut *mut _PACKAGE_INFO_REFERENCE  // _PACKAGE_INFO_REFERENCE** out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-appmodel-runtime-l1-1-1.dll")]
public static extern uint OpenPackageInfoByFullNameForUser(IntPtr userSid, [MarshalAs(UnmanagedType.LPWStr)] string packageFullName, uint reserved, IntPtr packageInfoReference);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-appmodel-runtime-l1-1-1_OpenPackageInfoByFullNameForUser' -Namespace Win32 -PassThru
# $api::OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll"
#func global OpenPackageInfoByFullNameForUser "OpenPackageInfoByFullNameForUser" sptr, sptr, sptr, sptr
; OpenPackageInfoByFullNameForUser userSid, packageFullName, reserved, varptr(packageInfoReference)   ; 戻り値は stat
; userSid : PSID optional -> "sptr"
; packageFullName : LPCWSTR -> "sptr"
; reserved : DWORD optional -> "sptr"
; packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll"
#cfunc global OpenPackageInfoByFullNameForUser "OpenPackageInfoByFullNameForUser" sptr, wstr, int, var
; res = OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
; userSid : PSID optional -> "sptr"
; packageFullName : LPCWSTR -> "wstr"
; reserved : DWORD optional -> "int"
; packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR OpenPackageInfoByFullNameForUser(PSID userSid, LPCWSTR packageFullName, DWORD reserved, _PACKAGE_INFO_REFERENCE** packageInfoReference)
#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll"
#cfunc global OpenPackageInfoByFullNameForUser "OpenPackageInfoByFullNameForUser" intptr, wstr, int, var
; res = OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
; userSid : PSID optional -> "intptr"
; packageFullName : LPCWSTR -> "wstr"
; reserved : DWORD optional -> "int"
; packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_appmodel_runtime_l1_1_1 = windows.NewLazySystemDLL("api-ms-win-appmodel-runtime-l1-1-1.dll")
	procOpenPackageInfoByFullNameForUser = api_ms_win_appmodel_runtime_l1_1_1.NewProc("OpenPackageInfoByFullNameForUser")
)

// userSid (PSID optional), packageFullName (LPCWSTR), reserved (DWORD optional), packageInfoReference (_PACKAGE_INFO_REFERENCE** out)
r1, _, err := procOpenPackageInfoByFullNameForUser.Call(
	uintptr(userSid),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(packageFullName))),
	uintptr(reserved),
	uintptr(packageInfoReference),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function OpenPackageInfoByFullNameForUser(
  userSid: THandle;   // PSID optional
  packageFullName: PWideChar;   // LPCWSTR
  reserved: DWORD;   // DWORD optional
  packageInfoReference: Pointer   // _PACKAGE_INFO_REFERENCE** out
): DWORD; stdcall;
  external 'api-ms-win-appmodel-runtime-l1-1-1.dll' name 'OpenPackageInfoByFullNameForUser';
result := DllCall("api-ms-win-appmodel-runtime-l1-1-1\OpenPackageInfoByFullNameForUser"
    , "Ptr", userSid   ; PSID optional
    , "WStr", packageFullName   ; LPCWSTR
    , "UInt", reserved   ; DWORD optional
    , "Ptr", packageInfoReference   ; _PACKAGE_INFO_REFERENCE** out
    , "UInt")   ; return: WIN32_ERROR
●OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference) = DLL("api-ms-win-appmodel-runtime-l1-1-1.dll", "dword OpenPackageInfoByFullNameForUser(void*, char*, dword, void*)")
# 呼び出し: OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
# userSid : PSID optional -> "void*"
# packageFullName : LPCWSTR -> "char*"
# reserved : DWORD optional -> "dword"
# packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。