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

GetApplicationUserModelId

関数
指定プロセスのアプリケーションユーザーモデルIDを取得する。
DLLKERNEL32.dll呼出規約winapi

シグネチャ

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

WIN32_ERROR GetApplicationUserModelId(
    HANDLE hProcess,
    DWORD* applicationUserModelIdLength,
    LPWSTR applicationUserModelId   // optional
);

パラメーター

名前方向
hProcessHANDLEin
applicationUserModelIdLengthDWORD*inout
applicationUserModelIdLPWSTRoutoptional

戻り値の型: WIN32_ERROR

各言語での呼び出し定義

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

WIN32_ERROR GetApplicationUserModelId(
    HANDLE hProcess,
    DWORD* applicationUserModelIdLength,
    LPWSTR applicationUserModelId   // optional
);
[DllImport("KERNEL32.dll", ExactSpelling = true)]
static extern uint GetApplicationUserModelId(
    IntPtr hProcess,   // HANDLE
    ref uint applicationUserModelIdLength,   // DWORD* in/out
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder applicationUserModelId   // LPWSTR optional, out
);
<DllImport("KERNEL32.dll", ExactSpelling:=True)>
Public Shared Function GetApplicationUserModelId(
    hProcess 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
' hProcess : HANDLE
' applicationUserModelIdLength : DWORD* in/out
' applicationUserModelId : LPWSTR optional, out
Declare PtrSafe Function GetApplicationUserModelId Lib "kernel32" ( _
    ByVal hProcess 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

GetApplicationUserModelId = ctypes.windll.kernel32.GetApplicationUserModelId
GetApplicationUserModelId.restype = wintypes.DWORD
GetApplicationUserModelId.argtypes = [
    wintypes.HANDLE,  # hProcess : HANDLE
    ctypes.POINTER(wintypes.DWORD),  # applicationUserModelIdLength : DWORD* in/out
    wintypes.LPWSTR,  # applicationUserModelId : LPWSTR optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetApplicationUserModelId = Fiddle::Function.new(
  lib['GetApplicationUserModelId'],
  [
    Fiddle::TYPE_VOIDP,  # hProcess : HANDLE
    Fiddle::TYPE_VOIDP,  # applicationUserModelIdLength : DWORD* in/out
    Fiddle::TYPE_VOIDP,  # applicationUserModelId : LPWSTR optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetApplicationUserModelId(
        hProcess: *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("KERNEL32.dll")]
public static extern uint GetApplicationUserModelId(IntPtr hProcess, ref uint applicationUserModelIdLength, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder applicationUserModelId);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetApplicationUserModelId' -Namespace Win32 -PassThru
# $api::GetApplicationUserModelId(hProcess, applicationUserModelIdLength, applicationUserModelId)
#uselib "KERNEL32.dll"
#func global GetApplicationUserModelId "GetApplicationUserModelId" sptr, sptr, sptr
; GetApplicationUserModelId hProcess, varptr(applicationUserModelIdLength), varptr(applicationUserModelId)   ; 戻り値は stat
; hProcess : HANDLE -> "sptr"
; applicationUserModelIdLength : DWORD* in/out -> "sptr"
; applicationUserModelId : LPWSTR optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global GetApplicationUserModelId "GetApplicationUserModelId" sptr, var, var
; res = GetApplicationUserModelId(hProcess, applicationUserModelIdLength, applicationUserModelId)
; hProcess : HANDLE -> "sptr"
; applicationUserModelIdLength : DWORD* in/out -> "var"
; applicationUserModelId : LPWSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; WIN32_ERROR GetApplicationUserModelId(HANDLE hProcess, DWORD* applicationUserModelIdLength, LPWSTR applicationUserModelId)
#uselib "KERNEL32.dll"
#cfunc global GetApplicationUserModelId "GetApplicationUserModelId" intptr, var, var
; res = GetApplicationUserModelId(hProcess, applicationUserModelIdLength, applicationUserModelId)
; hProcess : HANDLE -> "intptr"
; applicationUserModelIdLength : DWORD* in/out -> "var"
; applicationUserModelId : LPWSTR optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetApplicationUserModelId = kernel32.NewProc("GetApplicationUserModelId")
)

// hProcess (HANDLE), applicationUserModelIdLength (DWORD* in/out), applicationUserModelId (LPWSTR optional, out)
r1, _, err := procGetApplicationUserModelId.Call(
	uintptr(hProcess),
	uintptr(applicationUserModelIdLength),
	uintptr(applicationUserModelId),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // WIN32_ERROR
function GetApplicationUserModelId(
  hProcess: THandle;   // HANDLE
  applicationUserModelIdLength: Pointer;   // DWORD* in/out
  applicationUserModelId: PWideChar   // LPWSTR optional, out
): DWORD; stdcall;
  external 'KERNEL32.dll' name 'GetApplicationUserModelId';
result := DllCall("KERNEL32\GetApplicationUserModelId"
    , "Ptr", hProcess   ; HANDLE
    , "Ptr", applicationUserModelIdLength   ; DWORD* in/out
    , "Ptr", applicationUserModelId   ; LPWSTR optional, out
    , "UInt")   ; return: WIN32_ERROR
●GetApplicationUserModelId(hProcess, applicationUserModelIdLength, applicationUserModelId) = DLL("KERNEL32.dll", "dword GetApplicationUserModelId(void*, void*, char*)")
# 呼び出し: GetApplicationUserModelId(hProcess, applicationUserModelIdLength, applicationUserModelId)
# hProcess : HANDLE -> "void*"
# applicationUserModelIdLength : DWORD* in/out -> "void*"
# applicationUserModelId : LPWSTR optional, out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。