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

GetApiSetModuleBaseName

関数
APIセット契約名から実装モジュールの基底名を取得する。
DLLapi-ms-win-core-apiquery-l2-1-1.dll呼出規約winapi

シグネチャ

// api-ms-win-core-apiquery-l2-1-1.dll
#include <windows.h>

HRESULT GetApiSetModuleBaseName(
    LPCSTR contractName,
    DWORD bufferLength,
    LPWSTR moduleBaseName,
    DWORD* actualNameLength   // optional
);

パラメーター

名前方向
contractNameLPCSTRin
bufferLengthDWORDin
moduleBaseNameLPWSTRout
actualNameLengthDWORD*outoptional

戻り値の型: HRESULT

各言語での呼び出し定義

// api-ms-win-core-apiquery-l2-1-1.dll
#include <windows.h>

HRESULT GetApiSetModuleBaseName(
    LPCSTR contractName,
    DWORD bufferLength,
    LPWSTR moduleBaseName,
    DWORD* actualNameLength   // optional
);
[DllImport("api-ms-win-core-apiquery-l2-1-1.dll", ExactSpelling = true)]
static extern int GetApiSetModuleBaseName(
    [MarshalAs(UnmanagedType.LPStr)] string contractName,   // LPCSTR
    uint bufferLength,   // DWORD
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder moduleBaseName,   // LPWSTR out
    IntPtr actualNameLength   // DWORD* optional, out
);
<DllImport("api-ms-win-core-apiquery-l2-1-1.dll", ExactSpelling:=True)>
Public Shared Function GetApiSetModuleBaseName(
    <MarshalAs(UnmanagedType.LPStr)> contractName As String,   ' LPCSTR
    bufferLength As UInteger,   ' DWORD
    <MarshalAs(UnmanagedType.LPWStr)> moduleBaseName As System.Text.StringBuilder,   ' LPWSTR out
    actualNameLength As IntPtr   ' DWORD* optional, out
) As Integer
End Function
' contractName : LPCSTR
' bufferLength : DWORD
' moduleBaseName : LPWSTR out
' actualNameLength : DWORD* optional, out
Declare PtrSafe Function GetApiSetModuleBaseName Lib "api-ms-win-core-apiquery-l2-1-1" ( _
    ByVal contractName As String, _
    ByVal bufferLength As Long, _
    ByVal moduleBaseName As LongPtr, _
    ByVal actualNameLength As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

GetApiSetModuleBaseName = ctypes.windll.LoadLibrary("api-ms-win-core-apiquery-l2-1-1.dll").GetApiSetModuleBaseName
GetApiSetModuleBaseName.restype = ctypes.c_int
GetApiSetModuleBaseName.argtypes = [
    wintypes.LPCSTR,  # contractName : LPCSTR
    wintypes.DWORD,  # bufferLength : DWORD
    wintypes.LPWSTR,  # moduleBaseName : LPWSTR out
    ctypes.POINTER(wintypes.DWORD),  # actualNameLength : DWORD* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('api-ms-win-core-apiquery-l2-1-1.dll')
GetApiSetModuleBaseName = Fiddle::Function.new(
  lib['GetApiSetModuleBaseName'],
  [
    Fiddle::TYPE_VOIDP,  # contractName : LPCSTR
    -Fiddle::TYPE_INT,  # bufferLength : DWORD
    Fiddle::TYPE_VOIDP,  # moduleBaseName : LPWSTR out
    Fiddle::TYPE_VOIDP,  # actualNameLength : DWORD* optional, out
  ],
  Fiddle::TYPE_INT)
#[link(name = "api-ms-win-core-apiquery-l2-1-1")]
extern "system" {
    fn GetApiSetModuleBaseName(
        contractName: *const u8,  // LPCSTR
        bufferLength: u32,  // DWORD
        moduleBaseName: *mut u16,  // LPWSTR out
        actualNameLength: *mut u32  // DWORD* optional, out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("api-ms-win-core-apiquery-l2-1-1.dll")]
public static extern int GetApiSetModuleBaseName([MarshalAs(UnmanagedType.LPStr)] string contractName, uint bufferLength, [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder moduleBaseName, IntPtr actualNameLength);
"@
$api = Add-Type -MemberDefinition $sig -Name 'api-ms-win-core-apiquery-l2-1-1_GetApiSetModuleBaseName' -Namespace Win32 -PassThru
# $api::GetApiSetModuleBaseName(contractName, bufferLength, moduleBaseName, actualNameLength)
#uselib "api-ms-win-core-apiquery-l2-1-1.dll"
#func global GetApiSetModuleBaseName "GetApiSetModuleBaseName" sptr, sptr, sptr, sptr
; GetApiSetModuleBaseName contractName, bufferLength, varptr(moduleBaseName), varptr(actualNameLength)   ; 戻り値は stat
; contractName : LPCSTR -> "sptr"
; bufferLength : DWORD -> "sptr"
; moduleBaseName : LPWSTR out -> "sptr"
; actualNameLength : DWORD* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "api-ms-win-core-apiquery-l2-1-1.dll"
#cfunc global GetApiSetModuleBaseName "GetApiSetModuleBaseName" str, int, var, var
; res = GetApiSetModuleBaseName(contractName, bufferLength, moduleBaseName, actualNameLength)
; contractName : LPCSTR -> "str"
; bufferLength : DWORD -> "int"
; moduleBaseName : LPWSTR out -> "var"
; actualNameLength : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT GetApiSetModuleBaseName(LPCSTR contractName, DWORD bufferLength, LPWSTR moduleBaseName, DWORD* actualNameLength)
#uselib "api-ms-win-core-apiquery-l2-1-1.dll"
#cfunc global GetApiSetModuleBaseName "GetApiSetModuleBaseName" str, int, var, var
; res = GetApiSetModuleBaseName(contractName, bufferLength, moduleBaseName, actualNameLength)
; contractName : LPCSTR -> "str"
; bufferLength : DWORD -> "int"
; moduleBaseName : LPWSTR out -> "var"
; actualNameLength : DWORD* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	api_ms_win_core_apiquery_l2_1_1 = windows.NewLazySystemDLL("api-ms-win-core-apiquery-l2-1-1.dll")
	procGetApiSetModuleBaseName = api_ms_win_core_apiquery_l2_1_1.NewProc("GetApiSetModuleBaseName")
)

// contractName (LPCSTR), bufferLength (DWORD), moduleBaseName (LPWSTR out), actualNameLength (DWORD* optional, out)
r1, _, err := procGetApiSetModuleBaseName.Call(
	uintptr(unsafe.Pointer(windows.BytePtrFromString(contractName))),
	uintptr(bufferLength),
	uintptr(moduleBaseName),
	uintptr(actualNameLength),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function GetApiSetModuleBaseName(
  contractName: PAnsiChar;   // LPCSTR
  bufferLength: DWORD;   // DWORD
  moduleBaseName: PWideChar;   // LPWSTR out
  actualNameLength: Pointer   // DWORD* optional, out
): Integer; stdcall;
  external 'api-ms-win-core-apiquery-l2-1-1.dll' name 'GetApiSetModuleBaseName';
result := DllCall("api-ms-win-core-apiquery-l2-1-1\GetApiSetModuleBaseName"
    , "AStr", contractName   ; LPCSTR
    , "UInt", bufferLength   ; DWORD
    , "Ptr", moduleBaseName   ; LPWSTR out
    , "Ptr", actualNameLength   ; DWORD* optional, out
    , "Int")   ; return: HRESULT
●GetApiSetModuleBaseName(contractName, bufferLength, moduleBaseName, actualNameLength) = DLL("api-ms-win-core-apiquery-l2-1-1.dll", "int GetApiSetModuleBaseName(char*, dword, char*, void*)")
# 呼び出し: GetApiSetModuleBaseName(contractName, bufferLength, moduleBaseName, actualNameLength)
# contractName : LPCSTR -> "char*"
# bufferLength : DWORD -> "dword"
# moduleBaseName : LPWSTR out -> "char*"
# actualNameLength : DWORD* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。