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

DragAcceptFiles

関数
ウィンドウのドラッグ&ドロップ受け入れを設定する。
DLLSHELL32.dll呼出規約winapi対応OSWindows XP 以降

シグネチャ

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

void DragAcceptFiles(
    HWND hWnd,
    BOOL fAccept
);

パラメーター

名前方向
hWndHWNDin
fAcceptBOOLin

戻り値の型: void

各言語での呼び出し定義

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

void DragAcceptFiles(
    HWND hWnd,
    BOOL fAccept
);
[DllImport("SHELL32.dll", ExactSpelling = true)]
static extern void DragAcceptFiles(
    IntPtr hWnd,   // HWND
    bool fAccept   // BOOL
);
<DllImport("SHELL32.dll", ExactSpelling:=True)>
Public Shared Sub DragAcceptFiles(
    hWnd As IntPtr,   ' HWND
    fAccept As Boolean   ' BOOL
)
End Sub
' hWnd : HWND
' fAccept : BOOL
Declare PtrSafe Sub DragAcceptFiles Lib "shell32" ( _
    ByVal hWnd As LongPtr, _
    ByVal fAccept As Long)
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DragAcceptFiles = ctypes.windll.shell32.DragAcceptFiles
DragAcceptFiles.restype = None
DragAcceptFiles.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND
    wintypes.BOOL,  # fAccept : BOOL
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHELL32.dll')
DragAcceptFiles = Fiddle::Function.new(
  lib['DragAcceptFiles'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND
    Fiddle::TYPE_INT,  # fAccept : BOOL
  ],
  Fiddle::TYPE_VOID)
#[link(name = "shell32")]
extern "system" {
    fn DragAcceptFiles(
        hWnd: *mut core::ffi::c_void,  // HWND
        fAccept: i32  // BOOL
    );
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHELL32.dll")]
public static extern void DragAcceptFiles(IntPtr hWnd, bool fAccept);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHELL32_DragAcceptFiles' -Namespace Win32 -PassThru
# $api::DragAcceptFiles(hWnd, fAccept)
#uselib "SHELL32.dll"
#func global DragAcceptFiles "DragAcceptFiles" sptr, sptr
; DragAcceptFiles hWnd, fAccept
; hWnd : HWND -> "sptr"
; fAccept : BOOL -> "sptr"
#uselib "SHELL32.dll"
#func global DragAcceptFiles "DragAcceptFiles" sptr, int
; DragAcceptFiles hWnd, fAccept
; hWnd : HWND -> "sptr"
; fAccept : BOOL -> "int"
; void DragAcceptFiles(HWND hWnd, BOOL fAccept)
#uselib "SHELL32.dll"
#func global DragAcceptFiles "DragAcceptFiles" intptr, int
; DragAcceptFiles hWnd, fAccept
; hWnd : HWND -> "intptr"
; fAccept : BOOL -> "int"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shell32 = windows.NewLazySystemDLL("SHELL32.dll")
	procDragAcceptFiles = shell32.NewProc("DragAcceptFiles")
)

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