Win32 API 日本語リファレンス
ホームStorage.FileSystem › GetExpandedNameW

GetExpandedNameW

関数
圧縮ファイルの元のファイル名を取得する(Unicode版)。
DLLKERNEL32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows XP 以降

シグネチャ

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

INT GetExpandedNameW(
    LPWSTR lpszSource,
    LPWSTR lpszBuffer
);

パラメーター

名前方向
lpszSourceLPWSTRin
lpszBufferLPWSTRout

戻り値の型: INT

各言語での呼び出し定義

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

INT GetExpandedNameW(
    LPWSTR lpszSource,
    LPWSTR lpszBuffer
);
[DllImport("KERNEL32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern int GetExpandedNameW(
    [MarshalAs(UnmanagedType.LPWStr)] string lpszSource,   // LPWSTR
    [MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder lpszBuffer   // LPWSTR out
);
<DllImport("KERNEL32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function GetExpandedNameW(
    <MarshalAs(UnmanagedType.LPWStr)> lpszSource As String,   ' LPWSTR
    <MarshalAs(UnmanagedType.LPWStr)> lpszBuffer As System.Text.StringBuilder   ' LPWSTR out
) As Integer
End Function
' lpszSource : LPWSTR
' lpszBuffer : LPWSTR out
Declare PtrSafe Function GetExpandedNameW Lib "kernel32" ( _
    ByVal lpszSource As LongPtr, _
    ByVal lpszBuffer 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

GetExpandedNameW = ctypes.windll.kernel32.GetExpandedNameW
GetExpandedNameW.restype = ctypes.c_int
GetExpandedNameW.argtypes = [
    wintypes.LPCWSTR,  # lpszSource : LPWSTR
    wintypes.LPWSTR,  # lpszBuffer : LPWSTR out
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	kernel32 = windows.NewLazySystemDLL("KERNEL32.dll")
	procGetExpandedNameW = kernel32.NewProc("GetExpandedNameW")
)

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