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

DestroyCursor

関数
カーソルを破棄し関連リソースを解放する。
DLLUSER32.dll呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

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

BOOL DestroyCursor(
    HCURSOR hCursor
);

パラメーター

名前方向
hCursorHCURSORin

戻り値の型: BOOL

各言語での呼び出し定義

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

BOOL DestroyCursor(
    HCURSOR hCursor
);
[return: MarshalAs(UnmanagedType.Bool)]
[DllImport("USER32.dll", SetLastError = true, ExactSpelling = true)]
static extern bool DestroyCursor(
    IntPtr hCursor   // HCURSOR
);
<DllImport("USER32.dll", SetLastError:=True, ExactSpelling:=True)>
Public Shared Function DestroyCursor(
    hCursor As IntPtr   ' HCURSOR
) As Boolean
End Function
' hCursor : HCURSOR
Declare PtrSafe Function DestroyCursor Lib "user32" ( _
    ByVal hCursor As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

DestroyCursor = ctypes.windll.user32.DestroyCursor
DestroyCursor.restype = wintypes.BOOL
DestroyCursor.argtypes = [
    wintypes.HANDLE,  # hCursor : HCURSOR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

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

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procDestroyCursor = user32.NewProc("DestroyCursor")
)

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