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

SHCreateShellFolderViewEx

関数
拡張パラメーターでシェルフォルダービューを生成する。
DLLSHELL32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

// SHELL32.dll
#include <windows.h>

HRESULT SHCreateShellFolderViewEx(
    CSFV* pcsfv,
    IShellView** ppsv
);

パラメーター

名前方向説明
pcsfvCSFV*inこのシェルフォルダービューオブジェクトのインスタンスを作成する際に使用する詳細情報を記述した構造体へのポインターです。
ppsvIShellView**outIShellView インターフェイスポインターのアドレスです。この関数が正常に終了すると、新しいビューオブジェクトを指します。失敗した場合、この値は NULL になります。

戻り値の型: HRESULT

公式ドキュメント

既定のシェルフォルダービューオブジェクトの新しいインスタンスを作成します。この関数ではなく SHCreateShellFolderView を使用することを推奨します。

戻り値

型: HRESULT

この関数が成功すると S_OK を返します。それ以外の場合は HRESULT エラーコードを返します。

解説(Remarks)

SHCreateShellFolderView は、その要素がさまざまなシナリオに参加し、ビューに新しい機能を提供し、他のオブジェクトと連携できる柔軟性が高いため、SHCreateShellFolderViewEx よりも推奨されます。

複数の IShellView インスタンスを扱う場合、どれが既定のシェルフォルダービューオブジェクトであるかを確認したいことがあります。確認するには、IID_CDefView を使用してオブジェクトに対して QueryInterface を呼び出します。この呼び出しは、既定のシェルフォルダービューオブジェクトに対してのみ成功します。

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

各言語での呼び出し定義

// SHELL32.dll
#include <windows.h>

HRESULT SHCreateShellFolderViewEx(
    CSFV* pcsfv,
    IShellView** ppsv
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHCreateShellFolderViewEx(
    IntPtr pcsfv,   // CSFV*
    IntPtr ppsv   // IShellView** out
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHCreateShellFolderViewEx(
    pcsfv As IntPtr,   ' CSFV*
    ppsv As IntPtr   ' IShellView** out
) As Integer
End Function
' pcsfv : CSFV*
' ppsv : IShellView** out
Declare PtrSafe Function SHCreateShellFolderViewEx Lib "shell32" ( _
    ByVal pcsfv As LongPtr, _
    ByVal ppsv As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHCreateShellFolderViewEx = ctypes.windll.shell32.SHCreateShellFolderViewEx
SHCreateShellFolderViewEx.restype = ctypes.c_int
SHCreateShellFolderViewEx.argtypes = [
    ctypes.c_void_p,  # pcsfv : CSFV*
    ctypes.c_void_p,  # ppsv : IShellView** out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHCreateShellFolderViewEx = Fiddle::Function.new(
  lib['SHCreateShellFolderViewEx'],
  [
    Fiddle::TYPE_VOIDP,  # pcsfv : CSFV*
    Fiddle::TYPE_VOIDP,  # ppsv : IShellView** out
  ],
  Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn SHCreateShellFolderViewEx(
        pcsfv: *mut CSFV,  // CSFV*
        ppsv: *mut *mut core::ffi::c_void  // IShellView** out
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHCreateShellFolderViewEx(IntPtr pcsfv, IntPtr ppsv);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHCreateShellFolderViewEx' -Namespace Win32 -PassThru
# $api::SHCreateShellFolderViewEx(pcsfv, ppsv)
#uselib "SHELL32.dll"
#func global SHCreateShellFolderViewEx "SHCreateShellFolderViewEx" sptr, sptr
; SHCreateShellFolderViewEx varptr(pcsfv), ppsv   ; 戻り値は stat
; pcsfv : CSFV* -> "sptr"
; ppsv : IShellView** out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHELL32.dll"
#cfunc global SHCreateShellFolderViewEx "SHCreateShellFolderViewEx" var, sptr
; res = SHCreateShellFolderViewEx(pcsfv, ppsv)
; pcsfv : CSFV* -> "var"
; ppsv : IShellView** out -> "sptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; HRESULT SHCreateShellFolderViewEx(CSFV* pcsfv, IShellView** ppsv)
#uselib "SHELL32.dll"
#cfunc global SHCreateShellFolderViewEx "SHCreateShellFolderViewEx" var, intptr
; res = SHCreateShellFolderViewEx(pcsfv, ppsv)
; pcsfv : CSFV* -> "var"
; ppsv : IShellView** out -> "intptr"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHCreateShellFolderViewEx = shell32.NewProc("SHCreateShellFolderViewEx")
)

// pcsfv (CSFV*), ppsv (IShellView** out)
r1, _, err := procSHCreateShellFolderViewEx.Call(
	uintptr(pcsfv),
	uintptr(ppsv),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SHCreateShellFolderViewEx(
  pcsfv: Pointer;   // CSFV*
  ppsv: Pointer   // IShellView** out
): Integer; stdcall;
  external 'SHELL32.dll' name 'SHCreateShellFolderViewEx';
result := DllCall("SHELL32\SHCreateShellFolderViewEx"
    , "Ptr", pcsfv   ; CSFV*
    , "Ptr", ppsv   ; IShellView** out
    , "Int")   ; return: HRESULT
●SHCreateShellFolderViewEx(pcsfv, ppsv) = DLL("SHELL32.dll", "int SHCreateShellFolderViewEx(void*, void*)")
# 呼び出し: SHCreateShellFolderViewEx(pcsfv, ppsv)
# pcsfv : CSFV* -> "void*"
# ppsv : IShellView** out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

extern "shell32" fn SHCreateShellFolderViewEx(
    pcsfv: [*c]CSFV, // CSFV*
    ppsv: ?*anyopaque // IShellView** out
) callconv(std.os.windows.WINAPI) i32;
proc SHCreateShellFolderViewEx(
    pcsfv: ptr CSFV,  # CSFV*
    ppsv: pointer  # IShellView** out
): int32 {.importc: "SHCreateShellFolderViewEx", stdcall, dynlib: "SHELL32.dll".}
pragma(lib, "shell32");
extern(Windows)
int SHCreateShellFolderViewEx(
    CSFV* pcsfv,   // CSFV*
    void* ppsv   // IShellView** out
);
ccall((:SHCreateShellFolderViewEx, "SHELL32.dll"), stdcall, Int32,
      (Ptr{CSFV}, Ptr{Cvoid}),
      pcsfv, ppsv)
# pcsfv : CSFV* -> Ptr{CSFV}
# ppsv : IShellView** out -> Ptr{Cvoid}
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
local ffi = require("ffi")
ffi.cdef[[
int32_t SHCreateShellFolderViewEx(
    void* pcsfv,
    void* ppsv);
]]
local shell32 = ffi.load("shell32")
-- shell32.SHCreateShellFolderViewEx(pcsfv, ppsv)
-- pcsfv : CSFV*
-- ppsv : IShellView** out
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
const koffi = require('koffi');
const lib = koffi.load('SHELL32.dll');
const SHCreateShellFolderViewEx = lib.func('__stdcall', 'SHCreateShellFolderViewEx', 'int32_t', ['void *', 'void *']);
// SHCreateShellFolderViewEx(pcsfv, ppsv)
// pcsfv : CSFV* -> 'void *'
// ppsv : IShellView** out -> 'void *'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。
const lib = Deno.dlopen("SHELL32.dll", {
  SHCreateShellFolderViewEx: { parameters: ["pointer", "pointer"], result: "i32" },
});
// lib.symbols.SHCreateShellFolderViewEx(pcsfv, ppsv)
// pcsfv : CSFV* -> "pointer"
// ppsv : IShellView** out -> "pointer"
// 文字列引数は "buffer"(NUL 終端のバイト列を Uint8Array で渡す)。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。
<?php
$ffi = FFI::cdef(<<<C
int32_t SHCreateShellFolderViewEx(
    void* pcsfv,
    void* ppsv);
C, "SHELL32.dll");
// $ffi->SHCreateShellFolderViewEx(pcsfv, ppsv);
// pcsfv : CSFV*
// ppsv : IShellView** 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);
    int SHCreateShellFolderViewEx(
        Pointer pcsfv,   // CSFV*
        Pointer ppsv   // IShellView** out
    );
}
@[Link("shell32")]
lib LibSHELL32
  fun SHCreateShellFolderViewEx = SHCreateShellFolderViewEx(
    pcsfv : CSFV*,   # CSFV*
    ppsv : Void*   # IShellView** out
  ) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。
import 'dart:ffi';
import 'package:ffi/ffi.dart';

typedef SHCreateShellFolderViewExNative = Int32 Function(Pointer<Void>, Pointer<Void>);
typedef SHCreateShellFolderViewExDart = int Function(Pointer<Void>, Pointer<Void>);
final SHCreateShellFolderViewEx = DynamicLibrary.open('SHELL32.dll')
    .lookupFunction<SHCreateShellFolderViewExNative, SHCreateShellFolderViewExDart>('SHCreateShellFolderViewEx');
// pcsfv : CSFV* -> Pointer<Void>
// ppsv : IShellView** out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SHCreateShellFolderViewEx(
  pcsfv: Pointer;   // CSFV*
  ppsv: Pointer   // IShellView** out
): Integer; stdcall;
  external 'SHELL32.dll' name 'SHCreateShellFolderViewEx';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SHCreateShellFolderViewEx"
  c_SHCreateShellFolderViewEx :: Ptr () -> Ptr () -> IO Int32
-- pcsfv : CSFV* -> Ptr ()
-- ppsv : IShellView** out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let shcreateshellfolderviewex =
  foreign "SHCreateShellFolderViewEx"
    ((ptr void) @-> (ptr void) @-> returning int32_t)
(* pcsfv : CSFV* -> (ptr void) *)
(* ppsv : IShellView** out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)

(cffi:defcfun ("SHCreateShellFolderViewEx" shcreate-shell-folder-view-ex :convention :stdcall) :int32
  (pcsfv :pointer)   ; CSFV*
  (ppsv :pointer))   ; IShellView** out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SHCreateShellFolderViewEx = Win32::API::More->new('SHELL32',
    'int SHCreateShellFolderViewEx(LPVOID pcsfv, LPVOID ppsv)');
# my $ret = $SHCreateShellFolderViewEx->Call($pcsfv, $ppsv);
# pcsfv : CSFV* -> LPVOID
# ppsv : IShellView** out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

類似 API
使用する型