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

SHShowManageLibraryUI

関数
ライブラリ管理用のダイアログUIを表示する。
DLLSHELL32.dll呼出規約winapi対応OSWindows 7 以降

シグネチャ

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

HRESULT SHShowManageLibraryUI(
    IShellItem* psiLibrary,
    HWND hwndOwner,
    LPCWSTR pszTitle,   // optional
    LPCWSTR pszInstruction,   // optional
    LIBRARYMANAGEDIALOGOPTIONS lmdOptions
);

パラメーター

名前方向説明
psiLibraryIShellItem*in管理対象のライブラリを表す IShellItem オブジェクトへのポインター。
hwndOwnerHWNDinライブラリ管理ダイアログボックスを所有するウィンドウのハンドル。このパラメーターの値は NULL にできます。
pszTitleLPCWSTRinoptionalライブラリ管理ダイアログのタイトルへのポインター。汎用のタイトル文字列を表示するには、このパラメーターの値を NULL に設定します。
pszInstructionLPCWSTRinoptionalライブラリ管理ダイアログボックスのタイトル文字列の下に表示するヘルプ文字列へのポインター。汎用のヘルプ文字列を表示するには、このパラメーターの値を NULL に設定します。
lmdOptionsLIBRARYMANAGEDIALOGOPTIONSin管理ダイアログボックスの動作を指定する LIBRARYMANAGEDIALOGOPTIONS 列挙体の値。

戻り値の型: HRESULT

公式ドキュメント

ライブラリ管理ダイアログボックスを表示します。これにより、ユーザーはライブラリフォルダーと既定の保存場所を管理できます。

戻り値

Type: HRESULT

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

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

各言語での呼び出し定義

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

HRESULT SHShowManageLibraryUI(
    IShellItem* psiLibrary,
    HWND hwndOwner,
    LPCWSTR pszTitle,   // optional
    LPCWSTR pszInstruction,   // optional
    LIBRARYMANAGEDIALOGOPTIONS lmdOptions
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern int SHShowManageLibraryUI(
    IntPtr psiLibrary,   // IShellItem*
    IntPtr hwndOwner,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] string pszTitle,   // LPCWSTR optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszInstruction,   // LPCWSTR optional
    int lmdOptions   // LIBRARYMANAGEDIALOGOPTIONS
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Function SHShowManageLibraryUI(
    psiLibrary As IntPtr,   ' IShellItem*
    hwndOwner As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> pszTitle As String,   ' LPCWSTR optional
    <MarshalAs(UnmanagedType.LPWStr)> pszInstruction As String,   ' LPCWSTR optional
    lmdOptions As Integer   ' LIBRARYMANAGEDIALOGOPTIONS
) As Integer
End Function
' psiLibrary : IShellItem*
' hwndOwner : HWND
' pszTitle : LPCWSTR optional
' pszInstruction : LPCWSTR optional
' lmdOptions : LIBRARYMANAGEDIALOGOPTIONS
Declare PtrSafe Function SHShowManageLibraryUI Lib "shell32" ( _
    ByVal psiLibrary As LongPtr, _
    ByVal hwndOwner As LongPtr, _
    ByVal pszTitle As LongPtr, _
    ByVal pszInstruction As LongPtr, _
    ByVal lmdOptions As Long) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SHShowManageLibraryUI = ctypes.windll.shell32.SHShowManageLibraryUI
SHShowManageLibraryUI.restype = ctypes.c_int
SHShowManageLibraryUI.argtypes = [
    ctypes.c_void_p,  # psiLibrary : IShellItem*
    wintypes.HANDLE,  # hwndOwner : HWND
    wintypes.LPCWSTR,  # pszTitle : LPCWSTR optional
    wintypes.LPCWSTR,  # pszInstruction : LPCWSTR optional
    ctypes.c_int,  # lmdOptions : LIBRARYMANAGEDIALOGOPTIONS
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
SHShowManageLibraryUI = Fiddle::Function.new(
  lib['SHShowManageLibraryUI'],
  [
    Fiddle::TYPE_VOIDP,  # psiLibrary : IShellItem*
    Fiddle::TYPE_VOIDP,  # hwndOwner : HWND
    Fiddle::TYPE_VOIDP,  # pszTitle : LPCWSTR optional
    Fiddle::TYPE_VOIDP,  # pszInstruction : LPCWSTR optional
    Fiddle::TYPE_INT,  # lmdOptions : LIBRARYMANAGEDIALOGOPTIONS
  ],
  Fiddle::TYPE_INT)
#[link(name = "shell32")]
extern "system" {
    fn SHShowManageLibraryUI(
        psiLibrary: *mut core::ffi::c_void,  // IShellItem*
        hwndOwner: *mut core::ffi::c_void,  // HWND
        pszTitle: *const u16,  // LPCWSTR optional
        pszInstruction: *const u16,  // LPCWSTR optional
        lmdOptions: i32  // LIBRARYMANAGEDIALOGOPTIONS
    ) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern int SHShowManageLibraryUI(IntPtr psiLibrary, IntPtr hwndOwner, [MarshalAs(UnmanagedType.LPWStr)] string pszTitle, [MarshalAs(UnmanagedType.LPWStr)] string pszInstruction, int lmdOptions);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_SHShowManageLibraryUI' -Namespace Win32 -PassThru
# $api::SHShowManageLibraryUI(psiLibrary, hwndOwner, pszTitle, pszInstruction, lmdOptions)
#uselib "SHELL32.dll"
#func global SHShowManageLibraryUI "SHShowManageLibraryUI" sptr, sptr, sptr, sptr, sptr
; SHShowManageLibraryUI psiLibrary, hwndOwner, pszTitle, pszInstruction, lmdOptions   ; 戻り値は stat
; psiLibrary : IShellItem* -> "sptr"
; hwndOwner : HWND -> "sptr"
; pszTitle : LPCWSTR optional -> "sptr"
; pszInstruction : LPCWSTR optional -> "sptr"
; lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "SHELL32.dll"
#cfunc global SHShowManageLibraryUI "SHShowManageLibraryUI" sptr, sptr, wstr, wstr, int
; res = SHShowManageLibraryUI(psiLibrary, hwndOwner, pszTitle, pszInstruction, lmdOptions)
; psiLibrary : IShellItem* -> "sptr"
; hwndOwner : HWND -> "sptr"
; pszTitle : LPCWSTR optional -> "wstr"
; pszInstruction : LPCWSTR optional -> "wstr"
; lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> "int"
; HRESULT SHShowManageLibraryUI(IShellItem* psiLibrary, HWND hwndOwner, LPCWSTR pszTitle, LPCWSTR pszInstruction, LIBRARYMANAGEDIALOGOPTIONS lmdOptions)
#uselib "SHELL32.dll"
#cfunc global SHShowManageLibraryUI "SHShowManageLibraryUI" intptr, intptr, wstr, wstr, int
; res = SHShowManageLibraryUI(psiLibrary, hwndOwner, pszTitle, pszInstruction, lmdOptions)
; psiLibrary : IShellItem* -> "intptr"
; hwndOwner : HWND -> "intptr"
; pszTitle : LPCWSTR optional -> "wstr"
; pszInstruction : LPCWSTR optional -> "wstr"
; lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHShowManageLibraryUI = shell32.NewProc("SHShowManageLibraryUI")
)

// psiLibrary (IShellItem*), hwndOwner (HWND), pszTitle (LPCWSTR optional), pszInstruction (LPCWSTR optional), lmdOptions (LIBRARYMANAGEDIALOGOPTIONS)
r1, _, err := procSHShowManageLibraryUI.Call(
	uintptr(psiLibrary),
	uintptr(hwndOwner),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszTitle))),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszInstruction))),
	uintptr(lmdOptions),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HRESULT
function SHShowManageLibraryUI(
  psiLibrary: Pointer;   // IShellItem*
  hwndOwner: THandle;   // HWND
  pszTitle: PWideChar;   // LPCWSTR optional
  pszInstruction: PWideChar;   // LPCWSTR optional
  lmdOptions: Integer   // LIBRARYMANAGEDIALOGOPTIONS
): Integer; stdcall;
  external 'SHELL32.dll' name 'SHShowManageLibraryUI';
result := DllCall("SHELL32\SHShowManageLibraryUI"
    , "Ptr", psiLibrary   ; IShellItem*
    , "Ptr", hwndOwner   ; HWND
    , "WStr", pszTitle   ; LPCWSTR optional
    , "WStr", pszInstruction   ; LPCWSTR optional
    , "Int", lmdOptions   ; LIBRARYMANAGEDIALOGOPTIONS
    , "Int")   ; return: HRESULT
●SHShowManageLibraryUI(psiLibrary, hwndOwner, pszTitle, pszInstruction, lmdOptions) = DLL("SHELL32.dll", "int SHShowManageLibraryUI(void*, void*, char*, char*, int)")
# 呼び出し: SHShowManageLibraryUI(psiLibrary, hwndOwner, pszTitle, pszInstruction, lmdOptions)
# psiLibrary : IShellItem* -> "void*"
# hwndOwner : HWND -> "void*"
# pszTitle : LPCWSTR optional -> "char*"
# pszInstruction : LPCWSTR optional -> "char*"
# lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef SHShowManageLibraryUINative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, Int32);
typedef SHShowManageLibraryUIDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Pointer<Utf16>, int);
final SHShowManageLibraryUI = DynamicLibrary.open('SHELL32.dll')
    .lookupFunction<SHShowManageLibraryUINative, SHShowManageLibraryUIDart>('SHShowManageLibraryUI');
// psiLibrary : IShellItem* -> Pointer<Void>
// hwndOwner : HWND -> Pointer<Void>
// pszTitle : LPCWSTR optional -> Pointer<Utf16>
// pszInstruction : LPCWSTR optional -> Pointer<Utf16>
// lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SHShowManageLibraryUI(
  psiLibrary: Pointer;   // IShellItem*
  hwndOwner: THandle;   // HWND
  pszTitle: PWideChar;   // LPCWSTR optional
  pszInstruction: PWideChar;   // LPCWSTR optional
  lmdOptions: Integer   // LIBRARYMANAGEDIALOGOPTIONS
): Integer; stdcall;
  external 'SHELL32.dll' name 'SHShowManageLibraryUI';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SHShowManageLibraryUI"
  c_SHShowManageLibraryUI :: Ptr () -> Ptr () -> CWString -> CWString -> Int32 -> IO Int32
-- psiLibrary : IShellItem* -> Ptr ()
-- hwndOwner : HWND -> Ptr ()
-- pszTitle : LPCWSTR optional -> CWString
-- pszInstruction : LPCWSTR optional -> CWString
-- lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let shshowmanagelibraryui =
  foreign "SHShowManageLibraryUI"
    ((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* psiLibrary : IShellItem* -> (ptr void) *)
(* hwndOwner : HWND -> (ptr void) *)
(* pszTitle : LPCWSTR optional -> (ptr uint16_t) *)
(* pszInstruction : LPCWSTR optional -> (ptr uint16_t) *)
(* lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shell32 (t "SHELL32.dll"))
(cffi:use-foreign-library shell32)

(cffi:defcfun ("SHShowManageLibraryUI" shshow-manage-library-ui :convention :stdcall) :int32
  (psi-library :pointer)   ; IShellItem*
  (hwnd-owner :pointer)   ; HWND
  (psz-title (:string :encoding :utf-16le))   ; LPCWSTR optional
  (psz-instruction (:string :encoding :utf-16le))   ; LPCWSTR optional
  (lmd-options :int32))   ; LIBRARYMANAGEDIALOGOPTIONS
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SHShowManageLibraryUI = Win32::API::More->new('SHELL32',
    'int SHShowManageLibraryUI(LPVOID psiLibrary, HANDLE hwndOwner, LPCWSTR pszTitle, LPCWSTR pszInstruction, int lmdOptions)');
# my $ret = $SHShowManageLibraryUI->Call($psiLibrary, $hwndOwner, $pszTitle, $pszInstruction, $lmdOptions);
# psiLibrary : IShellItem* -> LPVOID
# hwndOwner : HWND -> HANDLE
# pszTitle : LPCWSTR optional -> LPCWSTR
# pszInstruction : LPCWSTR optional -> LPCWSTR
# lmdOptions : LIBRARYMANAGEDIALOGOPTIONS -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目
使用する型