ホーム › Storage.Packaging.Appx › OpenPackageInfoByFullNameForUser
OpenPackageInfoByFullNameForUser
関数指定ユーザー向けにフルネームからパッケージ情報参照を開く。
シグネチャ
// 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
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| userSid | PSID | inoptional | 対象ユーザーのSID。NULLで現在のユーザーを指す。 |
| packageFullName | LPCWSTR | in | 情報参照を開く対象パッケージのフルネーム文字列。 |
| reserved | DWORD | optional | 予約済み。0を指定する。 |
| packageInfoReference | _PACKAGE_INFO_REFERENCE** | out | 開かれたパッケージ情報参照ハンドルを受け取る出力ポインタ。ClosePackageInfoで解放する。 |
戻り値の型: 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 方式にも切替可。#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll" #cfunc global OpenPackageInfoByFullNameForUser "OpenPackageInfoByFullNameForUser" sptr, wstr, int, sptr ; res = OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, varptr(packageInfoReference)) ; userSid : PSID optional -> "sptr" ; packageFullName : LPCWSTR -> "wstr" ; reserved : DWORD optional -> "int" ; packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは 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 方式にも切替可。; 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, intptr ; res = OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, varptr(packageInfoReference)) ; userSid : PSID optional -> "intptr" ; packageFullName : LPCWSTR -> "wstr" ; reserved : DWORD optional -> "int" ; packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは 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_ERRORfunction 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)。const std = @import("std");
extern "api-ms-win-appmodel-runtime-l1-1-1" fn OpenPackageInfoByFullNameForUser(
userSid: ?*anyopaque, // PSID optional
packageFullName: [*c]const u16, // LPCWSTR
reserved: u32, // DWORD optional
packageInfoReference: [*c][*c]_PACKAGE_INFO_REFERENCE // _PACKAGE_INFO_REFERENCE** out
) callconv(std.os.windows.WINAPI) u32;proc OpenPackageInfoByFullNameForUser(
userSid: pointer, # PSID optional
packageFullName: WideCString, # LPCWSTR
reserved: uint32, # DWORD optional
packageInfoReference: ptr _PACKAGE_INFO_REFERENCE # _PACKAGE_INFO_REFERENCE** out
): uint32 {.importc: "OpenPackageInfoByFullNameForUser", stdcall, dynlib: "api-ms-win-appmodel-runtime-l1-1-1.dll".}pragma(lib, "api-ms-win-appmodel-runtime-l1-1-1");
extern(Windows)
uint OpenPackageInfoByFullNameForUser(
void* userSid, // PSID optional
const(wchar)* packageFullName, // LPCWSTR
uint reserved, // DWORD optional
_PACKAGE_INFO_REFERENCE** packageInfoReference // _PACKAGE_INFO_REFERENCE** out
);ccall((:OpenPackageInfoByFullNameForUser, "api-ms-win-appmodel-runtime-l1-1-1.dll"), stdcall, UInt32,
(Ptr{Cvoid}, Cwstring, UInt32, Ptr{_PACKAGE_INFO_REFERENCE}),
userSid, packageFullName, reserved, packageInfoReference)
# userSid : PSID optional -> Ptr{Cvoid}
# packageFullName : LPCWSTR -> Cwstring
# reserved : DWORD optional -> UInt32
# packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> Ptr{_PACKAGE_INFO_REFERENCE}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
uint32_t OpenPackageInfoByFullNameForUser(
void* userSid,
const uint16_t* packageFullName,
uint32_t reserved,
void* packageInfoReference);
]]
local api-ms-win-appmodel-runtime-l1-1-1 = ffi.load("api-ms-win-appmodel-runtime-l1-1-1")
-- api-ms-win-appmodel-runtime-l1-1-1.OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
-- userSid : PSID optional
-- packageFullName : LPCWSTR
-- reserved : DWORD optional
-- packageInfoReference : _PACKAGE_INFO_REFERENCE** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('api-ms-win-appmodel-runtime-l1-1-1.dll');
const OpenPackageInfoByFullNameForUser = lib.func('__stdcall', 'OpenPackageInfoByFullNameForUser', 'uint32_t', ['void *', 'str16', 'uint32_t', 'void *']);
// OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
// userSid : PSID optional -> 'void *'
// packageFullName : LPCWSTR -> 'str16'
// reserved : DWORD optional -> 'uint32_t'
// packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("api-ms-win-appmodel-runtime-l1-1-1.dll", {
OpenPackageInfoByFullNameForUser: { parameters: ["pointer", "buffer", "u32", "pointer"], result: "u32" },
});
// lib.symbols.OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference)
// userSid : PSID optional -> "pointer"
// packageFullName : LPCWSTR -> "buffer"
// reserved : DWORD optional -> "u32"
// packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
uint32_t OpenPackageInfoByFullNameForUser(
void* userSid,
const uint16_t* packageFullName,
uint32_t reserved,
void* packageInfoReference);
C, "api-ms-win-appmodel-runtime-l1-1-1.dll");
// $ffi->OpenPackageInfoByFullNameForUser(userSid, packageFullName, reserved, packageInfoReference);
// userSid : PSID optional
// packageFullName : LPCWSTR
// reserved : DWORD optional
// packageInfoReference : _PACKAGE_INFO_REFERENCE** 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 Api-ms-win-appmodel-runtime-l1-1-1 extends StdCallLibrary {
Api-ms-win-appmodel-runtime-l1-1-1 INSTANCE = Native.load("api-ms-win-appmodel-runtime-l1-1-1", Api-ms-win-appmodel-runtime-l1-1-1.class);
int OpenPackageInfoByFullNameForUser(
Pointer userSid, // PSID optional
WString packageFullName, // LPCWSTR
int reserved, // DWORD optional
Pointer packageInfoReference // _PACKAGE_INFO_REFERENCE** out
);
}@[Link("api-ms-win-appmodel-runtime-l1-1-1")]
lib Libapi-ms-win-appmodel-runtime-l1-1-1
fun OpenPackageInfoByFullNameForUser = OpenPackageInfoByFullNameForUser(
userSid : Void*, # PSID optional
packageFullName : UInt16*, # LPCWSTR
reserved : UInt32, # DWORD optional
packageInfoReference : _PACKAGE_INFO_REFERENCE** # _PACKAGE_INFO_REFERENCE** out
) : UInt32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef OpenPackageInfoByFullNameForUserNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Pointer<Void>);
typedef OpenPackageInfoByFullNameForUserDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Void>);
final OpenPackageInfoByFullNameForUser = DynamicLibrary.open('api-ms-win-appmodel-runtime-l1-1-1.dll')
.lookupFunction<OpenPackageInfoByFullNameForUserNative, OpenPackageInfoByFullNameForUserDart>('OpenPackageInfoByFullNameForUser');
// userSid : PSID optional -> Pointer<Void>
// packageFullName : LPCWSTR -> Pointer<Utf16>
// reserved : DWORD optional -> Uint32
// packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
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';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OpenPackageInfoByFullNameForUser"
c_OpenPackageInfoByFullNameForUser :: Ptr () -> CWString -> Word32 -> Ptr () -> IO Word32
-- userSid : PSID optional -> Ptr ()
-- packageFullName : LPCWSTR -> CWString
-- reserved : DWORD optional -> Word32
-- packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let openpackageinfobyfullnameforuser =
foreign "OpenPackageInfoByFullNameForUser"
((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* userSid : PSID optional -> (ptr void) *)
(* packageFullName : LPCWSTR -> (ptr uint16_t) *)
(* reserved : DWORD optional -> uint32_t *)
(* packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library api-ms-win-appmodel-runtime-l1-1-1 (t "api-ms-win-appmodel-runtime-l1-1-1.dll"))
(cffi:use-foreign-library api-ms-win-appmodel-runtime-l1-1-1)
(cffi:defcfun ("OpenPackageInfoByFullNameForUser" open-package-info-by-full-name-for-user :convention :stdcall) :uint32
(user-sid :pointer) ; PSID optional
(package-full-name (:string :encoding :utf-16le)) ; LPCWSTR
(reserved :uint32) ; DWORD optional
(package-info-reference :pointer)) ; _PACKAGE_INFO_REFERENCE** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $OpenPackageInfoByFullNameForUser = Win32::API::More->new('api-ms-win-appmodel-runtime-l1-1-1',
'DWORD OpenPackageInfoByFullNameForUser(HANDLE userSid, LPCWSTR packageFullName, DWORD reserved, LPVOID packageInfoReference)');
# my $ret = $OpenPackageInfoByFullNameForUser->Call($userSid, $packageFullName, $reserved, $packageInfoReference);
# userSid : PSID optional -> HANDLE
# packageFullName : LPCWSTR -> LPCWSTR
# reserved : DWORD optional -> DWORD
# packageInfoReference : _PACKAGE_INFO_REFERENCE** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。