IsLFNDriveA
関数ドライブが長いファイル名に対応しているか判定する。
シグネチャ
// SHELL32.dll (ANSI / -A)
#include <windows.h>
BOOL IsLFNDriveA(
LPCSTR pszPath // optional
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszPath | LPCSTR | inoptional | 判定対象のドライブまたはパス文字列。長いファイル名(LFN)対応か否かを調べる。 |
戻り値の型: BOOL
各言語での呼び出し定義
// SHELL32.dll (ANSI / -A)
#include <windows.h>
BOOL IsLFNDriveA(
LPCSTR pszPath // optional
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool IsLFNDriveA(
[MarshalAs(UnmanagedType.LPStr)] string pszPath // LPCSTR optional
);<DllImport("SHELL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function IsLFNDriveA(
<MarshalAs(UnmanagedType.LPStr)> pszPath As String ' LPCSTR optional
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pszPath : LPCSTR optional
Declare PtrSafe Function IsLFNDriveA Lib "shell32" ( _
ByVal pszPath As String) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
IsLFNDriveA = ctypes.windll.shell32.IsLFNDriveA
IsLFNDriveA.restype = wintypes.BOOL
IsLFNDriveA.argtypes = [
wintypes.LPCSTR, # pszPath : LPCSTR optional
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
IsLFNDriveA = Fiddle::Function.new(
lib['IsLFNDriveA'],
[
Fiddle::TYPE_VOIDP, # pszPath : LPCSTR optional
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn IsLFNDriveA(
pszPath: *const u8 // LPCSTR optional
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi)]
public static extern bool IsLFNDriveA([MarshalAs(UnmanagedType.LPStr)] string pszPath);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_IsLFNDriveA' -Namespace Win32 -PassThru
# $api::IsLFNDriveA(pszPath)#uselib "SHELL32.dll"
#func global IsLFNDriveA "IsLFNDriveA" sptr
; IsLFNDriveA pszPath ; 戻り値は stat
; pszPath : LPCSTR optional -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global IsLFNDriveA "IsLFNDriveA" str
; res = IsLFNDriveA(pszPath)
; pszPath : LPCSTR optional -> "str"; BOOL IsLFNDriveA(LPCSTR pszPath)
#uselib "SHELL32.dll"
#cfunc global IsLFNDriveA "IsLFNDriveA" str
; res = IsLFNDriveA(pszPath)
; pszPath : LPCSTR optional -> "str"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procIsLFNDriveA = shell32.NewProc("IsLFNDriveA")
)
// pszPath (LPCSTR optional)
r1, _, err := procIsLFNDriveA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszPath))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction IsLFNDriveA(
pszPath: PAnsiChar // LPCSTR optional
): BOOL; stdcall;
external 'SHELL32.dll' name 'IsLFNDriveA';result := DllCall("SHELL32\IsLFNDriveA"
, "AStr", pszPath ; LPCSTR optional
, "Int") ; return: BOOL●IsLFNDriveA(pszPath) = DLL("SHELL32.dll", "bool IsLFNDriveA(char*)")
# 呼び出し: IsLFNDriveA(pszPath)
# pszPath : LPCSTR optional -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn IsLFNDriveA(
pszPath: [*c]const u8 // LPCSTR optional
) callconv(std.os.windows.WINAPI) i32;proc IsLFNDriveA(
pszPath: cstring # LPCSTR optional
): int32 {.importc: "IsLFNDriveA", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int IsLFNDriveA(
const(char)* pszPath // LPCSTR optional
);ccall((:IsLFNDriveA, "SHELL32.dll"), stdcall, Int32,
(Cstring,),
pszPath)
# pszPath : LPCSTR optional -> Cstring
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t IsLFNDriveA(
const char* pszPath);
]]
local shell32 = ffi.load("shell32")
-- shell32.IsLFNDriveA(pszPath)
-- pszPath : LPCSTR optional
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const IsLFNDriveA = lib.func('__stdcall', 'IsLFNDriveA', 'int32_t', ['str']);
// IsLFNDriveA(pszPath)
// pszPath : LPCSTR optional -> 'str'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
IsLFNDriveA: { parameters: ["buffer"], result: "i32" },
});
// lib.symbols.IsLFNDriveA(pszPath)
// pszPath : LPCSTR optional -> "buffer"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t IsLFNDriveA(
const char* pszPath);
C, "SHELL32.dll");
// $ffi->IsLFNDriveA(pszPath);
// pszPath : LPCSTR optional
// 構造体/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, W32APIOptions.ASCII_OPTIONS);
boolean IsLFNDriveA(
String pszPath // LPCSTR optional
);
}@[Link("shell32")]
lib LibSHELL32
fun IsLFNDriveA = IsLFNDriveA(
pszPath : UInt8* # LPCSTR optional
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef IsLFNDriveANative = Int32 Function(Pointer<Utf8>);
typedef IsLFNDriveADart = int Function(Pointer<Utf8>);
final IsLFNDriveA = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<IsLFNDriveANative, IsLFNDriveADart>('IsLFNDriveA');
// pszPath : LPCSTR optional -> Pointer<Utf8>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function IsLFNDriveA(
pszPath: PAnsiChar // LPCSTR optional
): BOOL; stdcall;
external 'SHELL32.dll' name 'IsLFNDriveA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "IsLFNDriveA"
c_IsLFNDriveA :: CString -> IO CInt
-- pszPath : LPCSTR optional -> CString
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let islfndrivea =
foreign "IsLFNDriveA"
(string @-> returning int32_t)
(* pszPath : LPCSTR optional -> string *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)
(cffi:defcfun ("IsLFNDriveA" is-lfndrive-a :convention :stdcall) :int32
(psz-path :string)) ; LPCSTR optional
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $IsLFNDriveA = Win32::API::More->new('SHELL32',
'BOOL IsLFNDriveA(LPCSTR pszPath)');
# my $ret = $IsLFNDriveA->Call($pszPath);
# pszPath : LPCSTR optional -> LPCSTR
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f IsLFNDriveW (Unicode版) — ドライブが長いファイル名に対応しているか判定する。