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