PathQualify
関数相対パスを完全修飾パスに正規化する。
シグネチャ
// SHELL32.dll
#include <windows.h>
void PathQualify(
LPWSTR psz
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| psz | LPWSTR | inout | 完全修飾化する対象のパス文字列。その場で書き換えられる入出力兼用バッファ。 |
戻り値の型: void
各言語での呼び出し定義
// SHELL32.dll
#include <windows.h>
void PathQualify(
LPWSTR psz
);[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern void PathQualify(
[MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psz // LPWSTR in/out
);<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Sub PathQualify(
<MarshalAs(UnmanagedType.LPWStr)> psz As System.Text.StringBuilder ' LPWSTR in/out
)
End Sub' psz : LPWSTR in/out
Declare PtrSafe Sub PathQualify Lib "shell32" ( _
ByVal psz As LongPtr)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PathQualify = ctypes.windll.shell32.PathQualify
PathQualify.restype = None
PathQualify.argtypes = [
wintypes.LPWSTR, # psz : LPWSTR in/out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
PathQualify = Fiddle::Function.new(
lib['PathQualify'],
[
Fiddle::TYPE_VOIDP, # psz : LPWSTR in/out
],
Fiddle::TYPE_VOID)#[link(name = "shell32")]
extern "system" {
fn PathQualify(
psz: *mut u16 // LPWSTR in/out
);
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("SHELL32.dll")]
public static extern void PathQualify([MarshalAs(UnmanagedType.LPWStr)] System.Text.StringBuilder psz);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_PathQualify' -Namespace Win32 -PassThru
# $api::PathQualify(psz)#uselib "SHELL32.dll"
#func global PathQualify "PathQualify" sptr
; PathQualify varptr(psz)
; psz : LPWSTR in/out -> "sptr"出力引数:
#uselib "SHELL32.dll" #func global PathQualify "PathQualify" var ; PathQualify psz ; psz : LPWSTR in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "SHELL32.dll" #func global PathQualify "PathQualify" sptr ; PathQualify varptr(psz) ; psz : LPWSTR in/out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; void PathQualify(LPWSTR psz) #uselib "SHELL32.dll" #func global PathQualify "PathQualify" var ; PathQualify psz ; psz : LPWSTR in/out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; void PathQualify(LPWSTR psz) #uselib "SHELL32.dll" #func global PathQualify "PathQualify" intptr ; PathQualify varptr(psz) ; psz : LPWSTR in/out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procPathQualify = shell32.NewProc("PathQualify")
)
// psz (LPWSTR in/out)
r1, _, err := procPathQualify.Call(
uintptr(psz),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // voidprocedure PathQualify(
psz: PWideChar // LPWSTR in/out
); stdcall;
external 'SHELL32.dll' name 'PathQualify';result := DllCall("SHELL32\PathQualify"
, "Ptr", psz ; LPWSTR in/out
, "Int") ; return: void●PathQualify(psz) = DLL("SHELL32.dll", "int PathQualify(char*)")
# 呼び出し: PathQualify(psz)
# psz : LPWSTR in/out -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn PathQualify(
psz: [*c]u16 // LPWSTR in/out
) callconv(std.os.windows.WINAPI) void;proc PathQualify(
psz: ptr uint16 # LPWSTR in/out
) {.importc: "PathQualify", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
void PathQualify(
wchar* psz // LPWSTR in/out
);ccall((:PathQualify, "SHELL32.dll"), stdcall, Cvoid,
(Ptr{UInt16},),
psz)
# psz : LPWSTR in/out -> Ptr{UInt16}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
void PathQualify(
uint16_t* psz);
]]
local shell32 = ffi.load("shell32")
-- shell32.PathQualify(psz)
-- psz : LPWSTR in/out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const PathQualify = lib.func('__stdcall', 'PathQualify', 'void', ['uint16_t *']);
// PathQualify(psz)
// psz : LPWSTR in/out -> 'uint16_t *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
PathQualify: { parameters: ["buffer"], result: "void" },
});
// lib.symbols.PathQualify(psz)
// psz : LPWSTR in/out -> "buffer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
void PathQualify(
uint16_t* psz);
C, "SHELL32.dll");
// $ffi->PathQualify(psz);
// psz : LPWSTR in/out
// 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
// WINAPI(stdcall): x64 では呼出規約が統一されるため問題なし。x86 では __stdcall 対応のラッパが必要な場合あり。import com.sun.jna.*;
import com.sun.jna.ptr.*;
import com.sun.jna.win32.StdCallLibrary;
import com.sun.jna.win32.W32APIOptions;
public interface Shell32 extends StdCallLibrary {
Shell32 INSTANCE = Native.load("shell32", Shell32.class);
void PathQualify(
char[] psz // LPWSTR in/out
);
}@[Link("shell32")]
lib LibSHELL32
fun PathQualify = PathQualify(
psz : UInt16* # LPWSTR in/out
) : Void
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef PathQualifyNative = Void Function(Pointer<Utf16>);
typedef PathQualifyDart = void Function(Pointer<Utf16>);
final PathQualify = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<PathQualifyNative, PathQualifyDart>('PathQualify');
// psz : LPWSTR in/out -> Pointer<Utf16>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
procedure PathQualify(
psz: PWideChar // LPWSTR in/out
); stdcall;
external 'SHELL32.dll' name 'PathQualify';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PathQualify"
c_PathQualify :: CWString -> IO ()
-- psz : LPWSTR in/out -> CWString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pathqualify =
foreign "PathQualify"
((ptr uint16_t) @-> returning void)
(* psz : LPWSTR in/out -> (ptr uint16_t) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("PathQualify" path-qualify :convention :stdcall) :void
(psz :pointer)) ; LPWSTR in/out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PathQualify = Win32::API::More->new('SHELL32',
'void PathQualify(LPWSTR psz)');
# my $ret = $PathQualify->Call($psz);
# psz : LPWSTR in/out -> LPWSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。