Win32 API 日本語リファレンス
ホームSecurity.Isolation › GetAppContainerNamedObjectPath

GetAppContainerNamedObjectPath

関数
AppContainerの名前付きオブジェクト用パスを取得する。
DLLKERNEL32.dll呼出規約winapiSetLastErrorあり対応OSwindows8.0

シグネチャ

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

BOOL GetAppContainerNamedObjectPath(
    HANDLE Token,   // optional
    PSID AppContainerSid,   // optional
    DWORD ObjectPathLength,
    LPWSTR ObjectPath,   // optional
    DWORD* ReturnLength
);

パラメーター

名前方向
TokenHANDLEinoptional
AppContainerSidPSIDinoptional
ObjectPathLengthDWORDin
ObjectPathLPWSTRoutoptional
ReturnLengthDWORD*out

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL GetAppContainerNamedObjectPath(
    HANDLE Token,   // optional
    PSID AppContainerSid,   // optional
    DWORD ObjectPathLength,
    LPWSTR ObjectPath,   // optional
    DWORD* ReturnLength
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool GetAppContainerNamedObjectPath(
    IntPtr Token,   // HANDLE optional
    IntPtr AppContainerSid,   // PSID optional
    uint ObjectPathLength,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ObjectPath,   // LPWSTR optional, out
    out uint ReturnLength   // DWORD* out
);
<DllImport("KERNEL32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetAppContainerNamedObjectPath(
    Token As IntPtr,   ' HANDLE optional
    AppContainerSid As IntPtr,   ' PSID optional
    ObjectPathLength As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> ObjectPath As System.Text.StringBuilder,   ' LPWSTR optional, out
    <Out> ByRef ReturnLength As UInteger   ' DWORD* out
) As Boolean
End Function
' Token : HANDLE optional
' AppContainerSid : PSID optional
' ObjectPathLength : DWORD
' ObjectPath : LPWSTR optional, out
' ReturnLength : DWORD* out
Declare PtrSafe Function GetAppContainerNamedObjectPath Lib "kernel32" ( _
    ByVal Token As LongPtr, _
    ByVal AppContainerSid As LongPtr, _
    ByVal ObjectPathLength As Long, _
    ByVal ObjectPath As LongPtr, _
    ByRef ReturnLength As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetAppContainerNamedObjectPath = ctypes.windll.kernel32.GetAppContainerNamedObjectPath
GetAppContainerNamedObjectPath.restype = wintypes.BOOL
GetAppContainerNamedObjectPath.argtypes = [
    wintypes.HANDLE,  # Token : HANDLE optional
    wintypes.HANDLE,  # AppContainerSid : PSID optional
    wintypes.DWORD,  # ObjectPathLength : DWORD
    wintypes.LPWSTR,  # ObjectPath : LPWSTR optional, out
    ctypes.POINTER(wintypes.DWORD),  # ReturnLength : DWORD* out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
GetAppContainerNamedObjectPath = Fiddle::Function.new(
  lib['GetAppContainerNamedObjectPath'],
  [
    Fiddle::TYPE_VOIDP,  # Token : HANDLE optional
    Fiddle::TYPE_VOIDP,  # AppContainerSid : PSID optional
    -Fiddle::TYPE_INT,  # ObjectPathLength : DWORD
    Fiddle::TYPE_VOIDP,  # ObjectPath : LPWSTR optional, out
    Fiddle::TYPE_VOIDP,  # ReturnLength : DWORD* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "kernel32")]
extern "system" {
    fn GetAppContainerNamedObjectPath(
        Token: *mut core::ffi::c_void,  // HANDLE optional
        AppContainerSid: *mut core::ffi::c_void,  // PSID optional
        ObjectPathLength: u32,  // DWORD
        ObjectPath: *mut u16,  // LPWSTR optional, out
        ReturnLength: *mut u32  // DWORD* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("KERNEL32.dll", SetLastError = true)]
public static extern bool GetAppContainerNamedObjectPath(IntPtr Token, IntPtr AppContainerSid, uint ObjectPathLength, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder ObjectPath, out uint ReturnLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_GetAppContainerNamedObjectPath' -Namespace Win32 -PassThru
# $api::GetAppContainerNamedObjectPath(Token, AppContainerSid, ObjectPathLength, ObjectPath, ReturnLength)
#uselib "KERNEL32.dll"
#func global GetAppContainerNamedObjectPath "GetAppContainerNamedObjectPath" sptr, sptr, sptr, sptr, sptr
; GetAppContainerNamedObjectPath Token, AppContainerSid, ObjectPathLength, varptr(ObjectPath), varptr(ReturnLength)   ; 戻り値は stat
; Token : HANDLE optional -> "sptr"
; AppContainerSid : PSID optional -> "sptr"
; ObjectPathLength : DWORD -> "sptr"
; ObjectPath : LPWSTR optional, out -> "sptr"
; ReturnLength : DWORD* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global GetAppContainerNamedObjectPath "GetAppContainerNamedObjectPath" sptr, sptr, int, var, var
; res = GetAppContainerNamedObjectPath(Token, AppContainerSid, ObjectPathLength, ObjectPath, ReturnLength)
; Token : HANDLE optional -> "sptr"
; AppContainerSid : PSID optional -> "sptr"
; ObjectPathLength : DWORD -> "int"
; ObjectPath : LPWSTR optional, out -> "var"
; ReturnLength : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; BOOL GetAppContainerNamedObjectPath(HANDLE Token, PSID AppContainerSid, DWORD ObjectPathLength, LPWSTR ObjectPath, DWORD* ReturnLength)
#uselib "KERNEL32.dll"
#cfunc global GetAppContainerNamedObjectPath "GetAppContainerNamedObjectPath" intptr, intptr, int, var, var
; res = GetAppContainerNamedObjectPath(Token, AppContainerSid, ObjectPathLength, ObjectPath, ReturnLength)
; Token : HANDLE optional -> "intptr"
; AppContainerSid : PSID optional -> "intptr"
; ObjectPathLength : DWORD -> "int"
; ObjectPath : LPWSTR optional, out -> "var"
; ReturnLength : DWORD* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetAppContainerNamedObjectPath = kernel32.NewProc("GetAppContainerNamedObjectPath")
)

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