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

SoftwareUpdateMessageBox

関数
ソフトウェア更新を通知するメッセージボックスを表示する。
DLLSHDOCVW.dll呼出規約winapi対応OSWindows 2000 以降

シグネチャ

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

DWORD SoftwareUpdateMessageBox(
    HWND hWnd,   // optional
    LPCWSTR pszDistUnit,
    DWORD dwFlags,
    SOFTDISTINFO* psdi   // optional
);

パラメーター

名前方向説明
hWndHWNDinoptional親ウィンドウへのハンドル。
pszDistUnitLPCWSTRinコード配布単位の識別子を格納する文字列値。ActiveX コントロールの場合、pszDistUnit は通常 GUID です。
dwFlagsDWORDin予約済み。ゼロに設定する必要があります。
psdiSOFTDISTINFO*outoptionalSOFTDISTINFO 構造体へのポインター。このメソッドが正常に返ると、更新情報を受け取ります。cbSize メンバーは sizeof(SOFTDISTINFO) に初期化する必要があります。

戻り値の型: DWORD

公式ドキュメント

アプリケーションが更新されたことをユーザーに通知するために使用できる標準的なメッセージボックスを表示します。

戻り値

型: DWORD

次のいずれかの値を返します。

戻り値 説明
IDNO
ユーザーがダイアログボックスの Do Not Update ボタンをクリックしました。
IDYES
ユーザーが Update Now または About Update ボタンをクリックしました。アプリケーションは、psdi が指す構造体の szHREF メンバーで参照される HTML ページに移動する必要があります。
IDIGNORE
保留中のソフトウェア更新はありません。
IDABORT
エラーが発生しました。

解説(Remarks)

更新を処理する推奨される方法は、Open Software Description (OSD) ボキャブラリを使用して Channel Definition Format (CDF) を作成し、ショートカットを OSD 対応にすることです。詳細については、Channel Definition Format のドキュメントを参照してください。

SoftwareUpdateMessageBox 関数は、シェルショートカットフックが機能しない場合に使用することを目的としています。一例として、スタートメニューにインストールされていないアプリケーションが挙げられます。そのようなアプリケーションが独自のソフトウェア更新チェックを行う必要がある場合は、この関数を使用する必要があります。

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

各言語での呼び出し定義

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

DWORD SoftwareUpdateMessageBox(
    HWND hWnd,   // optional
    LPCWSTR pszDistUnit,
    DWORD dwFlags,
    SOFTDISTINFO* psdi   // optional
);
[DllImport("SHDOCVW.dll", ExactSpelling = true)]
static extern uint SoftwareUpdateMessageBox(
    IntPtr hWnd,   // HWND optional
    [MarshalAs(UnmanagedType.LPWStr)] string pszDistUnit,   // LPCWSTR
    uint dwFlags,   // DWORD
    IntPtr psdi   // SOFTDISTINFO* optional, out
);
<DllImport("SHDOCVW.dll", ExactSpelling:=True)>
Public Shared Function SoftwareUpdateMessageBox(
    hWnd As IntPtr,   ' HWND optional
    <MarshalAs(UnmanagedType.LPWStr)> pszDistUnit As String,   ' LPCWSTR
    dwFlags As UInteger,   ' DWORD
    psdi As IntPtr   ' SOFTDISTINFO* optional, out
) As UInteger
End Function
' hWnd : HWND optional
' pszDistUnit : LPCWSTR
' dwFlags : DWORD
' psdi : SOFTDISTINFO* optional, out
Declare PtrSafe Function SoftwareUpdateMessageBox Lib "shdocvw" ( _
    ByVal hWnd As LongPtr, _
    ByVal pszDistUnit As LongPtr, _
    ByVal dwFlags As Long, _
    ByVal psdi As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。
import ctypes
from ctypes import wintypes

SoftwareUpdateMessageBox = ctypes.windll.shdocvw.SoftwareUpdateMessageBox
SoftwareUpdateMessageBox.restype = wintypes.DWORD
SoftwareUpdateMessageBox.argtypes = [
    wintypes.HANDLE,  # hWnd : HWND optional
    wintypes.LPCWSTR,  # pszDistUnit : LPCWSTR
    wintypes.DWORD,  # dwFlags : DWORD
    ctypes.c_void_p,  # psdi : SOFTDISTINFO* optional, out
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('SHDOCVW.dll')
SoftwareUpdateMessageBox = Fiddle::Function.new(
  lib['SoftwareUpdateMessageBox'],
  [
    Fiddle::TYPE_VOIDP,  # hWnd : HWND optional
    Fiddle::TYPE_VOIDP,  # pszDistUnit : LPCWSTR
    -Fiddle::TYPE_INT,  # dwFlags : DWORD
    Fiddle::TYPE_VOIDP,  # psdi : SOFTDISTINFO* optional, out
  ],
  -Fiddle::TYPE_INT)
#[link(name = "shdocvw")]
extern "system" {
    fn SoftwareUpdateMessageBox(
        hWnd: *mut core::ffi::c_void,  // HWND optional
        pszDistUnit: *const u16,  // LPCWSTR
        dwFlags: u32,  // DWORD
        psdi: *mut SOFTDISTINFO  // SOFTDISTINFO* optional, out
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("SHDOCVW.dll")]
public static extern uint SoftwareUpdateMessageBox(IntPtr hWnd, [MarshalAs(UnmanagedType.LPWStr)] string pszDistUnit, uint dwFlags, IntPtr psdi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'SHDOCVW_SoftwareUpdateMessageBox' -Namespace Win32 -PassThru
# $api::SoftwareUpdateMessageBox(hWnd, pszDistUnit, dwFlags, psdi)
#uselib "SHDOCVW.dll"
#func global SoftwareUpdateMessageBox "SoftwareUpdateMessageBox" sptr, sptr, sptr, sptr
; SoftwareUpdateMessageBox hWnd, pszDistUnit, dwFlags, varptr(psdi)   ; 戻り値は stat
; hWnd : HWND optional -> "sptr"
; pszDistUnit : LPCWSTR -> "sptr"
; dwFlags : DWORD -> "sptr"
; psdi : SOFTDISTINFO* optional, out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
出力引数:
#uselib "SHDOCVW.dll"
#cfunc global SoftwareUpdateMessageBox "SoftwareUpdateMessageBox" sptr, wstr, int, var
; res = SoftwareUpdateMessageBox(hWnd, pszDistUnit, dwFlags, psdi)
; hWnd : HWND optional -> "sptr"
; pszDistUnit : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; psdi : SOFTDISTINFO* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
出力引数:
; DWORD SoftwareUpdateMessageBox(HWND hWnd, LPCWSTR pszDistUnit, DWORD dwFlags, SOFTDISTINFO* psdi)
#uselib "SHDOCVW.dll"
#cfunc global SoftwareUpdateMessageBox "SoftwareUpdateMessageBox" intptr, wstr, int, var
; res = SoftwareUpdateMessageBox(hWnd, pszDistUnit, dwFlags, psdi)
; hWnd : HWND optional -> "intptr"
; pszDistUnit : LPCWSTR -> "wstr"
; dwFlags : DWORD -> "int"
; psdi : SOFTDISTINFO* optional, out -> "var"
; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	shdocvw = windows.NewLazySystemDLL("SHDOCVW.dll")
	procSoftwareUpdateMessageBox = shdocvw.NewProc("SoftwareUpdateMessageBox")
)

// hWnd (HWND optional), pszDistUnit (LPCWSTR), dwFlags (DWORD), psdi (SOFTDISTINFO* optional, out)
r1, _, err := procSoftwareUpdateMessageBox.Call(
	uintptr(hWnd),
	uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(pszDistUnit))),
	uintptr(dwFlags),
	uintptr(psdi),
)
_ = err  // syscall.Errno (valid when the call sets last-error)
_ = r1   // DWORD
function SoftwareUpdateMessageBox(
  hWnd: THandle;   // HWND optional
  pszDistUnit: PWideChar;   // LPCWSTR
  dwFlags: DWORD;   // DWORD
  psdi: Pointer   // SOFTDISTINFO* optional, out
): DWORD; stdcall;
  external 'SHDOCVW.dll' name 'SoftwareUpdateMessageBox';
result := DllCall("SHDOCVW\SoftwareUpdateMessageBox"
    , "Ptr", hWnd   ; HWND optional
    , "WStr", pszDistUnit   ; LPCWSTR
    , "UInt", dwFlags   ; DWORD
    , "Ptr", psdi   ; SOFTDISTINFO* optional, out
    , "UInt")   ; return: DWORD
●SoftwareUpdateMessageBox(hWnd, pszDistUnit, dwFlags, psdi) = DLL("SHDOCVW.dll", "dword SoftwareUpdateMessageBox(void*, char*, dword, void*)")
# 呼び出し: SoftwareUpdateMessageBox(hWnd, pszDistUnit, dwFlags, psdi)
# hWnd : HWND optional -> "void*"
# pszDistUnit : LPCWSTR -> "char*"
# dwFlags : DWORD -> "dword"
# psdi : SOFTDISTINFO* optional, out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。
const std = @import("std");

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

typedef SoftwareUpdateMessageBoxNative = Uint32 Function(Pointer<Void>, Pointer<Utf16>, Uint32, Pointer<Void>);
typedef SoftwareUpdateMessageBoxDart = int Function(Pointer<Void>, Pointer<Utf16>, int, Pointer<Void>);
final SoftwareUpdateMessageBox = DynamicLibrary.open('SHDOCVW.dll')
    .lookupFunction<SoftwareUpdateMessageBoxNative, SoftwareUpdateMessageBoxDart>('SoftwareUpdateMessageBox');
// hWnd : HWND optional -> Pointer<Void>
// pszDistUnit : LPCWSTR -> Pointer<Utf16>
// dwFlags : DWORD -> Uint32
// psdi : SOFTDISTINFO* optional, out -> Pointer<Void>
// 文字列は package:ffi の "...".toNativeUtf16()/toNativeUtf8() で変換。
{$mode objfpc}{$H+}
function SoftwareUpdateMessageBox(
  hWnd: THandle;   // HWND optional
  pszDistUnit: PWideChar;   // LPCWSTR
  dwFlags: DWORD;   // DWORD
  psdi: Pointer   // SOFTDISTINFO* optional, out
): DWORD; stdcall;
  external 'SHDOCVW.dll' name 'SoftwareUpdateMessageBox';
import Foreign
import Foreign.C.Types
import Foreign.C.String

foreign import stdcall safe "SoftwareUpdateMessageBox"
  c_SoftwareUpdateMessageBox :: Ptr () -> CWString -> Word32 -> Ptr () -> IO Word32
-- hWnd : HWND optional -> Ptr ()
-- pszDistUnit : LPCWSTR -> CWString
-- dwFlags : DWORD -> Word32
-- psdi : SOFTDISTINFO* optional, out -> Ptr ()
-- 要 GHC(Windows)。stdcall は x64 では ccall として扱われる。ブロックする API は safe 呼び出し推奨。
open Ctypes
open Foreign

let softwareupdatemessagebox =
  foreign "SoftwareUpdateMessageBox"
    ((ptr void) @-> (ptr uint16_t) @-> uint32_t @-> (ptr void) @-> returning uint32_t)
(* hWnd : HWND optional -> (ptr void) *)
(* pszDistUnit : LPCWSTR -> (ptr uint16_t) *)
(* dwFlags : DWORD -> uint32_t *)
(* psdi : SOFTDISTINFO* optional, out -> (ptr void) *)
(* foreign は cdecl 前提。x64 Windows では WINAPI と一致。構造体は ctypes structure を定義のこと。 *)
(cffi:define-foreign-library shdocvw (t "SHDOCVW.dll"))
(cffi:use-foreign-library shdocvw)

(cffi:defcfun ("SoftwareUpdateMessageBox" software-update-message-box :convention :stdcall) :uint32
  (h-wnd :pointer)   ; HWND optional
  (psz-dist-unit (:string :encoding :utf-16le))   ; LPCWSTR
  (dw-flags :uint32)   ; DWORD
  (psdi :pointer))   ; SOFTDISTINFO* optional, out
; isize/usize(INT_PTR/SIZE_T)は x64 前提で :int64/:uint64。x86 では :int32/:uint32。
use Win32::API;
my $SoftwareUpdateMessageBox = Win32::API::More->new('SHDOCVW',
    'DWORD SoftwareUpdateMessageBox(HANDLE hWnd, LPCWSTR pszDistUnit, DWORD dwFlags, LPVOID psdi)');
# my $ret = $SoftwareUpdateMessageBox->Call($hWnd, $pszDistUnit, $dwFlags, $psdi);
# hWnd : HWND optional -> HANDLE
# pszDistUnit : LPCWSTR -> LPCWSTR
# dwFlags : DWORD -> DWORD
# psdi : SOFTDISTINFO* optional, out -> LPVOID
# 値渡し構造体は pack() した文字列、または Win32::API::Struct を使用。

関連項目

使用する型