PathIsSlowA
関数指定パス(ANSI)が低速な媒体上にあるかを判定する。
シグネチャ
// SHELL32.dll (ANSI / -A)
#include <windows.h>
BOOL PathIsSlowA(
LPCSTR pszFile,
DWORD dwAttr
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| pszFile | LPCSTR | in | ファイルの完全修飾パスを格納する、null 終端文字列へのポインターです。 |
| dwAttr | DWORD | in | ファイル属性が判明している場合はその値を指定します。判明していない場合は –1 を渡してください。その場合、この関数は GetFileAttributes を呼び出して属性を取得します。ファイル属性の一覧については GetFileAttributes を参照してください。 |
戻り値の型: BOOL
公式ドキュメント
PathIsSlow は変更されるか、利用できなくなる可能性があります。 (ANSI)
戻り値
型: BOOL
接続が高遅延である場合は TRUE を返します。それ以外の場合は FALSE を返します。
解説(Remarks)
パスは、MultinetGetConnectionPerformance 関数がその NETCONNECTINFOSTRUCT 構造体で 400 以下の dwSpeed を返す場合、または FILE_ATTRIBUTE_OFFLINE がファイルに設定されている場合に、低速と見なされます。この dwSpeed はネットワークリソースまでのメディアの速度を 100 ビット毎秒 (bps) 単位で表したものです。
ネットワークの状態が関数の処理時間に影響を与える場合がある点に注意してください。
メモ
shlobj.h ヘッダーは PathIsSlow を、UNICODE プリプロセッサ定数の定義に基づいてこの関数の ANSI 版または Unicode 版を自動的に選択するエイリアスとして定義しています。エンコード中立のエイリアスを、エンコード中立でないコードと混在させて使用すると、不一致が生じ、コンパイルエラーや実行時エラーの原因となる場合があります。詳細については Conventions for Function Prototypes を参照してください。
出典・ライセンス: 上記「公式ドキュメント」の内容は Microsoft の Win32 API ドキュメント(MicrosoftDocs/sdk-api)を日本語に翻訳・改変したものです。© Microsoft Corporation. CC BY 4.0 で提供。
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
Microsoft 公式リファレンス: 英語 (en-us) · 日本語 (ja-jp) · 原文ソース (GitHub)
各言語での呼び出し定義
// SHELL32.dll (ANSI / -A)
#include <windows.h>
BOOL PathIsSlowA(
LPCSTR pszFile,
DWORD dwAttr
);[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("SHELL32.dll", CharSet = CharSet.Ansi, ExactSpelling = true)]
static extern bool PathIsSlowA(
[MarshalAs(UnmanagedType.LPStr)] string pszFile, // LPCSTR
uint dwAttr // DWORD
);<DllImport("SHELL32.dll", CharSet:=CharSet.Ansi, ExactSpelling:=True)>
Public Shared Function PathIsSlowA(
<MarshalAs(UnmanagedType.LPStr)> pszFile As String, ' LPCSTR
dwAttr As UInteger ' DWORD
) As <MarshalAs(UnmanagedType.Bool)> Boolean
End Function' pszFile : LPCSTR
' dwAttr : DWORD
Declare PtrSafe Function PathIsSlowA Lib "shell32" ( _
ByVal pszFile As String, _
ByVal dwAttr As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
PathIsSlowA = ctypes.windll.shell32.PathIsSlowA
PathIsSlowA.restype = wintypes.BOOL
PathIsSlowA.argtypes = [
wintypes.LPCSTR, # pszFile : LPCSTR
wintypes.DWORD, # dwAttr : DWORD
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('SHELL32.dll')
PathIsSlowA = Fiddle::Function.new(
lib['PathIsSlowA'],
[
Fiddle::TYPE_VOIDP, # pszFile : LPCSTR
-Fiddle::TYPE_INT, # dwAttr : DWORD
],
Fiddle::TYPE_INT)#[link(name = "shell32")]
extern "system" {
fn PathIsSlowA(
pszFile: *const u8, // LPCSTR
dwAttr: u32 // DWORD
) -> 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 PathIsSlowA([MarshalAs(UnmanagedType.LPStr)] string pszFile, uint dwAttr);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_PathIsSlowA' -Namespace Win32 -PassThru
# $api::PathIsSlowA(pszFile, dwAttr)#uselib "SHELL32.dll"
#func global PathIsSlowA "PathIsSlowA" sptr, sptr
; PathIsSlowA pszFile, dwAttr ; 戻り値は stat
; pszFile : LPCSTR -> "sptr"
; dwAttr : DWORD -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "SHELL32.dll"
#cfunc global PathIsSlowA "PathIsSlowA" str, int
; res = PathIsSlowA(pszFile, dwAttr)
; pszFile : LPCSTR -> "str"
; dwAttr : DWORD -> "int"; BOOL PathIsSlowA(LPCSTR pszFile, DWORD dwAttr)
#uselib "SHELL32.dll"
#cfunc global PathIsSlowA "PathIsSlowA" str, int
; res = PathIsSlowA(pszFile, dwAttr)
; pszFile : LPCSTR -> "str"
; dwAttr : DWORD -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
shell32 = windows.NewLazySystemDLL("SHELL32.dll")
procPathIsSlowA = shell32.NewProc("PathIsSlowA")
)
// pszFile (LPCSTR), dwAttr (DWORD)
r1, _, err := procPathIsSlowA.Call(
uintptr(unsafe.Pointer(windows.BytePtrFromString(pszFile))),
uintptr(dwAttr),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // BOOLfunction PathIsSlowA(
pszFile: PAnsiChar; // LPCSTR
dwAttr: DWORD // DWORD
): BOOL; stdcall;
external 'SHELL32.dll' name 'PathIsSlowA';result := DllCall("SHELL32\PathIsSlowA"
, "AStr", pszFile ; LPCSTR
, "UInt", dwAttr ; DWORD
, "Int") ; return: BOOL●PathIsSlowA(pszFile, dwAttr) = DLL("SHELL32.dll", "bool PathIsSlowA(char*, dword)")
# 呼び出し: PathIsSlowA(pszFile, dwAttr)
# pszFile : LPCSTR -> "char*"
# dwAttr : DWORD -> "dword"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。const std = @import("std");
extern "shell32" fn PathIsSlowA(
pszFile: [*c]const u8, // LPCSTR
dwAttr: u32 // DWORD
) callconv(std.os.windows.WINAPI) i32;proc PathIsSlowA(
pszFile: cstring, # LPCSTR
dwAttr: uint32 # DWORD
): int32 {.importc: "PathIsSlowA", stdcall, dynlib: "SHELL32.dll".}pragma(lib, "shell32");
extern(Windows)
int PathIsSlowA(
const(char)* pszFile, // LPCSTR
uint dwAttr // DWORD
);ccall((:PathIsSlowA, "SHELL32.dll"), stdcall, Int32,
(Cstring, UInt32),
pszFile, dwAttr)
# pszFile : LPCSTR -> Cstring
# dwAttr : DWORD -> UInt32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。local ffi = require("ffi")
ffi.cdef[[
int32_t PathIsSlowA(
const char* pszFile,
uint32_t dwAttr);
]]
local shell32 = ffi.load("shell32")
-- shell32.PathIsSlowA(pszFile, dwAttr)
-- pszFile : LPCSTR
-- dwAttr : DWORD
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const PathIsSlowA = lib.func('__stdcall', 'PathIsSlowA', 'int32_t', ['str', 'uint32_t']);
// PathIsSlowA(pszFile, dwAttr)
// pszFile : LPCSTR -> 'str'
// dwAttr : DWORD -> 'uint32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("SHELL32.dll", {
PathIsSlowA: { parameters: ["buffer", "u32"], result: "i32" },
});
// lib.symbols.PathIsSlowA(pszFile, dwAttr)
// pszFile : LPCSTR -> "buffer"
// dwAttr : DWORD -> "u32"
// 文字列は "buffer"。ANSI(-A) は new TextEncoder() で UTF-8/ANSI バイト列(末尾に \x00)を渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t PathIsSlowA(
const char* pszFile,
uint32_t dwAttr);
C, "SHELL32.dll");
// $ffi->PathIsSlowA(pszFile, dwAttr);
// pszFile : LPCSTR
// 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.ASCII_OPTIONS);
boolean PathIsSlowA(
String pszFile, // LPCSTR
int dwAttr // DWORD
);
}@[Link("shell32")]
lib LibSHELL32
fun PathIsSlowA = PathIsSlowA(
pszFile : UInt8*, # LPCSTR
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 PathIsSlowANative = Int32 Function(Pointer<Utf8>, Uint32);
typedef PathIsSlowADart = int Function(Pointer<Utf8>, int);
final PathIsSlowA = DynamicLibrary.open('SHELL32.dll')
.lookupFunction<PathIsSlowANative, PathIsSlowADart>('PathIsSlowA');
// pszFile : LPCSTR -> Pointer<Utf8>
// dwAttr : DWORD -> Uint32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function PathIsSlowA(
pszFile: PAnsiChar; // LPCSTR
dwAttr: DWORD // DWORD
): BOOL; stdcall;
external 'SHELL32.dll' name 'PathIsSlowA';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "PathIsSlowA"
c_PathIsSlowA :: CString -> Word32 -> IO CInt
-- pszFile : LPCSTR -> CString
-- dwAttr : DWORD -> Word32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let pathisslowa =
foreign "PathIsSlowA"
(string @-> uint32_t @-> returning int32_t)
(* pszFile : LPCSTR -> string *)
(* 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 ("PathIsSlowA" path-is-slow-a :convention :stdcall) :int32
(psz-file :string) ; LPCSTR
(dw-attr :uint32)) ; DWORD
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $PathIsSlowA = Win32::API::More->new('SHELL32',
'BOOL PathIsSlowA(LPCSTR pszFile, DWORD dwAttr)');
# my $ret = $PathIsSlowA->Call($pszFile, $dwAttr);
# pszFile : LPCSTR -> LPCSTR
# dwAttr : DWORD -> DWORD
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。関連項目
文字セット違い
- f PathIsSlowW (Unicode版) — 指定パス(Unicode)が低速な媒体上にあるかを判定する。