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

UuidToStringA

関数
UUIDをANSI文字列形式に変換する。
DLLRPCRT4.dll文字セットANSI (-A)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

RPC_STATUS UuidToStringA(
    const GUID* Uuid,
    LPSTR* StringUuid
);

パラメーター

名前方向
UuidGUID*in
StringUuidLPSTR*out

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS UuidToStringA(
    const GUID* Uuid,
    LPSTR* StringUuid
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int UuidToStringA(
    ref Guid Uuid,   // GUID*
    IntPtr StringUuid   // LPSTR* out
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function UuidToStringA(
    ByRef Uuid As Guid,   ' GUID*
    StringUuid As IntPtr   ' LPSTR* out
) As Integer
End Function
' Uuid : GUID*
' StringUuid : LPSTR* out
Declare PtrSafe Function UuidToStringA Lib "rpcrt4" ( _
    ByVal Uuid As LongPtr, _
    ByVal StringUuid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

UuidToStringA = ctypes.windll.rpcrt4.UuidToStringA
UuidToStringA.restype = ctypes.c_int
UuidToStringA.argtypes = [
    ctypes.c_void_p,  # Uuid : GUID*
    ctypes.c_void_p,  # StringUuid : LPSTR* out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('RPCRT4.dll')
UuidToStringA = Fiddle::Function.new(
  lib['UuidToStringA'],
  [
    Fiddle::TYPE_VOIDP,  # Uuid : GUID*
    Fiddle::TYPE_VOIDP,  # StringUuid : LPSTR* out
  ],
  Fiddle::TYPE_INT)
#[link(name = "rpcrt4")]
extern "system" {
    fn UuidToStringA(
        Uuid: *const GUID,  // GUID*
        StringUuid: *mut *mut u8  // LPSTR* out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi)]
public static extern int UuidToStringA(ref Guid Uuid, IntPtr StringUuid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_UuidToStringA' -Namespace Win32 -PassThru
# $api::UuidToStringA(Uuid, StringUuid)
#uselib "RPCRT4.dll"
#func global UuidToStringA "UuidToStringA" sptr, sptr
; UuidToStringA varptr(Uuid), varptr(StringUuid)   ; 戻り値は stat
; Uuid : GUID* -> "sptr"
; StringUuid : LPSTR* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "RPCRT4.dll"
#cfunc global UuidToStringA "UuidToStringA" var, var
; res = UuidToStringA(Uuid, StringUuid)
; Uuid : GUID* -> "var"
; StringUuid : LPSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; RPC_STATUS UuidToStringA(GUID* Uuid, LPSTR* StringUuid)
#uselib "RPCRT4.dll"
#cfunc global UuidToStringA "UuidToStringA" var, var
; res = UuidToStringA(Uuid, StringUuid)
; Uuid : GUID* -> "var"
; StringUuid : LPSTR* out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procUuidToStringA = rpcrt4.NewProc("UuidToStringA")
)

// Uuid (GUID*), StringUuid (LPSTR* out)
r1, _, err := procUuidToStringA.Call(
	uintptr(Uuid),
	uintptr(StringUuid),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // RPC_STATUS
function UuidToStringA(
  Uuid: PGUID;   // GUID*
  StringUuid: PPAnsiChar   // LPSTR* out
): Integer; stdcall;
  external 'RPCRT4.dll' name 'UuidToStringA';
result := DllCall("RPCRT4\UuidToStringA"
    , "Ptr", Uuid   ; GUID*
    , "Ptr", StringUuid   ; LPSTR* out
    , "Int")   ; return: RPC_STATUS
●UuidToStringA(Uuid, StringUuid) = DLL("RPCRT4.dll", "int UuidToStringA(void*, void*)")
# 呼び出し: UuidToStringA(Uuid, StringUuid)
# Uuid : GUID* -> "void*"
# StringUuid : LPSTR* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。