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

RpcNsProfileEltAddW

関数
ネームサービスのプロファイルに要素を追加する(Unicode版)。
DLLRPCNS4.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

RPC_STATUS RpcNsProfileEltAddW(
    DWORD ProfileNameSyntax,
    LPWSTR ProfileName,
    RPC_IF_ID* IfId,   // optional
    DWORD MemberNameSyntax,
    LPWSTR MemberName,
    DWORD Priority,
    LPWSTR Annotation   // optional
);

パラメーター

名前方向
ProfileNameSyntaxDWORDin
ProfileNameLPWSTRin
IfIdRPC_IF_ID*inoptional
MemberNameSyntaxDWORDin
MemberNameLPWSTRin
PriorityDWORDin
AnnotationLPWSTRinoptional

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS RpcNsProfileEltAddW(
    DWORD ProfileNameSyntax,
    LPWSTR ProfileName,
    RPC_IF_ID* IfId,   // optional
    DWORD MemberNameSyntax,
    LPWSTR MemberName,
    DWORD Priority,
    LPWSTR Annotation   // optional
);
[DllImport("RPCNS4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int RpcNsProfileEltAddW(
    uint ProfileNameSyntax,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string ProfileName,   // LPWSTR
    IntPtr IfId,   // RPC_IF_ID* optional
    uint MemberNameSyntax,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string MemberName,   // LPWSTR
    uint Priority,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] string Annotation   // LPWSTR optional
);
<DllImport("RPCNS4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function RpcNsProfileEltAddW(
    ProfileNameSyntax As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> ProfileName As String,   ' LPWSTR
    IfId As IntPtr,   ' RPC_IF_ID* optional
    MemberNameSyntax As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> MemberName As String,   ' LPWSTR
    Priority As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> Annotation As String   ' LPWSTR optional
) As Integer
End Function
' ProfileNameSyntax : DWORD
' ProfileName : LPWSTR
' IfId : RPC_IF_ID* optional
' MemberNameSyntax : DWORD
' MemberName : LPWSTR
' Priority : DWORD
' Annotation : LPWSTR optional
Declare PtrSafe Function RpcNsProfileEltAddW Lib "rpcns4" ( _
    ByVal ProfileNameSyntax As Long, _
    ByVal ProfileName As LongPtr, _
    ByVal IfId As LongPtr, _
    ByVal MemberNameSyntax As Long, _
    ByVal MemberName As LongPtr, _
    ByVal Priority As Long, _
    ByVal Annotation As LongPtr) As Long
' 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

RpcNsProfileEltAddW = ctypes.windll.rpcns4.RpcNsProfileEltAddW
RpcNsProfileEltAddW.restype = ctypes.c_int
RpcNsProfileEltAddW.argtypes = [
    wintypes.DWORD,  # ProfileNameSyntax : DWORD
    wintypes.LPCWSTR,  # ProfileName : LPWSTR
    ctypes.c_void_p,  # IfId : RPC_IF_ID* optional
    wintypes.DWORD,  # MemberNameSyntax : DWORD
    wintypes.LPCWSTR,  # MemberName : LPWSTR
    wintypes.DWORD,  # Priority : DWORD
    wintypes.LPCWSTR,  # Annotation : LPWSTR optional
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCNS4.dll')
RpcNsProfileEltAddW = Fiddle::Function.new(
  lib['RpcNsProfileEltAddW'],
  [
    -Fiddle::TYPE_INT,  # ProfileNameSyntax : DWORD
    Fiddle::TYPE_VOIDP,  # ProfileName : LPWSTR
    Fiddle::TYPE_VOIDP,  # IfId : RPC_IF_ID* optional
    -Fiddle::TYPE_INT,  # MemberNameSyntax : DWORD
    Fiddle::TYPE_VOIDP,  # MemberName : LPWSTR
    -Fiddle::TYPE_INT,  # Priority : DWORD
    Fiddle::TYPE_VOIDP,  # Annotation : LPWSTR optional
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "rpcns4")]
extern "system" {
    fn RpcNsProfileEltAddW(
        ProfileNameSyntax: u32,  // DWORD
        ProfileName: *mut u16,  // LPWSTR
        IfId: *mut RPC_IF_ID,  // RPC_IF_ID* optional
        MemberNameSyntax: u32,  // DWORD
        MemberName: *mut u16,  // LPWSTR
        Priority: u32,  // DWORD
        Annotation: *mut u16  // LPWSTR optional
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCNS4.dll", CharSet = CharSet.Unicode)]
public static extern int RpcNsProfileEltAddW(uint ProfileNameSyntax, [MarshalAs(UnmanagedType.LPWStr)] string ProfileName, IntPtr IfId, uint MemberNameSyntax, [MarshalAs(UnmanagedType.LPWStr)] string MemberName, uint Priority, [MarshalAs(UnmanagedType.LPWStr)] string Annotation);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCNS4_RpcNsProfileEltAddW' -Namespace Win32 -PassThru
# $api::RpcNsProfileEltAddW(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation)
#uselib "RPCNS4.dll"
#func global RpcNsProfileEltAddW "RpcNsProfileEltAddW" wptr, wptr, wptr, wptr, wptr, wptr, wptr
; RpcNsProfileEltAddW ProfileNameSyntax, ProfileName, varptr(IfId), MemberNameSyntax, MemberName, Priority, Annotation   ; 戻り値は stat
; ProfileNameSyntax : DWORD -> "wptr"
; ProfileName : LPWSTR -> "wptr"
; IfId : RPC_IF_ID* optional -> "wptr"
; MemberNameSyntax : DWORD -> "wptr"
; MemberName : LPWSTR -> "wptr"
; Priority : DWORD -> "wptr"
; Annotation : LPWSTR optional -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCNS4.dll"
#cfunc global RpcNsProfileEltAddW "RpcNsProfileEltAddW" int, wstr, var, int, wstr, int, wstr
; res = RpcNsProfileEltAddW(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation)
; ProfileNameSyntax : DWORD -> "int"
; ProfileName : LPWSTR -> "wstr"
; IfId : RPC_IF_ID* optional -> "var"
; MemberNameSyntax : DWORD -> "int"
; MemberName : LPWSTR -> "wstr"
; Priority : DWORD -> "int"
; Annotation : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS RpcNsProfileEltAddW(DWORD ProfileNameSyntax, LPWSTR ProfileName, RPC_IF_ID* IfId, DWORD MemberNameSyntax, LPWSTR MemberName, DWORD Priority, LPWSTR Annotation)
#uselib "RPCNS4.dll"
#cfunc global RpcNsProfileEltAddW "RpcNsProfileEltAddW" int, wstr, var, int, wstr, int, wstr
; res = RpcNsProfileEltAddW(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation)
; ProfileNameSyntax : DWORD -> "int"
; ProfileName : LPWSTR -> "wstr"
; IfId : RPC_IF_ID* optional -> "var"
; MemberNameSyntax : DWORD -> "int"
; MemberName : LPWSTR -> "wstr"
; Priority : DWORD -> "int"
; Annotation : LPWSTR optional -> "wstr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcns4 = windows.NewLazySystemDLL("RPCNS4.dll")
	procRpcNsProfileEltAddW = rpcns4.NewProc("RpcNsProfileEltAddW")
)

// ProfileNameSyntax (DWORD), ProfileName (LPWSTR), IfId (RPC_IF_ID* optional), MemberNameSyntax (DWORD), MemberName (LPWSTR), Priority (DWORD), Annotation (LPWSTR optional)
r1, _, err := procRpcNsProfileEltAddW.Call(
	uintptr(ProfileNameSyntax),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(ProfileName))),
	uintptr(IfId),
	uintptr(MemberNameSyntax),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(MemberName))),
	uintptr(Priority),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(Annotation))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcNsProfileEltAddW(
  ProfileNameSyntax: DWORD;   // DWORD
  ProfileName: PWideChar;   // LPWSTR
  IfId: Pointer;   // RPC_IF_ID* optional
  MemberNameSyntax: DWORD;   // DWORD
  MemberName: PWideChar;   // LPWSTR
  Priority: DWORD;   // DWORD
  Annotation: PWideChar   // LPWSTR optional
): Integer; stdcall;
  external 'RPCNS4.dll' name 'RpcNsProfileEltAddW';
result := DllCall("RPCNS4\RpcNsProfileEltAddW"
    , "UInt", ProfileNameSyntax   ; DWORD
    , "WStr", ProfileName   ; LPWSTR
    , "Ptr", IfId   ; RPC_IF_ID* optional
    , "UInt", MemberNameSyntax   ; DWORD
    , "WStr", MemberName   ; LPWSTR
    , "UInt", Priority   ; DWORD
    , "WStr", Annotation   ; LPWSTR optional
    , "Int")   ; return: RPC_STATUS
●RpcNsProfileEltAddW(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation) = DLL("RPCNS4.dll", "int RpcNsProfileEltAddW(dword, char*, void*, dword, char*, dword, char*)")
# 呼び出し: RpcNsProfileEltAddW(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation)
# ProfileNameSyntax : DWORD -> "dword"
# ProfileName : LPWSTR -> "char*"
# IfId : RPC_IF_ID* optional -> "void*"
# MemberNameSyntax : DWORD -> "dword"
# MemberName : LPWSTR -> "char*"
# Priority : DWORD -> "dword"
# Annotation : LPWSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。