ホーム › UI.WindowsAndMessaging › LoadCursorW
LoadCursorW
関数カーソルリソースを読み込みハンドルを返す(Unicode版)。
シグネチャ
// USER32.dll (Unicode / -W)
#include <windows.h>
HCURSOR LoadCursorW(
HINSTANCE hInstance, // optional
LPCWSTR lpCursorName
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| hInstance | HINSTANCE | inoptional |
| lpCursorName | LPCWSTR | in |
戻り値の型: HCURSOR
各言語での呼び出し定義
// USER32.dll (Unicode / -W)
#include <windows.h>
HCURSOR LoadCursorW(
HINSTANCE hInstance, // optional
LPCWSTR lpCursorName
);[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr LoadCursorW(
IntPtr hInstance, // HINSTANCE optional
[MarshalAs(UnmanagedType.LPWStr)] string lpCursorName // LPCWSTR
);<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function LoadCursorW(
hInstance As IntPtr, ' HINSTANCE optional
<MarshalAs(UnmanagedType.LPWStr)> lpCursorName As String ' LPCWSTR
) As IntPtr
End Function' hInstance : HINSTANCE optional
' lpCursorName : LPCWSTR
Declare PtrSafe Function LoadCursorW Lib "user32" ( _
ByVal hInstance As LongPtr, _
ByVal lpCursorName As LongPtr) As LongPtr
' Unicode(W): 文字列は ByVal As LongPtr とし StrPtr(unicodeStr) を渡す
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
LoadCursorW = ctypes.windll.user32.LoadCursorW
LoadCursorW.restype = ctypes.c_void_p
LoadCursorW.argtypes = [
wintypes.HANDLE, # hInstance : HINSTANCE optional
wintypes.LPCWSTR, # lpCursorName : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('USER32.dll')
LoadCursorW = Fiddle::Function.new(
lib['LoadCursorW'],
[
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE optional
Fiddle::TYPE_VOIDP, # lpCursorName : LPCWSTR
],
Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "user32")]
extern "system" {
fn LoadCursorW(
hInstance: *mut core::ffi::c_void, // HINSTANCE optional
lpCursorName: *const u16 // LPCWSTR
) -> *mut core::ffi::c_void;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern IntPtr LoadCursorW(IntPtr hInstance, [MarshalAs(UnmanagedType.LPWStr)] string lpCursorName);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_LoadCursorW' -Namespace Win32 -PassThru
# $api::LoadCursorW(hInstance, lpCursorName)#uselib "USER32.dll"
#func global LoadCursorW "LoadCursorW" wptr, wptr
; LoadCursorW hInstance, lpCursorName ; 戻り値は stat
; hInstance : HINSTANCE optional -> "wptr"
; lpCursorName : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "USER32.dll"
#cfunc global LoadCursorW "LoadCursorW" sptr, wstr
; res = LoadCursorW(hInstance, lpCursorName)
; hInstance : HINSTANCE optional -> "sptr"
; lpCursorName : LPCWSTR -> "wstr"; HCURSOR LoadCursorW(HINSTANCE hInstance, LPCWSTR lpCursorName)
#uselib "USER32.dll"
#cfunc global LoadCursorW "LoadCursorW" intptr, wstr
; res = LoadCursorW(hInstance, lpCursorName)
; hInstance : HINSTANCE optional -> "intptr"
; lpCursorName : LPCWSTR -> "wstr"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
user32 = windows.NewLazySystemDLL("USER32.dll")
procLoadCursorW = user32.NewProc("LoadCursorW")
)
// hInstance (HINSTANCE optional), lpCursorName (LPCWSTR)
r1, _, err := procLoadCursorW.Call(
uintptr(hInstance),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpCursorName))),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HCURSORfunction LoadCursorW(
hInstance: THandle; // HINSTANCE optional
lpCursorName: PWideChar // LPCWSTR
): THandle; stdcall;
external 'USER32.dll' name 'LoadCursorW';result := DllCall("USER32\LoadCursorW"
, "Ptr", hInstance ; HINSTANCE optional
, "WStr", lpCursorName ; LPCWSTR
, "Ptr") ; return: HCURSOR●LoadCursorW(hInstance, lpCursorName) = DLL("USER32.dll", "void* LoadCursorW(void*, char*)")
# 呼び出し: LoadCursorW(hInstance, lpCursorName)
# hInstance : HINSTANCE optional -> "void*"
# lpCursorName : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。