ホーム › Storage.Packaging.Appx › GetApplicationUserModelIdFromToken
GetApplicationUserModelIdFromToken
関数トークンからアプリケーションユーザーモデルIDを取得する。
シグネチャ
// api-ms-win-appmodel-runtime-l1-1-1.dll
#include <windows.h>
WIN32_ERROR GetApplicationUserModelIdFromToken(
HANDLE token,
DWORD* applicationUserModelIdLength,
LPWSTR applicationUserModelId // optional
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| token | HANDLE | in |
| applicationUserModelIdLength | DWORD* | inout |
| applicationUserModelId | LPWSTR | outoptional |
戻り値の型: WIN32_ERROR
各言語での呼び出し定義
// api-ms-win-appmodel-runtime-l1-1-1.dll
#include <windows.h>
WIN32_ERROR GetApplicationUserModelIdFromToken(
HANDLE token,
DWORD* applicationUserModelIdLength,
LPWSTR applicationUserModelId // optional
);[DllImport("api-ms-win-appmodel-runtime-l1-1-1.dll", ExactSpelling = true)]
static extern uint GetApplicationUserModelIdFromToken(
IntPtr token, // HANDLE
ref uint applicationUserModelIdLength, // DWORD* in/out
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder applicationUserModelId // LPWSTR optional, out
);<DllImport("api-ms-win-appmodel-runtime-l1-1-1.dll", ExactSpelling:=True)>
Public Shared Function GetApplicationUserModelIdFromToken(
token As IntPtr, ' HANDLE
ByRef applicationUserModelIdLength As UInteger, ' DWORD* in/out
<MarshalAs(UnmanagedType.LPWStr)> applicationUserModelId As System.Text.StringBuilder ' LPWSTR optional, out
) As UInteger
End Function' token : HANDLE
' applicationUserModelIdLength : DWORD* in/out
' applicationUserModelId : LPWSTR optional, out
Declare PtrSafe Function GetApplicationUserModelIdFromToken Lib "api-ms-win-appmodel-runtime-l1-1-1" ( _
ByVal token As LongPtr, _
ByRef applicationUserModelIdLength As Long, _
ByVal applicationUserModelId As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetApplicationUserModelIdFromToken = ctypes.windll.LoadLibrary("api-ms-win-appmodel-runtime-l1-1-1.dll").GetApplicationUserModelIdFromToken
GetApplicationUserModelIdFromToken.restype = wintypes.DWORD
GetApplicationUserModelIdFromToken.argtypes = [
wintypes.HANDLE, # token : HANDLE
ctypes.POINTER(wintypes.DWORD), # applicationUserModelIdLength : DWORD* in/out
wintypes.LPWSTR, # applicationUserModelId : LPWSTR optional, out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('api-ms-win-appmodel-runtime-l1-1-1.dll')
GetApplicationUserModelIdFromToken = Fiddle::Function.new(
lib['GetApplicationUserModelIdFromToken'],
[
Fiddle::TYPE_VOIDP, # token : HANDLE
Fiddle::TYPE_VOIDP, # applicationUserModelIdLength : DWORD* in/out
Fiddle::TYPE_VOIDP, # applicationUserModelId : LPWSTR optional, out
],
-Fiddle::TYPE_INT)#[link(name = "api-ms-win-appmodel-runtime-l1-1-1")]
extern "system" {
fn GetApplicationUserModelIdFromToken(
token: *mut core::ffi::c_void, // HANDLE
applicationUserModelIdLength: *mut u32, // DWORD* in/out
applicationUserModelId: *mut u16 // LPWSTR optional, 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 GetApplicationUserModelIdFromToken(IntPtr token, ref uint applicationUserModelIdLength, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder applicationUserModelId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-appmodel-runtime-l1-1-1_GetApplicationUserModelIdFromToken' -Namespace Win32 -PassThru
# $api::GetApplicationUserModelIdFromToken(token, applicationUserModelIdLength, applicationUserModelId)#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll"
#func global GetApplicationUserModelIdFromToken "GetApplicationUserModelIdFromToken" sptr, sptr, sptr
; GetApplicationUserModelIdFromToken token, varptr(applicationUserModelIdLength), varptr(applicationUserModelId) ; 戻り値は stat
; token : HANDLE -> "sptr"
; applicationUserModelIdLength : DWORD* in/out -> "sptr"
; applicationUserModelId : LPWSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll" #cfunc global GetApplicationUserModelIdFromToken "GetApplicationUserModelIdFromToken" sptr, var, var ; res = GetApplicationUserModelIdFromToken(token, applicationUserModelIdLength, applicationUserModelId) ; token : HANDLE -> "sptr" ; applicationUserModelIdLength : DWORD* in/out -> "var" ; applicationUserModelId : LPWSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "api-ms-win-appmodel-runtime-l1-1-1.dll" #cfunc global GetApplicationUserModelIdFromToken "GetApplicationUserModelIdFromToken" sptr, sptr, sptr ; res = GetApplicationUserModelIdFromToken(token, varptr(applicationUserModelIdLength), varptr(applicationUserModelId)) ; token : HANDLE -> "sptr" ; applicationUserModelIdLength : DWORD* in/out -> "sptr" ; applicationUserModelId : LPWSTR optional, out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; WIN32_ERROR GetApplicationUserModelIdFromToken(HANDLE token, DWORD* applicationUserModelIdLength, LPWSTR applicationUserModelId) #uselib "api-ms-win-appmodel-runtime-l1-1-1.dll" #cfunc global GetApplicationUserModelIdFromToken "GetApplicationUserModelIdFromToken" intptr, var, var ; res = GetApplicationUserModelIdFromToken(token, applicationUserModelIdLength, applicationUserModelId) ; token : HANDLE -> "intptr" ; applicationUserModelIdLength : DWORD* in/out -> "var" ; applicationUserModelId : LPWSTR optional, out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; WIN32_ERROR GetApplicationUserModelIdFromToken(HANDLE token, DWORD* applicationUserModelIdLength, LPWSTR applicationUserModelId) #uselib "api-ms-win-appmodel-runtime-l1-1-1.dll" #cfunc global GetApplicationUserModelIdFromToken "GetApplicationUserModelIdFromToken" intptr, intptr, intptr ; res = GetApplicationUserModelIdFromToken(token, varptr(applicationUserModelIdLength), varptr(applicationUserModelId)) ; token : HANDLE -> "intptr" ; applicationUserModelIdLength : DWORD* in/out -> "intptr" ; applicationUserModelId : LPWSTR optional, 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")
procGetApplicationUserModelIdFromToken = api_ms_win_appmodel_runtime_l1_1_1.NewProc("GetApplicationUserModelIdFromToken")
)
// token (HANDLE), applicationUserModelIdLength (DWORD* in/out), applicationUserModelId (LPWSTR optional, out)
r1, _, err := procGetApplicationUserModelIdFromToken.Call(
uintptr(token),
uintptr(applicationUserModelIdLength),
uintptr(applicationUserModelId),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // WIN32_ERRORfunction GetApplicationUserModelIdFromToken(
token: THandle; // HANDLE
applicationUserModelIdLength: Pointer; // DWORD* in/out
applicationUserModelId: PWideChar // LPWSTR optional, out
): DWORD; stdcall;
external 'api-ms-win-appmodel-runtime-l1-1-1.dll' name 'GetApplicationUserModelIdFromToken';result := DllCall("api-ms-win-appmodel-runtime-l1-1-1\GetApplicationUserModelIdFromToken"
, "Ptr", token ; HANDLE
, "Ptr", applicationUserModelIdLength ; DWORD* in/out
, "Ptr", applicationUserModelId ; LPWSTR optional, out
, "UInt") ; return: WIN32_ERROR●GetApplicationUserModelIdFromToken(token, applicationUserModelIdLength, applicationUserModelId) = DLL("api-ms-win-appmodel-runtime-l1-1-1.dll", "dword GetApplicationUserModelIdFromToken(void*, void*, char*)")
# 呼び出し: GetApplicationUserModelIdFromToken(token, applicationUserModelIdLength, applicationUserModelId)
# token : HANDLE -> "void*"
# applicationUserModelIdLength : DWORD* in/out -> "void*"
# applicationUserModelId : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。