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

RemovePropW

関数
ウィンドウのプロパティリストから項目を削除する(Unicode版)。
DLLUSER32.dll文字セットUnicode (-W)呼出規約winapiSetLastErrorあり対応OSWindows 2000 以降

シグネチャ

// USER32.dll  (Unicode / -W)
#include <windows.h>

HANDLE RemovePropW(
    HWND hWnd,
    LPCWSTR lpString
);

パラメーター

名前方向
hWndHWNDin
lpStringLPCWSTRin

戻り値の型: HANDLE

各言語での呼び出し定義

// USER32.dll  (Unicode / -W)
#include <windows.h>

HANDLE RemovePropW(
    HWND hWnd,
    LPCWSTR lpString
);
[DllImport("USER32.dll", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
static extern IntPtr RemovePropW(
    IntPtr hWnd,   // HWND
    [MarshalAs(UnmanagedType.LPWStr)] string lpString   // LPCWSTR
);
<DllImport("USER32.dll", CharSet:=CharSet.Unicode, SetLastError:=True, ExactSpelling:=True)>
Public Shared Function RemovePropW(
    hWnd As IntPtr,   ' HWND
    <MarshalAs(UnmanagedType.LPWStr)> lpString As String   ' LPCWSTR
) As IntPtr
End Function
' hWnd : HWND
' lpString : LPCWSTR
Declare PtrSafe Function RemovePropW Lib "user32" ( _
    ByVal hWnd As LongPtr, _
    ByVal lpString 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

RemovePropW = ctypes.windll.user32.RemovePropW
RemovePropW.restype = ctypes.c_void_p
RemovePropW.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND
    wintypes.LPCWSTR,  # lpString : LPCWSTR
]
# GetLastError: use ctypes.GetLastError() (or ctypes.WinDLL(use_last_error=True))
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('USER32.dll')
RemovePropW = Fiddle::Function.new(
  lib['RemovePropW'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND
    Fiddle::TYPE_VOIDP,  # lpString : LPCWSTR
  ],
  Fiddle::TYPE_VOIDP)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "user32")]
extern "system" {
    fn RemovePropW(
        hWnd: *mut core::ffi::c_void,  // HWND
        lpString: *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 RemovePropW(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string lpString);
"@
$api = Add-Type -MemberDefinition $sig -Name 'USER32_RemovePropW' -Namespace Win32 -PassThru
# $api::RemovePropW(hWnd, lpString)
#uselib "USER32.dll"
#func global RemovePropW "RemovePropW" wptr, wptr
; RemovePropW hWnd, lpString   ; 戻り値は stat
; hWnd : HWND -> "wptr"
; lpString : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "USER32.dll"
#cfunc global RemovePropW "RemovePropW" sptr, wstr
; res = RemovePropW(hWnd, lpString)
; hWnd : HWND -> "sptr"
; lpString : LPCWSTR -> "wstr"
; HANDLE RemovePropW(HWND hWnd, LPCWSTR lpString)
#uselib "USER32.dll"
#cfunc global RemovePropW "RemovePropW" intptr, wstr
; res = RemovePropW(hWnd, lpString)
; hWnd : HWND -> "intptr"
; lpString : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	user32 = windows.NewLazySystemDLL("USER32.dll")
	procRemovePropW = user32.NewProc("RemovePropW")
)

// hWnd (HWND), lpString (LPCWSTR)
r1, _, err := procRemovePropW.Call(
	uintptr(hWnd),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(lpString))),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // HANDLE
function RemovePropW(
  hWnd: THandle;   // HWND
  lpString: PWideChar   // LPCWSTR
): THandle; stdcall;
  external 'USER32.dll' name 'RemovePropW';
result := DllCall("USER32\RemovePropW"
    , "Ptr", hWnd   ; HWND
    , "WStr", lpString   ; LPCWSTR
    , "Ptr")   ; return: HANDLE
●RemovePropW(hWnd, lpString) = DLL("USER32.dll", "void* RemovePropW(void*, char*)")
# 呼び出し: RemovePropW(hWnd, lpString)
# hWnd : HWND -> "void*"
# lpString : LPCWSTR -> "char*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。