ホーム › System.Threading › CreatePrivateNamespaceA
CreatePrivateNamespaceA
関数プライベート名前空間を作成する(ANSI版)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE CreatePrivateNamespaceA(
SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes, // optional
void* lpBoundaryDescriptor,
LPCSTR lpAliasPrefix
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| lpPrivateNamespaceAttributes | SECURITY_ATTRIBUTES* | inoptional |
| lpBoundaryDescriptor | void* | in |
| lpAliasPrefix | LPCSTR | in |
戻り値の型: HANDLE
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE CreatePrivateNamespaceA(
SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes, // optional
void* lpBoundaryDescriptor,
LPCSTR lpAliasPrefix
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
static extern IntPtr CreatePrivateNamespaceA(
IntPtr lpPrivateNamespaceAttributes, // SECURITY_ATTRIBUTES* optional
IntPtr lpBoundaryDescriptor, // void*
[MarshalAs(UnmanagedType.LPStr)] string lpAliasPrefix // LPCSTR
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function CreatePrivateNamespaceA(
lpPrivateNamespaceAttributes As IntPtr, ' SECURITY_ATTRIBUTES* optional
lpBoundaryDescriptor As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> lpAliasPrefix As String ' LPCSTR
) As IntPtr
End Function' lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional
' lpBoundaryDescriptor : void*
' lpAliasPrefix : LPCSTR
Declare PtrSafe Function CreatePrivateNamespaceA Lib "kernel32" ( _
ByVal lpPrivateNamespaceAttributes As LongPtr, _
ByVal lpBoundaryDescriptor As LongPtr, _
ByVal lpAliasPrefix As String) As LongPtr
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
CreatePrivateNamespaceA = ctypes.windll.kernel32.CreatePrivateNamespaceA
CreatePrivateNamespaceA.restype = ctypes.c_void_p
CreatePrivateNamespaceA.argtypes = [
ctypes.c_void_p, # lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional
ctypes.POINTER(None), # lpBoundaryDescriptor : void*
wintypes.LPCSTR, # lpAliasPrefix : LPCSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
CreatePrivateNamespaceA = Fiddle::Function.new(
lib['CreatePrivateNamespaceA'],
[
Fiddle::TYPE_VOIDP, # lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional
Fiddle::TYPE_VOIDP, # lpBoundaryDescriptor : void*
Fiddle::TYPE_VOIDP, # lpAliasPrefix : LPCSTR
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn CreatePrivateNamespaceA(
lpPrivateNamespaceAttributes: *mut SECURITY_ATTRIBUTES, // SECURITY_ATTRIBUTES* optional
lpBoundaryDescriptor: *mut (), // void*
lpAliasPrefix: *const u8 // LPCSTR
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, SetLastError = true)]
public static extern IntPtr CreatePrivateNamespaceA(IntPtr lpPrivateNamespaceAttributes, IntPtr lpBoundaryDescriptor, [MarshalAs(UnmanagedType.LPStr)] string lpAliasPrefix);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_CreatePrivateNamespaceA' -Namespace Win32 -PassThru
# $api::CreatePrivateNamespaceA(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix)#uselib "KERNEL32.dll"
#func global CreatePrivateNamespaceA "CreatePrivateNamespaceA" sptr, sptr, sptr
; CreatePrivateNamespaceA varptr(lpPrivateNamespaceAttributes), lpBoundaryDescriptor, lpAliasPrefix ; 戻り値は stat
; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "sptr"
; lpBoundaryDescriptor : void* -> "sptr"
; lpAliasPrefix : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "KERNEL32.dll" #cfunc global CreatePrivateNamespaceA "CreatePrivateNamespaceA" var, sptr, str ; res = CreatePrivateNamespaceA(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix) ; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; lpBoundaryDescriptor : void* -> "sptr" ; lpAliasPrefix : LPCSTR -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "KERNEL32.dll" #cfunc global CreatePrivateNamespaceA "CreatePrivateNamespaceA" sptr, sptr, str ; res = CreatePrivateNamespaceA(varptr(lpPrivateNamespaceAttributes), lpBoundaryDescriptor, lpAliasPrefix) ; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "sptr" ; lpBoundaryDescriptor : void* -> "sptr" ; lpAliasPrefix : LPCSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HANDLE CreatePrivateNamespaceA(SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes, void* lpBoundaryDescriptor, LPCSTR lpAliasPrefix) #uselib "KERNEL32.dll" #cfunc global CreatePrivateNamespaceA "CreatePrivateNamespaceA" var, intptr, str ; res = CreatePrivateNamespaceA(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix) ; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "var" ; lpBoundaryDescriptor : void* -> "intptr" ; lpAliasPrefix : LPCSTR -> "str" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HANDLE CreatePrivateNamespaceA(SECURITY_ATTRIBUTES* lpPrivateNamespaceAttributes, void* lpBoundaryDescriptor, LPCSTR lpAliasPrefix) #uselib "KERNEL32.dll" #cfunc global CreatePrivateNamespaceA "CreatePrivateNamespaceA" intptr, intptr, str ; res = CreatePrivateNamespaceA(varptr(lpPrivateNamespaceAttributes), lpBoundaryDescriptor, lpAliasPrefix) ; lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "intptr" ; lpBoundaryDescriptor : void* -> "intptr" ; lpAliasPrefix : LPCSTR -> "str" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procCreatePrivateNamespaceA = kernel32.NewProc("CreatePrivateNamespaceA")
)
// lpPrivateNamespaceAttributes (SECURITY_ATTRIBUTES* optional), lpBoundaryDescriptor (void*), lpAliasPrefix (LPCSTR)
r1, _, err := procCreatePrivateNamespaceA.Call(
uintptr(lpPrivateNamespaceAttributes),
uintptr(lpBoundaryDescriptor),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpAliasPrefix))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction CreatePrivateNamespaceA(
lpPrivateNamespaceAttributes: Pointer; // SECURITY_ATTRIBUTES* optional
lpBoundaryDescriptor: Pointer; // void*
lpAliasPrefix: PAnsiChar // LPCSTR
): THandle; stdcall;
external 'KERNEL32.dll' name 'CreatePrivateNamespaceA';result := DllCall("KERNEL32\CreatePrivateNamespaceA"
, "Ptr", lpPrivateNamespaceAttributes ; SECURITY_ATTRIBUTES* optional
, "Ptr", lpBoundaryDescriptor ; void*
, "AStr", lpAliasPrefix ; LPCSTR
, "Ptr") ; return: HANDLE●CreatePrivateNamespaceA(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix) = DLL("KERNEL32.dll", "void* CreatePrivateNamespaceA(void*, void*, char*)")
# 呼び出し: CreatePrivateNamespaceA(lpPrivateNamespaceAttributes, lpBoundaryDescriptor, lpAliasPrefix)
# lpPrivateNamespaceAttributes : SECURITY_ATTRIBUTES* optional -> "void*"
# lpBoundaryDescriptor : void* -> "void*"
# lpAliasPrefix : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。