ホーム › System.Com.Urlmon › GetSoftwareUpdateInfo
GetSoftwareUpdateInfo
関数指定した配布ユニットのソフトウェア更新情報を取得する。
シグネチャ
// urlmon.dll
#include <windows.h>
HRESULT GetSoftwareUpdateInfo(
LPCWSTR szDistUnit,
SOFTDISTINFO* psdi
);パラメーター
| 名前 | 型 | 方向 |
|---|---|---|
| szDistUnit | LPCWSTR | in |
| psdi | SOFTDISTINFO* | out |
戻り値の型: HRESULT
各言語での呼び出し定義
// urlmon.dll
#include <windows.h>
HRESULT GetSoftwareUpdateInfo(
LPCWSTR szDistUnit,
SOFTDISTINFO* psdi
);[DllImport("urlmon.dll", ExactSpelling = true)]
static extern int GetSoftwareUpdateInfo(
[MarshalAs(UnmanagedType.LPWStr)] string szDistUnit, // LPCWSTR
IntPtr psdi // SOFTDISTINFO* out
);<DllImport("urlmon.dll", ExactSpelling:=True)>
Public Shared Function GetSoftwareUpdateInfo(
<MarshalAs(UnmanagedType.LPWStr)> szDistUnit As String, ' LPCWSTR
psdi As IntPtr ' SOFTDISTINFO* out
) As Integer
End Function' szDistUnit : LPCWSTR
' psdi : SOFTDISTINFO* out
Declare PtrSafe Function GetSoftwareUpdateInfo Lib "urlmon" ( _
ByVal szDistUnit As LongPtr, _
ByVal psdi As LongPtr) As Long
' VBA7前提(PtrSafe)。32bit Office では LongPtr→Long。Integer=16bit / Long=32bit / LongLong=64bit。import ctypes
from ctypes import wintypes
GetSoftwareUpdateInfo = ctypes.windll.urlmon.GetSoftwareUpdateInfo
GetSoftwareUpdateInfo.restype = ctypes.c_int
GetSoftwareUpdateInfo.argtypes = [
wintypes.LPCWSTR, # szDistUnit : LPCWSTR
ctypes.c_void_p, # psdi : SOFTDISTINFO* out
]require 'fiddle'
require 'fiddle/import'
lib = Fiddle.dlopen('urlmon.dll')
GetSoftwareUpdateInfo = Fiddle::Function.new(
lib['GetSoftwareUpdateInfo'],
[
Fiddle::TYPE_VOIDP, # szDistUnit : LPCWSTR
Fiddle::TYPE_VOIDP, # psdi : SOFTDISTINFO* out
],
Fiddle::TYPE_INT)#[link(name = "urlmon")]
extern "system" {
fn GetSoftwareUpdateInfo(
szDistUnit: *const u16, // LPCWSTR
psdi: *mut SOFTDISTINFO // SOFTDISTINFO* out
) -> i32;
}
// crates: windows-sys provides ready-made bindings for this API.$sig = @"
[DllImport("urlmon.dll")]
public static extern int GetSoftwareUpdateInfo([MarshalAs(UnmanagedType.LPWStr)] string szDistUnit, IntPtr psdi);
"@
$api = Add-Type -MemberDefinition $sig -Name 'urlmon_GetSoftwareUpdateInfo' -Namespace Win32 -PassThru
# $api::GetSoftwareUpdateInfo(szDistUnit, psdi)#uselib "urlmon.dll"
#func global GetSoftwareUpdateInfo "GetSoftwareUpdateInfo" sptr, sptr
; GetSoftwareUpdateInfo szDistUnit, varptr(psdi) ; 戻り値は stat
; szDistUnit : LPCWSTR -> "sptr"
; psdi : SOFTDISTINFO* out -> "sptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。出力引数:
#uselib "urlmon.dll" #cfunc global GetSoftwareUpdateInfo "GetSoftwareUpdateInfo" wstr, var ; res = GetSoftwareUpdateInfo(szDistUnit, psdi) ; szDistUnit : LPCWSTR -> "wstr" ; psdi : SOFTDISTINFO* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。#uselib "urlmon.dll" #cfunc global GetSoftwareUpdateInfo "GetSoftwareUpdateInfo" wstr, sptr ; res = GetSoftwareUpdateInfo(szDistUnit, varptr(psdi)) ; szDistUnit : LPCWSTR -> "wstr" ; psdi : SOFTDISTINFO* out -> "sptr" ; ※出力/バッファ引数はポインタ方式(token=sptr / 呼び出しは varptr(変数))。
出力引数:
; HRESULT GetSoftwareUpdateInfo(LPCWSTR szDistUnit, SOFTDISTINFO* psdi) #uselib "urlmon.dll" #cfunc global GetSoftwareUpdateInfo "GetSoftwareUpdateInfo" wstr, var ; res = GetSoftwareUpdateInfo(szDistUnit, psdi) ; szDistUnit : LPCWSTR -> "wstr" ; psdi : SOFTDISTINFO* out -> "var" ; ※出力/バッファ引数は var 方式(変数を直接渡す)。varptr 方式にも切替可。; HRESULT GetSoftwareUpdateInfo(LPCWSTR szDistUnit, SOFTDISTINFO* psdi) #uselib "urlmon.dll" #cfunc global GetSoftwareUpdateInfo "GetSoftwareUpdateInfo" wstr, intptr ; res = GetSoftwareUpdateInfo(szDistUnit, varptr(psdi)) ; szDistUnit : LPCWSTR -> "wstr" ; psdi : SOFTDISTINFO* out -> "intptr" ; ※出力/バッファ引数はポインタ方式(token=intptr / 呼び出しは varptr(変数))。
import (
"golang.org/x/sys/windows"
"unsafe"
)
var (
urlmon = windows.NewLazySystemDLL("urlmon.dll")
procGetSoftwareUpdateInfo = urlmon.NewProc("GetSoftwareUpdateInfo")
)
// szDistUnit (LPCWSTR), psdi (SOFTDISTINFO* out)
r1, _, err := procGetSoftwareUpdateInfo.Call(
uintptr(unsafe.Pointer(windows.StringToUTF16Ptr(szDistUnit))),
uintptr(psdi),
)
_ = err // syscall.Errno (valid when the call sets last-error)
_ = r1 // HRESULTfunction GetSoftwareUpdateInfo(
szDistUnit: PWideChar; // LPCWSTR
psdi: Pointer // SOFTDISTINFO* out
): Integer; stdcall;
external 'urlmon.dll' name 'GetSoftwareUpdateInfo';result := DllCall("urlmon\GetSoftwareUpdateInfo"
, "WStr", szDistUnit ; LPCWSTR
, "Ptr", psdi ; SOFTDISTINFO* out
, "Int") ; return: HRESULT●GetSoftwareUpdateInfo(szDistUnit, psdi) = DLL("urlmon.dll", "int GetSoftwareUpdateInfo(char*, void*)")
# 呼び出し: GetSoftwareUpdateInfo(szDistUnit, psdi)
# szDistUnit : LPCWSTR -> "char*"
# psdi : SOFTDISTINFO* out -> "void*"
# なでしこ1は32bit・ANSI(Shift_JIS)。文字列=char*(ANSI)、ポインタ/ハンドル=void*(4byte)。