Win32 API 日本語リファレンス
ホームUI.Shell › SHLoadIndirectString

SHLoadIndirectString

関数
リソース参照形式の間接文字列を読み込んで展開する。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

// SHLWAPI.dll
#include <windows.h>

HRESULT SHLoadIndirectString(
    LPCWSTR pszSource,
    LPWSTR pszOutBuf,
    DWORD cchOutBuf,
    void** ppvReserved   // optional
);

パラメーター

名前方向
pszSourceLPCWSTRin
pszOutBufLPWSTRout
cchOutBufDWORDin
ppvReservedvoid**optional

戻り値の型: HRESULT

各言語での呼び出し定義

// SHLWAPI.dll
#include <windows.h>

HRESULT SHLoadIndirectString(
    LPCWSTR pszSource,
    LPWSTR pszOutBuf,
    DWORD cchOutBuf,
    void** ppvReserved   // optional
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern int SHLoadIndirectString(
    [MarshalAs(UnmanagedType.LPWStr)] string pszSource,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder pszOutBuf,   // LPWSTR out
    uint cchOutBuf,   // DWORD
    IntPtr ppvReserved   // void** optional
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function SHLoadIndirectString(
    <MarshalAs(UnmanagedType.LPWStr)> pszSource As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pszOutBuf As System.Text.StringBuilder,   ' LPWSTR out
    cchOutBuf As UInteger,   ' DWORD
    ppvReserved As IntPtr   ' void** optional
) As Integer
End Function
' pszSource : LPCWSTR
' pszOutBuf : LPWSTR out
' cchOutBuf : DWORD
' ppvReserved : void** optional
Declare PtrSafe Function SHLoadIndirectString Lib "shlwapi" ( _
    ByVal pszSource As LongPtr, _
    ByVal pszOutBuf As LongPtr, _
    ByVal cchOutBuf As Long, _
    ByVal ppvReserved As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHLoadIndirectString = ctypes.windll.shlwapi.SHLoadIndirectString
SHLoadIndirectString.restype = ctypes.c_int
SHLoadIndirectString.argtypes = [
    wintypes.LPCWSTR,  # pszSource : LPCWSTR
    wintypes.LPWSTR,  # pszOutBuf : LPWSTR out
    wintypes.DWORD,  # cchOutBuf : DWORD
    ctypes.c_void_p,  # ppvReserved : void** optional
]
require 'fiddle'
require 'fiddle/import'

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

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procSHLoadIndirectString = shlwapi.NewProc("SHLoadIndirectString")
)

// pszSource (LPCWSTR), pszOutBuf (LPWSTR out), cchOutBuf (DWORD), ppvReserved (void** optional)
r1, _, err := procSHLoadIndirectString.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszSource))),
	uintptr(pszOutBuf),
	uintptr(cchOutBuf),
	uintptr(ppvReserved),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SHLoadIndirectString(
  pszSource: PWideChar;   // LPCWSTR
  pszOutBuf: PWideChar;   // LPWSTR out
  cchOutBuf: DWORD;   // DWORD
  ppvReserved: Pointer   // void** optional
): Integer; stdcall;
  external 'SHLWAPI.dll' name 'SHLoadIndirectString';
result := DllCall("SHLWAPI\SHLoadIndirectString"
    , "WStr", pszSource   ; LPCWSTR
    , "Ptr", pszOutBuf   ; LPWSTR out
    , "UInt", cchOutBuf   ; DWORD
    , "Ptr", ppvReserved   ; void** optional
    , "Int")   ; return: HRESULT
●SHLoadIndirectString(pszSource, pszOutBuf, cchOutBuf, ppvReserved) = DLL("SHLWAPI.dll", "int SHLoadIndirectString(char*, char*, dword, void*)")
# 呼び出し: SHLoadIndirectString(pszSource, pszOutBuf, cchOutBuf, ppvReserved)
# pszSource : LPCWSTR -> "char*"
# pszOutBuf : LPWSTR out -> "char*"
# cchOutBuf : DWORD -> "dword"
# ppvReserved : void** optional -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。