ホーム › System.Rpc › UuidFromStringA
UuidFromStringA
関数ANSI文字列をUUID構造体に変換する。
シグネチャ
// RPCRT4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS UuidFromStringA(
LPSTR StringUuid, // optional
GUID* Uuid
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| StringUuid | LPSTR | inoptional |
| Uuid | GUID* | out |
戻り値の型: RPC_STATUS
各言語での呼び出し定義
// RPCRT4.dll (ANSI / -A)
#include <windows.h>
RPC_STATUS UuidFromStringA(
LPSTR StringUuid, // optional
GUID* Uuid
);[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern int UuidFromStringA(
[MarshalAs(UnmanagedType.LPStr)] string StringUuid, // LPSTR optional
out Guid Uuid // GUID* out
);<DllImport("RPCRT4.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function UuidFromStringA(
<MarshalAs(UnmanagedType.LPStr)> StringUuid As String, ' LPSTR optional
<Out> ByRef Uuid As Guid ' GUID* out
) As Integer
End Function' StringUuid : LPSTR optional
' Uuid : GUID* out
Declare PtrSafe Function UuidFromStringA Lib "rpcrt4" ( _
ByVal StringUuid As String, _
ByVal Uuid As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
UuidFromStringA = ctypes.windll.rpcrt4.UuidFromStringA
UuidFromStringA.restype = ctypes.c_int
UuidFromStringA.argtypes = [
wintypes.LPCSTR, # StringUuid : LPSTR optional
ctypes.c_void_p, # Uuid : GUID* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('RPCRT4.dll')
UuidFromStringA = Fiddle::Function.new(
lib['UuidFromStringA'],
[
Fiddle::TYPE_VOIDP, # StringUuid : LPSTR optional
Fiddle::TYPE_VOIDP, # Uuid : GUID* out
],
Fiddle::TYPE_INT)#[link(name = "rpcrt4")]
extern "system" {
fn UuidFromStringA(
StringUuid: *mut u8, // LPSTR optional
Uuid: *mut GUID // GUID* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("RPCRT4.dll", CharSet = CharSet.Ansi)]
public static extern int UuidFromStringA([MarshalAs(UnmanagedType.LPStr)] string StringUuid, out Guid Uuid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'RPCRT4_UuidFromStringA' -Namespace Win32 -PassThru
# $api::UuidFromStringA(StringUuid, Uuid)#uselib "RPCRT4.dll"
#func global UuidFromStringA "UuidFromStringA" sptr, sptr
; UuidFromStringA StringUuid, varptr(Uuid) ; 戻り値は stat
; StringUuid : LPSTR optional -> "sptr"
; Uuid : GUID* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "RPCRT4.dll" #cfunc global UuidFromStringA "UuidFromStringA" str, var ; res = UuidFromStringA(StringUuid, Uuid) ; StringUuid : LPSTR optional -> "str" ; Uuid : GUID* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "RPCRT4.dll" #cfunc global UuidFromStringA "UuidFromStringA" str, sptr ; res = UuidFromStringA(StringUuid, varptr(Uuid)) ; StringUuid : LPSTR optional -> "str" ; Uuid : GUID* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; RPC_STATUS UuidFromStringA(LPSTR StringUuid, GUID* Uuid) #uselib "RPCRT4.dll" #cfunc global UuidFromStringA "UuidFromStringA" str, var ; res = UuidFromStringA(StringUuid, Uuid) ; StringUuid : LPSTR optional -> "str" ; Uuid : GUID* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; RPC_STATUS UuidFromStringA(LPSTR StringUuid, GUID* Uuid) #uselib "RPCRT4.dll" #cfunc global UuidFromStringA "UuidFromStringA" str, intptr ; res = UuidFromStringA(StringUuid, varptr(Uuid)) ; StringUuid : LPSTR optional -> "str" ; Uuid : GUID* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
rpcrt4 = windows.NewLazySystemDLL("RPCRT4.dll")
procUuidFromStringA = rpcrt4.NewProc("UuidFromStringA")
)
// StringUuid (LPSTR optional), Uuid (GUID* out)
r1, _, err := procUuidFromStringA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(StringUuid))),
uintptr(Uuid),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // RPC_STATUSfunction UuidFromStringA(
StringUuid: PAnsiChar; // LPSTR optional
Uuid: PGUID // GUID* out
): Integer; stdcall;
external 'RPCRT4.dll' name 'UuidFromStringA';result := DllCall("RPCRT4\UuidFromStringA"
, "AStr", StringUuid ; LPSTR optional
, "Ptr", Uuid ; GUID* out
, "Int") ; return: RPC_STATUS●UuidFromStringA(StringUuid, Uuid) = DLL("RPCRT4.dll", "int UuidFromStringA(char*, void*)")
# 呼び出し: UuidFromStringA(StringUuid, Uuid)
# StringUuid : LPSTR optional -> "char*"
# Uuid : GUID* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。