Win32 API 日本語リファレンス
ホームSystem.Threading › CreatePrivateNamespaceW

CreatePrivateNamespaceW

関数
境界記述子に基づくプライベート名前空間を作成する。
DLLKERNEL32.dll文字セットUnicode (-W)呼出規約winapi

シグネチャ

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

HANDLE CreatePrivateNamespaceW(
    SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes,   // optional
    void* lpBoundaryDescriptor,
    LPCWSTR lpAliasPrefix
);

パラメーター

名前方向
lpPrivateNamespaceAttributesSECURITY_ATTRIBUTES*inoptional
lpBoundaryDescriptorvoid*in
lpAliasPrefixLPCWSTRin

戻り値の型: HANDLE

各言語での呼び出し定義

// KERNEL32.dll  (Unicode / -W)
#include <windows.h>

HANDLE CreatePrivateNamespaceW(
    SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes,   // optional
    void* lpBoundaryDescriptor,
    LPCWSTR lpAliasPrefix
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern IntPtr CreatePrivateNamespaceW(
    IntPtr lpPrivateNamespaceAttributes,   // SECURITY_ATTRIBUTES* optional
    IntPtr lpBoundaryDescriptor,   // void*
    [MarshalAs(UnmanagedType.LPWStr)] string lpAliasPrefix   // LPCWSTR
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function CreatePrivateNamespaceW(
    lpPrivateNamespaceAttributes As IntPtr,   ' SECURITY_ATTRIBUTES* optional
    lpBoundaryDescriptor As IntPtr,   ' void*
    <MarshalAs(UnmanagedType.LPWStr)> lpAliasPrefix As String   ' LPCWSTR
) As IntPtr
End Function
' lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional
' lpBoundaryDescriptor : void*
' lpAliasPrefix : LPCWSTR
Declare PtrSafe Function CreatePrivateNamespaceW Lib "kernel32" ( _
    ByVal lpPrivateNamespaceAttributes As LongPtr, _
    ByVal lpBoundaryDescriptor As LongPtr, _
    ByVal lpAliasPrefix As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

CreatePrivateNamespaceW = ctypes.windll.kernel32.CreatePrivateNamespaceW
CreatePrivateNamespaceW.restype = ctypes.c_void_p
CreatePrivateNamespaceW.argtypes = [
    ctypes.c_void_p,  # lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional
    ctypes.POINTER(None),  # lpBoundaryDescriptor : void*
    wintypes.LPCWSTR,  # lpAliasPrefix : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('KERNEL32.dll')
CreatePrivateNamespaceW = Fiddle::Function.new(
  lib['CreatePrivateNamespaceW'],
  [
    Fiddle::TYPE_VOIDP,  # lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional
    Fiddle::TYPE_VOIDP,  # lpBoundaryDescriptor : void*
    Fiddle::TYPE_VOIDP,  # lpAliasPrefix : LPCWSTR
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "kernel32")]
extern "system" {
    fn CreatePrivateNamespaceW(
        lpPrivateNamespaceAttributes: *mut SECURITY_ATTRIBUTES,  // SECURITY_ATTRIBUTES* optional
        lpBoundaryDescriptor: *mut (),  // void*
        lpAliasPrefix: *const u16  // LPCWSTR
    ) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr CreatePrivateNamespaceW(IntPtr lpPrivateNamespaceAttributes, IntPtr lpBoundaryDescriptor, [MarshalAs(UnmanagedType.LPWStr)] string lpAliasPrefix);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreatePrivateNamespaceW' -Namespace Win32 -PassThru
# $api::CreatePrivateNamespaceW(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix)
#uselib "KERNEL32.dll"
#func global CreatePrivateNamespaceW "CreatePrivateNamespaceW" wptr, wptr, wptr
; CreatePrivateNamespaceW varptr(lpPrivateNamespaceAttributes), lpBoundaryDescriptor, lpAliasPrefix   ; 戻り値は stat
; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "wptr"
; lpBoundaryDescriptor : void* -> "wptr"
; lpAliasPrefix : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "KERNEL32.dll"
#cfunc global CreatePrivateNamespaceW "CreatePrivateNamespaceW" var, sptr, wstr
; res = CreatePrivateNamespaceW(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix)
; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "var"
; lpBoundaryDescriptor : void* -> "sptr"
; lpAliasPrefix : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HANDLE CreatePrivateNamespaceW(SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes, void* lpBoundaryDescriptor, LPCWSTR lpAliasPrefix)
#uselib "KERNEL32.dll"
#cfunc global CreatePrivateNamespaceW "CreatePrivateNamespaceW" var, intptr, wstr
; res = CreatePrivateNamespaceW(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix)
; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "var"
; lpBoundaryDescriptor : void* -> "intptr"
; lpAliasPrefix : LPCWSTR -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procCreatePrivateNamespaceW = kernel32.NewProc("CreatePrivateNamespaceW")
)

// lpPrivateNamespaceAttributes (SECURITY_ATTRIBUTES* optional), lpBoundaryDescriptor (void*), lpAliasPrefix (LPCWSTR)
r1, _, err := procCreatePrivateNamespaceW.Call(
	uintptr(lpPrivateNamespaceAttributes),
	uintptr(lpBoundaryDescriptor),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpAliasPrefix))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function CreatePrivateNamespaceW(
  lpPrivateNamespaceAttributes: Pointer;   // SECURITY_ATTRIBUTES* optional
  lpBoundaryDescriptor: Pointer;   // void*
  lpAliasPrefix: PWideChar   // LPCWSTR
): THandle; stdcall;
  external 'KERNEL32.dll' name 'CreatePrivateNamespaceW';
result := DllCall("KERNEL32\CreatePrivateNamespaceW"
    , "Ptr", lpPrivateNamespaceAttributes   ; SECURITY_ATTRIBUTES* optional
    , "Ptr", lpBoundaryDescriptor   ; void*
    , "WStr", lpAliasPrefix   ; LPCWSTR
    , "Ptr")   ; return: HANDLE
●CreatePrivateNamespaceW(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix) = DLL("KERNEL32.dll", "void* CreatePrivateNamespaceW(void*, void*, char*)")
# 呼び出し: CreatePrivateNamespaceW(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix)
# lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# lpBoundaryDescriptor : void* -> "void*"
# lpAliasPrefix : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。