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

PathIsSlowW

関数
指定パス(Unicode)が低速な媒体上にあるかを判定する。
DLLSHELL32.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

BOOL PathIsSlowW(
    LPCWSTR pszFile,
    DWORD dwAttr
);

パラメーター

名前方向説明
pszFileLPCWSTRinファイルの完全修飾パスを格納した、null で終わる文字列へのポインターです。
dwAttrDWORDinファイル属性が判明している場合はその属性を指定します。判明していない場合は –1 を渡すと、この関数は GetFileAttributes を呼び出して属性を取得します。ファイル属性の一覧については GetFileAttributes を参照してください。

戻り値の型: BOOL

公式ドキュメント

PathIsSlow は変更されるか、利用できなくなる可能性があります。(Unicode)

戻り値

型: BOOL

接続が高遅延である場合は TRUE を返します。それ以外の場合は FALSE を返します。

解説(Remarks)

パスは、MultinetGetConnectionPerformance 関数が NETCONNECTINFOSTRUCT 構造体において 400 以下の dwSpeed を返した場合 (これはネットワークリソースへのメディアの速度を 100 ビット毎秒 (bps) 単位で表したものです)、またはファイルに FILE_ATTRIBUTE_OFFLINE が設定されている場合に、低速と見なされます。

ネットワークの状態によって、この関数のパフォーマンス時間が影響を受ける可能性がある点に注意してください。

メモ

shlobj.h ヘッダーは、UNICODE プリプロセッサ定数の定義に基づいて、この関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして PathIsSlow を定義します。エンコーディング非依存のエイリアスを、エンコーディング非依存でないコードと混在させて使用すると、不一致が生じ、コンパイルエラーや実行時エラーを引き起こす可能性があります。詳細については、関数プロトタイプの規約 を参照してください。

出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)

各言語での呼び出し定義

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

BOOL PathIsSlowW(
    LPCWSTR pszFile,
    DWORD dwAttr
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern bool PathIsSlowW(
    [MarshalAs(UnmanagedType.LPWStr)] string pszFile,   // LPCWSTR
    uint dwAttr   // DWORD
);
<DllImport("SHELL32.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function PathIsSlowW(
    <MarshalAs(UnmanagedType.LPWStr)> pszFile As String,   ' LPCWSTR
    dwAttr As UInteger   ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function
' pszFile : LPCWSTR
' dwAttr : DWORD
Declare PtrSafe Function PathIsSlowW Lib "shell32" ( _
    ByVal pszFile As LongPtr, _
    ByVal dwAttr As Long) 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

PathIsSlowW = ctypes.windll.shell32.PathIsSlowW
PathIsSlowW.restype = wintypes.BOOL
PathIsSlowW.argtypes = [
    wintypes.LPCWSTR,  # pszFile : LPCWSTR
    wintypes.DWORD,  # dwAttr : DWORD
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
PathIsSlowW = Fiddle::Function.new(
  lib['PathIsSlowW'],
  [
    Fiddle::TYPE_VOIDP,  # pszFile : LPCWSTR
    -Fiddle::TYPE_INT,  # dwAttr : DWORD
  ],
  Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "shell32")]
extern "system" {
    fn PathIsSlowW(
        pszFile: *const u16,  // LPCWSTR
        dwAttr: u32  // DWORD
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Unicode)]
public static extern bool PathIsSlowW([MarshalAs(UnmanagedType.LPWStr)] string pszFile, uint dwAttr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_PathIsSlowW' -Namespace Win32 -PassThru
# $api::PathIsSlowW(pszFile, dwAttr)
#uselib "SHELL32.dll"
#func global PathIsSlowW "PathIsSlowW" wptr, wptr
; PathIsSlowW pszFile, dwAttr   ; 戻り値は stat
; pszFile : LPCWSTR -> "wptr"
; dwAttr : DWORD -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global PathIsSlowW "PathIsSlowW" wstr, int
; res = PathIsSlowW(pszFile, dwAttr)
; pszFile : LPCWSTR -> "wstr"
; dwAttr : DWORD -> "int"
; BOOL PathIsSlowW(LPCWSTR pszFile, DWORD dwAttr)
#uselib "SHELL32.dll"
#cfunc global PathIsSlowW "PathIsSlowW" wstr, int
; res = PathIsSlowW(pszFile, dwAttr)
; pszFile : LPCWSTR -> "wstr"
; dwAttr : DWORD -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procPathIsSlowW = shell32.NewProc("PathIsSlowW")
)

// pszFile (LPCWSTR), dwAttr (DWORD)
r1, _, err := procPathIsSlowW.Call(
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszFile))),
	uintptr(dwAttr),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // BOOL
function PathIsSlowW(
  pszFile: PWideChar;   // LPCWSTR
  dwAttr: DWORD   // DWORD
): BOOL; stdcall;
  external 'SHELL32.dll' name 'PathIsSlowW';
result := DllCall("SHELL32\PathIsSlowW"
    , "WStr", pszFile   ; LPCWSTR
    , "UInt", dwAttr   ; DWORD
    , "Int")   ; return: BOOL
●PathIsSlowW(pszFile, dwAttr) = DLL("SHELL32.dll", "bool PathIsSlowW(char*, dword)")
# 呼び出し: PathIsSlowW(pszFile, dwAttr)
# pszFile : LPCWSTR -> "char*"
# dwAttr : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。
const std = @import("std");

extern "shell32" fn PathIsSlowW(
    pszFile: [*c]const u16, // LPCWSTR
    dwAttr: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。
proc PathIsSlowW(
    pszFile: WideCString,  # LPCWSTR
    dwAttr: uint32  # DWORD
): int32 {.importc: "PathIsSlowW", stdcall, dynlib: "SHELL32.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。
pragma(lib, "shell32");
extern(Windows)
int PathIsSlowW(
    const(wchar)* pszFile,   // LPCWSTR
    uint dwAttr   // DWORD
);
ccall((:PathIsSlowW, "SHELL32.dll"), stdcall, Int32,
      (Cwstring, UInt32),
      pszFile, dwAttr)
# pszFile : LPCWSTR -> Cwstring
# dwAttr : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。
local ffi = require("ffi")
ffi.cdef[[
int32_t PathIsSlowW(
    const uint16_t* pszFile,
    uint32_t dwAttr);
]]
local shell32 = ffi.load("shell32")
-- shell32.PathIsSlowW(pszFile, dwAttr)
-- pszFile : LPCWSTR
-- dwAttr : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。
const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const PathIsSlowW = lib.func('__stdcall', 'PathIsSlowW', 'int32_t', ['str16', 'uint32_t']);
// PathIsSlowW(pszFile, dwAttr)
// pszFile : LPCWSTR -> 'str16'
// dwAttr : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SHELL32.dll", {
  PathIsSlowW: { parameters: ["buffer", "u32"], result: "i32" },
});
// lib.symbols.PathIsSlowW(pszFile, dwAttr)
// pszFile : LPCWSTR -> "buffer"
// dwAttr : DWORD -> "u32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t PathIsSlowW(
    const uint16_t* pszFile,
    uint32_t dwAttr);
C, "SHELL32.dll");
// $ffi->PathIsSlowW(pszFile, dwAttr);
// pszFile : LPCWSTR
// dwAttr : DWORD
// 構造体/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.UNICODE_OPTIONS);
    boolean PathIsSlowW(
        WString pszFile,   // LPCWSTR
        int dwAttr   // DWORD
    );
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。
@[Link("shell32")]
lib LibSHELL32
  fun PathIsSlowW = PathIsSlowW(
    pszFile : UInt16*,   # LPCWSTR
    dwAttr : UInt32   # DWORD
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef PathIsSlowWNative = Int32 Function(Pointer<Utf16>, Uint32);
typedef PathIsSlowWDart = int Function(Pointer<Utf16>, int);
final PathIsSlowW = DynamicLibrary.open('SHELL32.dll')
    .lookupFunction<PathIsSlowWNative, PathIsSlowWDart>('PathIsSlowW');
// pszFile : LPCWSTR -> Pointer<Utf16>
// dwAttr : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function PathIsSlowW(
  pszFile: PWideChar;   // LPCWSTR
  dwAttr: DWORD   // DWORD
): BOOL; stdcall;
  external 'SHELL32.dll' name 'PathIsSlowW';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "PathIsSlowW"
  c_PathIsSlowW :: CWString -> Word32 -> IO CInt
-- pszFile : LPCWSTR -> CWString
-- dwAttr : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let pathissloww =
  foreign "PathIsSlowW"
    ((ptr uint16_t) @-> uint32_t @-> returning int32_t)
(* pszFile : LPCWSTR -> (ptr uint16_t) *)
(* dwAttr : DWORD -> uint32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)

(cffi:defcfun ("PathIsSlowW" path-is-slow-w :convention :stdcall) :int32
  (psz-file (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-attr :uint32))   ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $PathIsSlowW = Win32::API::More->new('SHELL32',
    'BOOL PathIsSlowW(LPCWSTR pszFile, DWORD dwAttr)');
# my $ret = $PathIsSlowW->Call($pszFile, $dwAttr);
# pszFile : LPCWSTR -> LPCWSTR
# dwAttr : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。

関連項目

文字セット違い