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

GetAppContainerFolderPath

関数
AppContainer SIDに対応するフォルダーパスを取得する。
DLLUSERENV.dll呼出規約winapi対応OSwindows8.0

シグネチャ

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

HRESULT GetAppContainerFolderPath(
    LPCWSTR pszAppContainerSid,
    LPWSTR* ppszPath
);

パラメーター

名前方向
pszAppContainerSidLPCWSTRin
ppszPathLPWSTR*out

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT GetAppContainerFolderPath(
    LPCWSTR pszAppContainerSid,
    LPWSTR* ppszPath
);
[DllImport("USERENV.dll", ExactSpelling = true)]
static extern int GetAppContainerFolderPath(
    [MarshalAs(UnmanagedType.LPWStr)] string pszAppContainerSid,   // LPCWSTR
    IntPtr ppszPath   // LPWSTR* out
);
<DllImport("USERENV.dll", ExactSpelling:=True)>
Public Shared Function GetAppContainerFolderPath(
    <MarshalAs(UnmanagedType.LPWStr)> pszAppContainerSid As String,   ' LPCWSTR
    ppszPath As IntPtr   ' LPWSTR* out
) As Integer
End Function
' pszAppContainerSid : LPCWSTR
' ppszPath : LPWSTR* out
Declare PtrSafe Function GetAppContainerFolderPath Lib "userenv" ( _
    ByVal pszAppContainerSid As LongPtr, _
    ByVal ppszPath As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetAppContainerFolderPath = ctypes.windll.userenv.GetAppContainerFolderPath
GetAppContainerFolderPath.restype = ctypes.c_int
GetAppContainerFolderPath.argtypes = [
    wintypes.LPCWSTR,  # pszAppContainerSid : LPCWSTR
    ctypes.c_void_p,  # ppszPath : LPWSTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USERENV.dll')
GetAppContainerFolderPath = Fiddle::Function.new(
  lib['GetAppContainerFolderPath'],
  [
    Fiddle::TYPE_VOIDP,  # pszAppContainerSid : LPCWSTR
    Fiddle::TYPE_VOIDP,  # ppszPath : LPWSTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "userenv")]
extern "system" {
    fn GetAppContainerFolderPath(
        pszAppContainerSid: *const u16,  // LPCWSTR
        ppszPath: *mut *mut u16  // LPWSTR* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("USERENV.dll")]
public static extern int GetAppContainerFolderPath([MarshalAs(UnmanagedType.LPWStr)] string pszAppContainerSid, IntPtr ppszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USERENV_GetAppContainerFolderPath' -Namespace Win32 -PassThru
# $api::GetAppContainerFolderPath(pszAppContainerSid, ppszPath)
#uselib "USERENV.dll"
#func global GetAppContainerFolderPath "GetAppContainerFolderPath" sptr, sptr
; GetAppContainerFolderPath pszAppContainerSid, varptr(ppszPath)   ; 戻り値は stat
; pszAppContainerSid : LPCWSTR -> "sptr"
; ppszPath : LPWSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "USERENV.dll"
#cfunc global GetAppContainerFolderPath "GetAppContainerFolderPath" wstr, var
; res = GetAppContainerFolderPath(pszAppContainerSid, ppszPath)
; pszAppContainerSid : LPCWSTR -> "wstr"
; ppszPath : LPWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT GetAppContainerFolderPath(LPCWSTR pszAppContainerSid, LPWSTR* ppszPath)
#uselib "USERENV.dll"
#cfunc global GetAppContainerFolderPath "GetAppContainerFolderPath" wstr, var
; res = GetAppContainerFolderPath(pszAppContainerSid, ppszPath)
; pszAppContainerSid : LPCWSTR -> "wstr"
; ppszPath : LPWSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	userenv = windows.NewLazySystemDLL("USERENV.dll")
	procGetAppContainerFolderPath = userenv.NewProc("GetAppContainerFolderPath")
)

// pszAppContainerSid (LPCWSTR), ppszPath (LPWSTR* out)
r1, _, err := procGetAppContainerFolderPath.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszAppContainerSid))),
	uintptr(ppszPath),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetAppContainerFolderPath(
  pszAppContainerSid: PWideChar;   // LPCWSTR
  ppszPath: PPWideChar   // LPWSTR* out
): Integer; stdcall;
  external 'USERENV.dll' name 'GetAppContainerFolderPath';
result := DllCall("USERENV\GetAppContainerFolderPath"
    , "WStr", pszAppContainerSid   ; LPCWSTR
    , "Ptr", ppszPath   ; LPWSTR* out
    , "Int")   ; return: HRESULT
●GetAppContainerFolderPath(pszAppContainerSid, ppszPath) = DLL("USERENV.dll", "int GetAppContainerFolderPath(char*, void*)")
# 呼び出し: GetAppContainerFolderPath(pszAppContainerSid, ppszPath)
# pszAppContainerSid : LPCWSTR -> "char*"
# ppszPath : LPWSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。