ホーム › System.Rpc › RpcNsProfileDeleteA
RpcNsProfileDeleteA
関数ネームサービスからプロファイルエントリを削除する(ANSI版)。
シグネチャ
// RPCNS4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcNsProfileDeleteA(
DWORD ProfileNameSyntax,
LPSTR ProfileName
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| ProfileNameSyntax | DWORD | in | ProfileNameの名前構文を指定するDWORD。0で既定構文を使用する。 |
| ProfileName | LPSTR | in | 削除するRPCプロファイルのエントリ名(ANSI文字列)。 |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCNS4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS RpcNsProfileDeleteA(
DWORD ProfileNameSyntax,
LPSTR ProfileName
);[DllImport("RPCNS4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int RpcNsProfileDeleteA(
uint ProfileNameSyntax, // DWORD
[MarshalAs(UnmanagedType.LPStr)] string ProfileName // LPSTR
);<DllImport("RPCNS4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function RpcNsProfileDeleteA(
ProfileNameSyntax As UInteger, ' DWORD
<MarshalAs(UnmanagedType.LPStr)> ProfileName As String ' LPSTR
) As Integer
End Function' ProfileNameSyntax : DWORD
' ProfileName : LPSTR
Declare PtrSafe Function RpcNsProfileDeleteA Lib "rpcns4" ( _
ByVal ProfileNameSyntax As Long, _
ByVal ProfileName As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
RpcNsProfileDeleteA = ctypes.windll.rpcns4.RpcNsProfileDeleteA
RpcNsProfileDeleteA.restype = ctypes.c_int
RpcNsProfileDeleteA.argtypes = [
wintypes.DWORD, # ProfileNameSyntax : DWORD
wintypes.LPCSTR, # ProfileName : LPSTR
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCNS4.dll')
RpcNsProfileDeleteA = Fiddle::Function.new(
lib['RpcNsProfileDeleteA'],
[
-Fiddle::TYPE_INT, # ProfileNameSyntax : DWORD
Fiddle::TYPE_VOIDP, # ProfileName : LPSTR
],
Fiddle::TYPE_INT)#[link(name = "rpcns4")]
extern "system" {
fn RpcNsProfileDeleteA(
ProfileNameSyntax: u32, // DWORD
ProfileName: *mut u8 // LPSTR
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCNS4.dll", CharSet = CharSet.Ansi)]
public static extern int RpcNsProfileDeleteA(uint ProfileNameSyntax, [MarshalAs(UnmanagedType.LPStr)] string ProfileName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCNS4_RpcNsProfileDeleteA' -Namespace Win32 -PassThru
# $api::RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)#uselib "RPCNS4.dll"
#func global RpcNsProfileDeleteA "RpcNsProfileDeleteA" sptr, sptr
; RpcNsProfileDeleteA ProfileNameSyntax, ProfileName ; 戻り値は stat
; ProfileNameSyntax : DWORD -> "sptr"
; ProfileName : LPSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "RPCNS4.dll"
#cfunc global RpcNsProfileDeleteA "RpcNsProfileDeleteA" int, str
; res = RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)
; ProfileNameSyntax : DWORD -> "int"
; ProfileName : LPSTR -> "str"; RPC_STATUS RpcNsProfileDeleteA(DWORD ProfileNameSyntax, LPSTR ProfileName)
#uselib "RPCNS4.dll"
#cfunc global RpcNsProfileDeleteA "RpcNsProfileDeleteA" int, str
; res = RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)
; ProfileNameSyntax : DWORD -> "int"
; ProfileName : LPSTR -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcns4 = windows.NewLazySystemDLL("RPCNS4.dll")
procRpcNsProfileDeleteA = rpcns4.NewProc("RpcNsProfileDeleteA")
)
// ProfileNameSyntax (DWORD), ProfileName (LPSTR)
r1, _, err := procRpcNsProfileDeleteA.Call(
uintptr(ProfileNameSyntax),
uintptr(unsafe.Pointer(windows.BytePtrFromString(ProfileName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction RpcNsProfileDeleteA(
ProfileNameSyntax: DWORD; // DWORD
ProfileName: PAnsiChar // LPSTR
): Integer; stdcall;
external 'RPCNS4.dll' name 'RpcNsProfileDeleteA';result := DllCall("RPCNS4\RpcNsProfileDeleteA"
, "UInt", ProfileNameSyntax ; DWORD
, "AStr", ProfileName ; LPSTR
, "Int") ; return: RPC_STATUS●RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName) = DLL("RPCNS4.dll", "int RpcNsProfileDeleteA(dword, char*)")
# 呼び出し: RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)
# ProfileNameSyntax : DWORD -> "dword"
# ProfileName : LPSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "rpcns4" fn RpcNsProfileDeleteA(
ProfileNameSyntax: u32, // DWORD
ProfileName: [*c]const u8 // LPSTR
) callconv(std.os.windows.WINAPI) i32;proc RpcNsProfileDeleteA(
ProfileNameSyntax: uint32, # DWORD
ProfileName: cstring # LPSTR
): int32 {.importc: "RpcNsProfileDeleteA", stdcall, dynlib: "RPCNS4.dll".}pragma(lib, "rpcns4");
extern(Windows)
int RpcNsProfileDeleteA(
uint ProfileNameSyntax, // DWORD
const(char)* ProfileName // LPSTR
);ccall((:RpcNsProfileDeleteA, "RPCNS4.dll"), stdcall, Int32,
(UInt32, Cstring),
ProfileNameSyntax, ProfileName)
# ProfileNameSyntax : DWORD -> UInt32
# ProfileName : LPSTR -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t RpcNsProfileDeleteA(
uint32_t ProfileNameSyntax,
const char* ProfileName);
]]
local rpcns4 = ffi.load("rpcns4")
-- rpcns4.RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)
-- ProfileNameSyntax : DWORD
-- ProfileName : LPSTR
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('RPCNS4.dll');
const RpcNsProfileDeleteA = lib.func('__stdcall', 'RpcNsProfileDeleteA', 'int32_t', ['uint32_t', 'str']);
// RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)
// ProfileNameSyntax : DWORD -> 'uint32_t'
// ProfileName : LPSTR -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("RPCNS4.dll", {
RpcNsProfileDeleteA: { parameters: ["u32", "buffer"], result: "i32" },
});
// lib.symbols.RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName)
// ProfileNameSyntax : DWORD -> "u32"
// ProfileName : LPSTR -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t RpcNsProfileDeleteA(
uint32_t ProfileNameSyntax,
const char* ProfileName);
C, "RPCNS4.dll");
// $ffi->RpcNsProfileDeleteA(ProfileNameSyntax, ProfileName);
// ProfileNameSyntax : DWORD
// ProfileName : LPSTR
// 構造体/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 Rpcns4 extends StdCallLibrary {
Rpcns4 INSTANCE = Native.load("rpcns4", Rpcns4.class, W32APIOptions.ASCII_OPTIONS);
int RpcNsProfileDeleteA(
int ProfileNameSyntax, // DWORD
String ProfileName // LPSTR
);
}@[Link("rpcns4")]
lib LibRPCNS4
fun RpcNsProfileDeleteA = RpcNsProfileDeleteA(
ProfileNameSyntax : UInt32, # DWORD
ProfileName : UInt8* # LPSTR
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef RpcNsProfileDeleteANative = Int32 Function(Uint32, Pointer<Utf8>);
typedef RpcNsProfileDeleteADart = int Function(int, Pointer<Utf8>);
final RpcNsProfileDeleteA = DynamicLibrary.open('RPCNS4.dll')
.lookupFunction<RpcNsProfileDeleteANative, RpcNsProfileDeleteADart>('RpcNsProfileDeleteA');
// ProfileNameSyntax : DWORD -> Uint32
// ProfileName : LPSTR -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function RpcNsProfileDeleteA(
ProfileNameSyntax: DWORD; // DWORD
ProfileName: PAnsiChar // LPSTR
): Integer; stdcall;
external 'RPCNS4.dll' name 'RpcNsProfileDeleteA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "RpcNsProfileDeleteA"
c_RpcNsProfileDeleteA :: Word32 -> CString -> IO Int32
-- ProfileNameSyntax : DWORD -> Word32
-- ProfileName : LPSTR -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let rpcnsprofiledeletea =
foreign "RpcNsProfileDeleteA"
(uint32_t @-> string @-> returning int32_t)
(* ProfileNameSyntax : DWORD -> uint32_t *)
(* ProfileName : LPSTR -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library rpcns4 (t "RPCNS4.dll"))
(cffi:use-foreign-library rpcns4)
(cffi:defcfun ("RpcNsProfileDeleteA" rpc-ns-profile-delete-a :convention :stdcall) :int32
(profile-name-syntax :uint32) ; DWORD
(profile-name :string)) ; LPSTR
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $RpcNsProfileDeleteA = Win32::API::More->new('RPCNS4',
'int RpcNsProfileDeleteA(DWORD ProfileNameSyntax, LPCSTR ProfileName)');
# my $ret = $RpcNsProfileDeleteA->Call($ProfileNameSyntax, $ProfileName);
# ProfileNameSyntax : DWORD -> DWORD
# ProfileName : LPSTR -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f RpcNsProfileDeleteW (Unicode版) — ネームサービスからプロファイルエントリを削除する(Unicode版)。
使用する型