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

UuidFromStringW

関数
Unicode文字列をUUID構造体に変換する。
DLLRPCRT4.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

RPC_STATUS UuidFromStringW(
    LPWSTR StringUuid,   // optional
    GUID* Uuid
);

パラメーター

名前方向
StringUuidLPWSTRinoptional
UuidGUID*out

戻り値の型: RPC_STATUS

各言語での呼び出し定義

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

RPC_STATUS UuidFromStringW(
    LPWSTR StringUuid,   // optional
    GUID* Uuid
);
[DllImport("RPCRT4.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int UuidFromStringW(
    [MarshalAs(UnmanagedType.LPWStr)] string StringUuid,   // LPWSTR optional
    out Guid Uuid   // GUID* out
);
<DllImport("RPCRT4.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function UuidFromStringW(
    <MarshalAs(UnmanagedType.LPWStr)> StringUuid As String,   ' LPWSTR optional
    <Out> ByRef Uuid As Guid   ' GUID* out
) As Integer
End Function
' StringUuid : LPWSTR optional
' Uuid : GUID* out
Declare PtrSafe Function UuidFromStringW Lib "rpcrt4" ( _
    ByVal StringUuid As LongPtr, _
    ByVal Uuid 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

UuidFromStringW = ctypes.windll.rpcrt4.UuidFromStringW
UuidFromStringW.restype = ctypes.c_int
UuidFromStringW.argtypes = [
    wintypes.LPCWSTR,  # StringUuid : LPWSTR optional
    ctypes.c_void_p,  # Uuid : GUID* out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
	procUuidFromStringW = rpcrt4.NewProc("UuidFromStringW")
)

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