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

RpcNsProfileEltAddA

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

シグネチャ

// RPCNS4.dll  (ANSI / -A)
#include <windows.h>

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

パラメーター

名前方向
ProfileNameSyntaxDWORDin
ProfileNameLPSTRin
IfIdRPC_IF_ID*inoptional
MemberNameSyntaxDWORDin
MemberNameLPSTRin
PriorityDWORDin
AnnotationLPSTRinoptional

戻り値の型: RPC_STATUS

各言語での呼び出し定義

// RPCNS4.dll  (ANSI / -A)
#include <windows.h>

RPC_STATUS RpcNsProfileEltAddA(
    DWORD ProfileNameSyntax,
    LPSTR ProfileName,
    RPC_IF_ID* IfId,   // optional
    DWORD MemberNameSyntax,
    LPSTR MemberName,
    DWORD Priority,
    LPSTR Annotation   // optional
);
[DllImport("RPCNS4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcNsProfileEltAddA(
    uint ProfileNameSyntax,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string ProfileName,   // LPSTR
    IntPtr IfId,   // RPC_IF_ID* optional
    uint MemberNameSyntax,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string MemberName,   // LPSTR
    uint Priority,   // DWORD
    [MarshalAs(UnmanagedType.LPStr)] string Annotation   // LPSTR optional
);
<DllImport("RPCNS4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcNsProfileEltAddA(
    ProfileNameSyntax As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> ProfileName As String,   ' LPSTR
    IfId As IntPtr,   ' RPC_IF_ID* optional
    MemberNameSyntax As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> MemberName As String,   ' LPSTR
    Priority As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPStr)> Annotation As String   ' LPSTR optional
) As Integer
End Function
' ProfileNameSyntax : DWORD
' ProfileName : LPSTR
' IfId : RPC_IF_ID* optional
' MemberNameSyntax : DWORD
' MemberName : LPSTR
' Priority : DWORD
' Annotation : LPSTR optional
Declare PtrSafe Function RpcNsProfileEltAddA Lib "rpcns4" ( _
    ByVal ProfileNameSyntax As Long, _
    ByVal ProfileName As String, _
    ByVal IfId As LongPtr, _
    ByVal MemberNameSyntax As Long, _
    ByVal MemberName As String, _
    ByVal Priority As Long, _
    ByVal Annotation As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

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

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

var (
	rpcns4 = windows.NewLazySystemDLL("RPCNS4.dll")
	procRpcNsProfileEltAddA = rpcns4.NewProc("RpcNsProfileEltAddA")
)

// ProfileNameSyntax (DWORD), ProfileName (LPSTR), IfId (RPC_IF_ID* optional), MemberNameSyntax (DWORD), MemberName (LPSTR), Priority (DWORD), Annotation (LPSTR optional)
r1, _, err := procRpcNsProfileEltAddA.Call(
	uintptr(ProfileNameSyntax),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(ProfileName))),
	uintptr(IfId),
	uintptr(MemberNameSyntax),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(MemberName))),
	uintptr(Priority),
	uintptr(unsafe.Pointer(windows.BytePtrFromString(Annotation))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function RpcNsProfileEltAddA(
  ProfileNameSyntax: DWORD;   // DWORD
  ProfileName: PAnsiChar;   // LPSTR
  IfId: Pointer;   // RPC_IF_ID* optional
  MemberNameSyntax: DWORD;   // DWORD
  MemberName: PAnsiChar;   // LPSTR
  Priority: DWORD;   // DWORD
  Annotation: PAnsiChar   // LPSTR optional
): Integer; stdcall;
  external 'RPCNS4.dll' name 'RpcNsProfileEltAddA';
result := DllCall("RPCNS4\RpcNsProfileEltAddA"
    , "UInt", ProfileNameSyntax   ; DWORD
    , "AStr", ProfileName   ; LPSTR
    , "Ptr", IfId   ; RPC_IF_ID* optional
    , "UInt", MemberNameSyntax   ; DWORD
    , "AStr", MemberName   ; LPSTR
    , "UInt", Priority   ; DWORD
    , "AStr", Annotation   ; LPSTR optional
    , "Int")   ; return: RPC_STATUS
●RpcNsProfileEltAddA(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation) = DLL("RPCNS4.dll", "int RpcNsProfileEltAddA(dword, char*, void*, dword, char*, dword, char*)")
# 呼び出し: RpcNsProfileEltAddA(ProfileNameSyntax, ProfileName, IfId, MemberNameSyntax, MemberName, Priority, Annotation)
# ProfileNameSyntax : DWORD -> "dword"
# ProfileName : LPSTR -> "char*"
# IfId : RPC_IF_ID* optional -> "void*"
# MemberNameSyntax : DWORD -> "dword"
# MemberName : LPSTR -> "char*"
# Priority : DWORD -> "dword"
# Annotation : LPSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。