Win32 API 日本語リファレンス
ホームSystem.Ole › RevokeDragDrop

RevokeDragDrop

関数
ウィンドウのドロップ対象としての登録を解除する。
DLLOLE32.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

HRESULT RevokeDragDrop(
    HWND hwnd
);

パラメーター

名前方向説明
hwndHWNDinOLE のドラッグアンドドロップ操作のターゲットとして以前に登録されたウィンドウへのハンドル。

戻り値の型: HRESULT

公式ドキュメント

指定したアプリケーションウィンドウを、OLE のドラッグアンドドロップ操作のターゲット候補として登録した内容を取り消します。

戻り値

この関数は成功した場合に S_OK を返します。その他に返される可能性のある値は以下のとおりです。

戻り値 説明
DRAGDROP_E_NOTREGISTERED
登録されていないドロップターゲットの取り消しが試みられました。
DRAGDROP_E_INVALIDHWND
hwnd パラメーターに無効なハンドルが返されました。
E_OUTOFMEMORY
操作に必要なメモリが不足しています。

解説(Remarks)

アプリケーションウィンドウが OLE のドラッグアンドドロップ操作のターゲット候補として利用できなくなった場合は、RevokeDragDrop を呼び出す必要があります。

この関数は、ドロップターゲットインターフェイスに対して IUnknown::Release メソッドを呼び出します。

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

各言語での呼び出し定義

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

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

RevokeDragDrop = ctypes.windll.ole32.RevokeDragDrop
RevokeDragDrop.restype = ctypes.c_int
RevokeDragDrop.argtypes = [
    wintypes.HANDLE,  # hwnd : HWND
]
require 'fiddle'
require 'fiddle/import'

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

var (
	ole32 = windows.NewLazySystemDLL("OLE32.dll")
	procRevokeDragDrop = ole32.NewProc("RevokeDragDrop")
)

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

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

typedef RevokeDragDropNative = Int32 Function(Pointer<Void>);
typedef RevokeDragDropDart = int Function(Pointer<Void>);
final RevokeDragDrop = DynamicLibrary.open('OLE32.dll')
    .lookupFunction<RevokeDragDropNative, RevokeDragDropDart>('RevokeDragDrop');
// hwnd : HWND -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function RevokeDragDrop(
  hwnd: THandle   // HWND
): Integer; stdcall;
  external 'OLE32.dll' name 'RevokeDragDrop';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "RevokeDragDrop"
  c_RevokeDragDrop :: Ptr () -> IO Int32
-- hwnd : HWND -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let revokedragdrop =
  foreign "RevokeDragDrop"
    ((ptr void) @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library ole32 (t "OLE32.dll"))
(cffi:use-foreign-library ole32)

(cffi:defcfun ("RevokeDragDrop" revoke-drag-drop :convention :stdcall) :int32
  (hwnd :pointer))   ; HWND
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $RevokeDragDrop = Win32::API::More->new('OLE32',
    'int RevokeDragDrop(HANDLE hwnd)');
# my $ret = $RevokeDragDrop->Call($hwnd);
# hwnd : HWND -> HANDLE
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

公式の関連項目