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

IStream_WriteStr

関数
文字列をストリームへ書き込む。
DLLSHLWAPI.dll呼出規約winapi対応OSWindows Vista 以降

シグネチャ

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

HRESULT IStream_WriteStr(
    IStream* pstm,
    LPCWSTR psz
);

パラメーター

名前方向
pstmIStream*in
pszLPCWSTRin

戻り値の型: HRESULT

各言語での呼び出し定義

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

HRESULT IStream_WriteStr(
    IStream* pstm,
    LPCWSTR psz
);
[DllImport("SHLWAPI.dll", ExactSpelling = true)]
static extern int IStream_WriteStr(
    IntPtr pstm,   // IStream*
    [MarshalAs(UnmanagedType.LPWStr)] string psz   // LPCWSTR
);
<DllImport("SHLWAPI.dll", ExactSpelling:=True)>
Public Shared Function IStream_WriteStr(
    pstm As IntPtr,   ' IStream*
    <MarshalAs(UnmanagedType.LPWStr)> psz As String   ' LPCWSTR
) As Integer
End Function
' pstm : IStream*
' psz : LPCWSTR
Declare PtrSafe Function IStream_WriteStr Lib "shlwapi" ( _
    ByVal pstm As LongPtr, _
    ByVal psz As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

IStream_WriteStr = ctypes.windll.shlwapi.IStream_WriteStr
IStream_WriteStr.restype = ctypes.c_int
IStream_WriteStr.argtypes = [
    ctypes.c_void_p,  # pstm : IStream*
    wintypes.LPCWSTR,  # psz : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHLWAPI.dll')
IStream_WriteStr = Fiddle::Function.new(
  lib['IStream_WriteStr'],
  [
    Fiddle::TYPE_VOIDP,  # pstm : IStream*
    Fiddle::TYPE_VOIDP,  # psz : LPCWSTR
  ],
  Fiddle::TYPE_INT)
#[link(name = "shlwapi")]
extern "system" {
    fn IStream_WriteStr(
        pstm: *mut core::ffi::c_void,  // IStream*
        psz: *const u16  // LPCWSTR
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHLWAPI.dll")]
public static extern int IStream_WriteStr(IntPtr pstm, [MarshalAs(UnmanagedType.LPWStr)] string psz);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHLWAPI_IStream_WriteStr' -Namespace Win32 -PassThru
# $api::IStream_WriteStr(pstm, psz)
#uselib "SHLWAPI.dll"
#func global IStream_WriteStr "IStream_WriteStr" sptr, sptr
; IStream_WriteStr pstm, psz   ; 戻り値は stat
; pstm : IStream* -> "sptr"
; psz : LPCWSTR -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHLWAPI.dll"
#cfunc global IStream_WriteStr "IStream_WriteStr" sptr, wstr
; res = IStream_WriteStr(pstm, psz)
; pstm : IStream* -> "sptr"
; psz : LPCWSTR -> "wstr"
; HRESULT IStream_WriteStr(IStream* pstm, LPCWSTR psz)
#uselib "SHLWAPI.dll"
#cfunc global IStream_WriteStr "IStream_WriteStr" intptr, wstr
; res = IStream_WriteStr(pstm, psz)
; pstm : IStream* -> "intptr"
; psz : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procIStream_WriteStr = shlwapi.NewProc("IStream_WriteStr")
)

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