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

PathIsSystemFolderW

関数
指定したフォルダがシステムフォルダかどうかを判定する。
DLLSHLWAPI.dll文字セットUnicode (-W)呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

BOOL PathIsSystemFolderW(
    LPCWSTR pszPath,   // optional
    DWORD dwAttrb
);

パラメーター

名前方向
pszPathLPCWSTRinoptional
dwAttrbDWORDin

戻り値の型: BOOL

各言語での呼び出し定義

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

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

PathIsSystemFolderW = ctypes.windll.shlwapi.PathIsSystemFolderW
PathIsSystemFolderW.restype = wintypes.BOOL
PathIsSystemFolderW.argtypes = [
    wintypes.LPCWSTR,  # pszPath : LPCWSTR optional
    wintypes.DWORD,  # dwAttrb : DWORD
]
require 'fiddle'
require 'fiddle/import'

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

var (
	shlwapi = windows.NewLazySystemDLL("SHLWAPI.dll")
	procPathIsSystemFolderW = shlwapi.NewProc("PathIsSystemFolderW")
)

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