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

SHGetDesktopFolder

関数
デスクトップのIShellFolderインターフェイスを取得する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

HRESULT SHGetDesktopFolder(
    IShellFolder** ppshf
);

パラメーター

名前方向
ppshfIShellFolder**out

戻り値の型: HRESULT

各言語での呼び出し定義

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

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

SHGetDesktopFolder = ctypes.windll.shell32.SHGetDesktopFolder
SHGetDesktopFolder.restype = ctypes.c_int
SHGetDesktopFolder.argtypes = [
    ctypes.c_void_p,  # ppshf : IShellFolder** out
]
require 'fiddle'
require 'fiddle/import'

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

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procSHGetDesktopFolder = shell32.NewProc("SHGetDesktopFolder")
)

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