ホーム › System.WindowsProgramming › UserUnInstStubWrapperW
UserUnInstStubWrapperW
関数ユーザー単位アンインストールのスタブをラップ実行する(Unicode版)。
シグネチャ
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT UserUnInstStubWrapperW(
HWND hwnd,
HINSTANCE hInstance,
LPCWSTR pszParms,
INT nShow
);パラメーター
| 名前 | 型 | 方向 | 説明 |
|---|---|---|---|
| hwnd | HWND | in | UIの親となるウィンドウのハンドル。NULL可。 |
| hInstance | HINSTANCE | in | 呼び出し元モジュールのインスタンスハンドル。 |
| pszParms | LPCWSTR | in | アンインストール対象のCLSID等を含むパラメーター文字列。 |
| nShow | INT | in | ウィンドウの表示状態を指定するSW_系の値。 |
戻り値の型: HRESULT
各言語での呼び出し定義
// ADVPACK.dll (Unicode / -W)
#include <windows.h>
HRESULT UserUnInstStubWrapperW(
HWND hwnd,
HINSTANCE hInstance,
LPCWSTR pszParms,
INT nShow
);[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int UserUnInstStubWrapperW(
IntPtr hwnd, // HWND
IntPtr hInstance, // HINSTANCE
[MarshalAs(UnmanagedType.LPWStr)] string pszParms, // LPCWSTR
int nShow // INT
);<DllImport("ADVPACK.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function UserUnInstStubWrapperW(
hwnd As IntPtr, ' HWND
hInstance As IntPtr, ' HINSTANCE
<MarshalAs(UnmanagedType.LPWStr)> pszParms As String, ' LPCWSTR
nShow As Integer ' INT
) As Integer
End Function' hwnd : HWND
' hInstance : HINSTANCE
' pszParms : LPCWSTR
' nShow : INT
Declare PtrSafe Function UserUnInstStubWrapperW Lib "advpack" ( _
ByVal hwnd As LongPtr, _
ByVal hInstance As LongPtr, _
ByVal pszParms As LongPtr, _
ByVal nShow As Long) As Long
' 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
UserUnInstStubWrapperW = ctypes.windll.advpack.UserUnInstStubWrapperW
UserUnInstStubWrapperW.restype = ctypes.c_int
UserUnInstStubWrapperW.argtypes = [
wintypes.HANDLE, # hwnd : HWND
wintypes.HANDLE, # hInstance : HINSTANCE
wintypes.LPCWSTR, # pszParms : LPCWSTR
ctypes.c_int, # nShow : INT
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('ADVPACK.dll')
UserUnInstStubWrapperW = Fiddle::Function.new(
lib['UserUnInstStubWrapperW'],
[
Fiddle::TYPE_VOIDP, # hwnd : HWND
Fiddle::TYPE_VOIDP, # hInstance : HINSTANCE
Fiddle::TYPE_VOIDP, # pszParms : LPCWSTR
Fiddle::TYPE_INT, # nShow : INT
],
Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"#[link(name = "advpack")]
extern "system" {
fn UserUnInstStubWrapperW(
hwnd: *mut core::ffi::c_void, // HWND
hInstance: *mut core::ffi::c_void, // HINSTANCE
pszParms: *const u16, // LPCWSTR
nShow: i32 // INT
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("ADVPACK.dll", CharSet = CharSet.Unicode)]
public static extern int UserUnInstStubWrapperW(IntPtr hwnd, IntPtr hInstance, [MarshalAs(UnmanagedType.LPWStr)] string pszParms, int nShow);
"@
$api = Add-Type -MemberDefinition $sig -Name 'ADVPACK_UserUnInstStubWrapperW' -Namespace Win32 -PassThru
# $api::UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)#uselib "ADVPACK.dll"
#func global UserUnInstStubWrapperW "UserUnInstStubWrapperW" wptr, wptr, wptr, wptr
; UserUnInstStubWrapperW hwnd, hInstance, pszParms, nShow ; 戻り値は stat
; hwnd : HWND -> "wptr"
; hInstance : HINSTANCE -> "wptr"
; pszParms : LPCWSTR -> "wptr"
; nShow : INT -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。#uselib "ADVPACK.dll"
#cfunc global UserUnInstStubWrapperW "UserUnInstStubWrapperW" sptr, sptr, wstr, int
; res = UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)
; hwnd : HWND -> "sptr"
; hInstance : HINSTANCE -> "sptr"
; pszParms : LPCWSTR -> "wstr"
; nShow : INT -> "int"; HRESULT UserUnInstStubWrapperW(HWND hwnd, HINSTANCE hInstance, LPCWSTR pszParms, INT nShow)
#uselib "ADVPACK.dll"
#cfunc global UserUnInstStubWrapperW "UserUnInstStubWrapperW" intptr, intptr, wstr, int
; res = UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)
; hwnd : HWND -> "intptr"
; hInstance : HINSTANCE -> "intptr"
; pszParms : LPCWSTR -> "wstr"
; nShow : INT -> "int"import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
advpack = windows.NewLazySystemDLL("ADVPACK.dll")
procUserUnInstStubWrapperW = advpack.NewProc("UserUnInstStubWrapperW")
)
// hwnd (HWND), hInstance (HINSTANCE), pszParms (LPCWSTR), nShow (INT)
r1, _, err := procUserUnInstStubWrapperW.Call(
uintptr(hwnd),
uintptr(hInstance),
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszParms))),
uintptr(nShow),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction UserUnInstStubWrapperW(
hwnd: THandle; // HWND
hInstance: THandle; // HINSTANCE
pszParms: PWideChar; // LPCWSTR
nShow: Integer // INT
): Integer; stdcall;
external 'ADVPACK.dll' name 'UserUnInstStubWrapperW';result := DllCall("ADVPACK\UserUnInstStubWrapperW"
, "Ptr", hwnd ; HWND
, "Ptr", hInstance ; HINSTANCE
, "WStr", pszParms ; LPCWSTR
, "Int", nShow ; INT
, "Int") ; return: HRESULT●UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow) = DLL("ADVPACK.dll", "int UserUnInstStubWrapperW(void*, void*, char*, int)")
# 呼び出し: UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)
# hwnd : HWND -> "void*"
# hInstance : HINSTANCE -> "void*"
# pszParms : LPCWSTR -> "char*"
# nShow : INT -> "int"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
# ※-W(Unicode)関数。なでしこ1はANSIのため -A 版の利用を推奨。const std = @import("std");
extern "advpack" fn UserUnInstStubWrapperW(
hwnd: ?*anyopaque, // HWND
hInstance: ?*anyopaque, // HINSTANCE
pszParms: [*c]const u16, // LPCWSTR
nShow: i32 // INT
) callconv(std.os.windows.WINAPI) i32;
// Unicode(-W): UTF-16LE のヌル終端バッファ([*c]const u16)を渡す。proc UserUnInstStubWrapperW(
hwnd: pointer, # HWND
hInstance: pointer, # HINSTANCE
pszParms: WideCString, # LPCWSTR
nShow: int32 # INT
): int32 {.importc: "UserUnInstStubWrapperW", stdcall, dynlib: "ADVPACK.dll".}
# Unicode(-W): WideCString は newWideCString("...") で生成。pragma(lib, "advpack");
extern(Windows)
int UserUnInstStubWrapperW(
void* hwnd, // HWND
void* hInstance, // HINSTANCE
const(wchar)* pszParms, // LPCWSTR
int nShow // INT
);ccall((:UserUnInstStubWrapperW, "ADVPACK.dll"), stdcall, Int32,
(Ptr{Cvoid}, Ptr{Cvoid}, Cwstring, Int32),
hwnd, hInstance, pszParms, nShow)
# hwnd : HWND -> Ptr{Cvoid}
# hInstance : HINSTANCE -> Ptr{Cvoid}
# pszParms : LPCWSTR -> Cwstring
# nShow : INT -> Int32
# stdcall は 32bit のみ意味を持つ(x64 では無視)。
# Unicode(-W): Cwstring には transcode(UInt16, "...") 等で UTF-16 を渡す。local ffi = require("ffi")
ffi.cdef[[
int32_t UserUnInstStubWrapperW(
void* hwnd,
void* hInstance,
const uint16_t* pszParms,
int32_t nShow);
]]
local advpack = ffi.load("advpack")
-- advpack.UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)
-- hwnd : HWND
-- hInstance : HINSTANCE
-- pszParms : LPCWSTR
-- nShow : INT
-- 構造体/GUIDへのポインタは cdef が通るよう void* で表記(実型は各引数コメント参照)。値渡し構造体・enum は対応する typedef を cdef に追加すること。
-- Unicode(-W): uint16_t* には UTF-16LE のバッファ(ffi.new("uint16_t[?]", ...))を渡す。const koffi = require('koffi');
const lib = koffi.load('ADVPACK.dll');
const UserUnInstStubWrapperW = lib.func('__stdcall', 'UserUnInstStubWrapperW', 'int32_t', ['void *', 'void *', 'str16', 'int32_t']);
// UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)
// hwnd : HWND -> 'void *'
// hInstance : HINSTANCE -> 'void *'
// pszParms : LPCWSTR -> 'str16'
// nShow : INT -> 'int32_t'
// 出力ポインタは koffi.out(...) で包む。構造体は koffi.struct で定義。const lib = Deno.dlopen("ADVPACK.dll", {
UserUnInstStubWrapperW: { parameters: ["pointer", "pointer", "buffer", "i32"], result: "i32" },
});
// lib.symbols.UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow)
// hwnd : HWND -> "pointer"
// hInstance : HINSTANCE -> "pointer"
// pszParms : LPCWSTR -> "buffer"
// nShow : INT -> "i32"
// 文字列は "buffer"。Unicode(-W) は new TextEncoder() ではなく UTF-16LE のバイト列(末尾に \x00\x00)を Uint8Array で渡す。
// 値渡し構造体は { struct: [ ...field types... ] } を使用。<?php
$ffi = FFI::cdef(<<<C
int32_t UserUnInstStubWrapperW(
void* hwnd,
void* hInstance,
const uint16_t* pszParms,
int32_t nShow);
C, "ADVPACK.dll");
// $ffi->UserUnInstStubWrapperW(hwnd, hInstance, pszParms, nShow);
// hwnd : HWND
// hInstance : HINSTANCE
// pszParms : LPCWSTR
// nShow : INT
// 構造体/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 Advpack extends StdCallLibrary {
Advpack INSTANCE = Native.load("advpack", Advpack.class, W32APIOptions.UNICODE_OPTIONS);
int UserUnInstStubWrapperW(
Pointer hwnd, // HWND
Pointer hInstance, // HINSTANCE
WString pszParms, // LPCWSTR
int nShow // INT
);
}
// Unicode(-W): WString(入力)/char[](出力)で UTF-16 をマーシャリング。@[Link("advpack")]
lib LibADVPACK
fun UserUnInstStubWrapperW = UserUnInstStubWrapperW(
hwnd : Void*, # HWND
hInstance : Void*, # HINSTANCE
pszParms : UInt16*, # LPCWSTR
nShow : Int32 # INT
) : Int32
end
# 構造体/GUID/enum は lib 内に対応する型定義が必要。
# 呼出規約: x64 は規約統一のため OK。x86(32bit)は WINAPI=stdcall だが Crystal の fun に stdcall 付与構文がなく非対応。import 'dart:ffi';
import 'package:ffi/ffi.dart';
typedef UserUnInstStubWrapperWNative = Int32 Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, Int32);
typedef UserUnInstStubWrapperWDart = int Function(Pointer<Void>, Pointer<Void>, Pointer<Utf16>, int);
final UserUnInstStubWrapperW = DynamicLibrary.open('ADVPACK.dll')
.lookupFunction<UserUnInstStubWrapperWNative, UserUnInstStubWrapperWDart>('UserUnInstStubWrapperW');
// hwnd : HWND -> Pointer<Void>
// hInstance : HINSTANCE -> Pointer<Void>
// pszParms : LPCWSTR -> Pointer<Utf16>
// nShow : INT -> Int32
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。{$mode objfpc}{$H+}
function UserUnInstStubWrapperW(
hwnd: THandle; // HWND
hInstance: THandle; // HINSTANCE
pszParms: PWideChar; // LPCWSTR
nShow: Integer // INT
): Integer; stdcall;
external 'ADVPACK.dll' name 'UserUnInstStubWrapperW';import Foreign
import Foreign.C.Types
import Foreign.C.String
foreign import stdcall safe "UserUnInstStubWrapperW"
c_UserUnInstStubWrapperW :: Ptr () -> Ptr () -> CWString -> Int32 -> IO Int32
-- hwnd : HWND -> Ptr ()
-- hInstance : HINSTANCE -> Ptr ()
-- pszParms : LPCWSTR -> CWString
-- nShow : INT -> Int32
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。open Ctypes
open Foreign
let useruninststubwrapperw =
foreign "UserUnInstStubWrapperW"
((ptr void) @-> (ptr void) @-> (ptr uint16_t) @-> int32_t @-> returning int32_t)
(* hwnd : HWND -> (ptr void) *)
(* hInstance : HINSTANCE -> (ptr void) *)
(* pszParms : LPCWSTR -> (ptr uint16_t) *)
(* nShow : INT -> int32_t *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)(cffi:define-foreign-library advpack (t "ADVPACK.dll"))
(cffi:use-foreign-library advpack)
(cffi:defcfun ("UserUnInstStubWrapperW" user-un-inst-stub-wrapper-w :convention :stdcall) :int32
(hwnd :pointer) ; HWND
(h-instance :pointer) ; HINSTANCE
(psz-parms (:string :encoding :utf-16le)) ; LPCWSTR
(n-show :int32)) ; INT
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。use Win32::API;
my $UserUnInstStubWrapperW = Win32::API::More->new('ADVPACK',
'int UserUnInstStubWrapperW(HANDLE hwnd, HANDLE hInstance, LPCWSTR pszParms, int nShow)');
# my $ret = $UserUnInstStubWrapperW->Call($hwnd, $hInstance, $pszParms, $nShow);
# hwnd : HWND -> HANDLE
# hInstance : HINSTANCE -> HANDLE
# pszParms : LPCWSTR -> LPCWSTR
# nShow : INT -> int
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。
# Unicode(-W): LPCWSTR/LPWSTR は Win32::API が UTF-16 変換を行う。関連項目
文字セット違い
- f UserUnInstStubWrapperA (ANSI版) — ユーザー単位アンインストールのスタブをラップ実行する(ANSI版)。