ホーム › System.Threading › OpenPrivateNamespaceA
OpenPrivateNamespaceA
関数既存のプライベート名前空間を開く(ANSI版)。
シグネチャ
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE OpenPrivateNamespaceA(
void* lpBoundaryDescriptor,
LPCSTR lpAliasPrefix
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| lpBoundaryDescriptor | void* | in | 名前空間をどのように分離するかを定義する記述子です。境界記述子は CreateBoundaryDescriptor 関数によって作成されます。 |
| lpAliasPrefix | LPCSTR | in | 名前空間のプレフィックスです。この名前空間内にオブジェクトを作成するには、オブジェクト名を prefix\objectname の形式で指定します。 |
戻り値の型: HANDLE
公式ドキュメント
OpenPrivateNamespaceA (ANSI) 関数 (winbase.h) は、プライベート名前空間を開きます。
戻り値
この関数は、既存の名前空間へのハンドルを返します。
解説(Remarks)
この関数を使用するアプリケーションをコンパイルするには、_WIN32_WINNT を 0x0600 以降として定義してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// KERNEL32.dll (ANSI / -A)
#include <windows.h>
HANDLE OpenPrivateNamespaceA(
void* lpBoundaryDescriptor,
LPCSTR lpAliasPrefix
);[DllImport("KERNEL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern IntPtr OpenPrivateNamespaceA(
IntPtr lpBoundaryDescriptor, // void*
[MarshalAs(UnmanagedType.LPStr)] string lpAliasPrefix // LPCSTR
);<DllImport("KERNEL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function OpenPrivateNamespaceA(
lpBoundaryDescriptor As IntPtr, ' void*
<MarshalAs(UnmanagedType.LPStr)> lpAliasPrefix As String ' LPCSTR
) As IntPtr
End Function' lpBoundaryDescriptor : void*
' lpAliasPrefix : LPCSTR
Declare PtrSafe Function OpenPrivateNamespaceA Lib "kernel32" ( _
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
OpenPrivateNamespaceA = ctypes.windll.kernel32.OpenPrivateNamespaceA
OpenPrivateNamespaceA.restype = ctypes.c_void_p
OpenPrivateNamespaceA.argtypes = [
ctypes.POINTER(None), # lpBoundaryDescriptor : void*
wintypes.LPCSTR, # lpAliasPrefix : LPCSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('KERNEL32.dll')
OpenPrivateNamespaceA = Fiddle::Function.new(
lib['OpenPrivateNamespaceA'],
[
Fiddle::TYPE_VOIDP, # lpBoundaryDescriptor : void*
Fiddle::TYPE_VOIDP, # lpAliasPrefix : LPCSTR
],
Fiddle::TYPE_VOIDP)#[link(name = "kernel32")]
extern "system" {
fn OpenPrivateNamespaceA(
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)]
public static extern IntPtr OpenPrivateNamespaceA(IntPtr lpBoundaryDescriptor, [MarshalAs(UnmanagedType.LPStr)] string lpAliasPrefix);
"@
$api = Add-Type -MemberDefinition $sig -Name 'KERNEL32_OpenPrivateNamespaceA' -Namespace Win32 -PassThru
# $api::OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)#uselib "KERNEL32.dll"
#func global OpenPrivateNamespaceA "OpenPrivateNamespaceA" sptr, sptr
; OpenPrivateNamespaceA lpBoundaryDescriptor, lpAliasPrefix ; 戻り値は stat
; lpBoundaryDescriptor : void* -> "sptr"
; lpAliasPrefix : LPCSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "KERNEL32.dll"
#cfunc global OpenPrivateNamespaceA "OpenPrivateNamespaceA" sptr, str
; res = OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)
; lpBoundaryDescriptor : void* -> "sptr"
; lpAliasPrefix : LPCSTR -> "str"; HANDLE OpenPrivateNamespaceA(void* lpBoundaryDescriptor, LPCSTR lpAliasPrefix)
#uselib "KERNEL32.dll"
#cfunc global OpenPrivateNamespaceA "OpenPrivateNamespaceA" intptr, str
; res = OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)
; lpBoundaryDescriptor : void* -> "intptr"
; lpAliasPrefix : LPCSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
procOpenPrivateNamespaceA = kernel32.NewProc("OpenPrivateNamespaceA")
)
// lpBoundaryDescriptor (void*), lpAliasPrefix (LPCSTR)
r1, _, err := procOpenPrivateNamespaceA.Call(
uintptr(lpBoundaryDescriptor),
uintptr(unsafe.Pointer(windows.BytePtrFromString(lpAliasPrefix))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HANDLEfunction OpenPrivateNamespaceA(
lpBoundaryDescriptor: Pointer; // void*
lpAliasPrefix: PAnsiChar // LPCSTR
): THandle; stdcall;
external 'KERNEL32.dll' name 'OpenPrivateNamespaceA';result := DllCall("KERNEL32\OpenPrivateNamespaceA"
, "Ptr", lpBoundaryDescriptor ; void*
, "AStr", lpAliasPrefix ; LPCSTR
, "Ptr") ; return: HANDLE●OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix) = DLL("KERNEL32.dll", "void* OpenPrivateNamespaceA(void*, char*)")
# 呼び出し: OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)
# lpBoundaryDescriptor : void* -> "void*"
# lpAliasPrefix : LPCSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "kernel32" fn OpenPrivateNamespaceA(
lpBoundaryDescriptor: ?*anyopaque, // void*
lpAliasPrefix: [*c]const u8 // LPCSTR
) callconv(std.os.windows.WINAPI) ?*anyopaque;proc OpenPrivateNamespaceA(
lpBoundaryDescriptor: pointer, # void*
lpAliasPrefix: cstring # LPCSTR
): pointer {.importc: "OpenPrivateNamespaceA", stdcall, dynlib: "KERNEL32.dll".}pragma(lib, "kernel32");
extern(Windows)
void* OpenPrivateNamespaceA(
void* lpBoundaryDescriptor, // void*
const(char)* lpAliasPrefix // LPCSTR
);ccall((:OpenPrivateNamespaceA, "KERNEL32.dll"), stdcall, Ptr{Cvoid},
(Ptr{Cvoid}, Cstring),
lpBoundaryDescriptor, lpAliasPrefix)
# lpBoundaryDescriptor : void* -> Ptr{Cvoid}
# lpAliasPrefix : LPCSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void* OpenPrivateNamespaceA(
void* lpBoundaryDescriptor,
const char* lpAliasPrefix);
]]
local kernel32 = ffi.load("kernel32")
-- kernel32.OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)
-- lpBoundaryDescriptor : void*
-- lpAliasPrefix : LPCSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('KERNEL32.dll');
const OpenPrivateNamespaceA = lib.func('__stdcall', 'OpenPrivateNamespaceA', 'void *', ['void *', 'str']);
// OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)
// lpBoundaryDescriptor : void* -> 'void *'
// lpAliasPrefix : LPCSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("KERNEL32.dll", {
OpenPrivateNamespaceA: { parameters: ["pointer", "buffer"], result: "pointer" },
});
// lib.symbols.OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix)
// lpBoundaryDescriptor : void* -> "pointer"
// lpAliasPrefix : LPCSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void* OpenPrivateNamespaceA(
void* lpBoundaryDescriptor,
const char* lpAliasPrefix);
C, "KERNEL32.dll");
// $ffi->OpenPrivateNamespaceA(lpBoundaryDescriptor, lpAliasPrefix);
// lpBoundaryDescriptor : void*
// lpAliasPrefix : LPCSTR
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Kernel32 extends StdCallLibrary {
Kernel32 INSTANCE = Native.load("kernel32", Kernel32.class, W32APIOptions.ASCII_OPTIONS);
Pointer OpenPrivateNamespaceA(
Pointer lpBoundaryDescriptor, // void*
String lpAliasPrefix // LPCSTR
);
}@[Link("kernel32")]
lib LibKERNEL32
fun OpenPrivateNamespaceA = OpenPrivateNamespaceA(
lpBoundaryDescriptor : Void*, # void*
lpAliasPrefix : UInt8* # LPCSTR
) : Void*
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef OpenPrivateNamespaceANative = Pointer<Void> Function(Pointer<Void>, Pointer<Utf8>);
typedef OpenPrivateNamespaceADart = Pointer<Void> Function(Pointer<Void>, Pointer<Utf8>);
final OpenPrivateNamespaceA = DynamicLibrary.open('KERNEL32.dll')
.lookupFunction<OpenPrivateNamespaceANative, OpenPrivateNamespaceADart>('OpenPrivateNamespaceA');
// lpBoundaryDescriptor : void* -> Pointer<Void>
// lpAliasPrefix : LPCSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function OpenPrivateNamespaceA(
lpBoundaryDescriptor: Pointer; // void*
lpAliasPrefix: PAnsiChar // LPCSTR
): THandle; stdcall;
external 'KERNEL32.dll' name 'OpenPrivateNamespaceA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "OpenPrivateNamespaceA"
c_OpenPrivateNamespaceA :: Ptr () -> CString -> IO (Ptr ())
-- lpBoundaryDescriptor : void* -> Ptr ()
-- lpAliasPrefix : LPCSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let openprivatenamespacea =
foreign "OpenPrivateNamespaceA"
((ptr void) @-> string @-> returning (ptr void))
(* lpBoundaryDescriptor : void* -> (ptr void) *)
(* lpAliasPrefix : LPCSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library kernel32 (t "KERNEL32.dll"))
(cffi:use-foreign-library kernel32)
(cffi:defcfun ("OpenPrivateNamespaceA" open-private-namespace-a :convention :stdcall) :pointer
(lp-boundary-descriptor :pointer) ; void*
(lp-alias-prefix :string)) ; LPCSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $OpenPrivateNamespaceA = Win32::API::More->new('KERNEL32',
'HANDLE OpenPrivateNamespaceA(LPVOID lpBoundaryDescriptor, LPCSTR lpAliasPrefix)');
# my $ret = $OpenPrivateNamespaceA->Call($lpBoundaryDescriptor, $lpAliasPrefix);
# lpBoundaryDescriptor : void* -> LPVOID
# lpAliasPrefix : LPCSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f OpenPrivateNamespaceW (Unicode版) — 既存のプライベート名前空間を開く。
公式の関連項目
- f ClosePrivateNamespace — 開いたプライベート名前空間を閉じる。
- f CreateBoundaryDescriptorA — プライベート名前空間用の境界記述子を作成する(ANSI版)。
- f CreatePrivateNamespaceA — プライベート名前空間を作成する(ANSI版)。