Win32 API 日本語リファレンス
ホームSystem.ApplicationInstallationAndServicing › MsiNotifySidChangeW

MsiNotifySidChangeW

関数
ユーザーSIDの変更をMSIに通知して関連情報を更新する。
DLLmsi.dll文字セットUnicode (-W)呼出規約winapi対応OSwindows8.0

シグネチャ

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

DWORD MsiNotifySidChangeW(
    LPCWSTR pOldSid,
    LPCWSTR pNewSid
);

パラメーター

名前方向
pOldSidLPCWSTRin
pNewSidLPCWSTRin

戻り値の型: DWORD

各言語での呼び出し定義

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

DWORD MsiNotifySidChangeW(
    LPCWSTR pOldSid,
    LPCWSTR pNewSid
);
[DllImport("msi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern uint MsiNotifySidChangeW(
    [MarshalAs(UnmanagedType.LPWStr)] string pOldSid,   // LPCWSTR
    [MarshalAs(UnmanagedType.LPWStr)] string pNewSid   // LPCWSTR
);
<DllImport("msi.dll", CharSet:=CharSet.Unicode, ExactSpelling:=True)>
Public Shared Function MsiNotifySidChangeW(
    <MarshalAs(UnmanagedType.LPWStr)> pOldSid As String,   ' LPCWSTR
    <MarshalAs(UnmanagedType.LPWStr)> pNewSid As String   ' LPCWSTR
) As UInteger
End Function
' pOldSid : LPCWSTR
' pNewSid : LPCWSTR
Declare PtrSafe Function MsiNotifySidChangeW Lib "msi" ( _
    ByVal pOldSid As LongPtr, _
    ByVal pNewSid As LongPtr) 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

MsiNotifySidChangeW = ctypes.windll.msi.MsiNotifySidChangeW
MsiNotifySidChangeW.restype = wintypes.DWORD
MsiNotifySidChangeW.argtypes = [
    wintypes.LPCWSTR,  # pOldSid : LPCWSTR
    wintypes.LPCWSTR,  # pNewSid : LPCWSTR
]
require 'fiddle'
require 'fiddle/import'

lib = Fiddle.dlopen('msi.dll')
MsiNotifySidChangeW = Fiddle::Function.new(
  lib['MsiNotifySidChangeW'],
  [
    Fiddle::TYPE_VOIDP,  # pOldSid : LPCWSTR
    Fiddle::TYPE_VOIDP,  # pNewSid : LPCWSTR
  ],
  -Fiddle::TYPE_INT)
# Wide strings: pass str.encode("UTF-16LE") + "\x00\x00"
#[link(name = "msi")]
extern "system" {
    fn MsiNotifySidChangeW(
        pOldSid: *const u16,  // LPCWSTR
        pNewSid: *const u16  // LPCWSTR
    ) -> u32;
}
// crates: windows-sys provides ready-made bindings for this API.
$sig = @"
[DllImport("msi.dll", CharSet = CharSet.Unicode)]
public static extern uint MsiNotifySidChangeW([MarshalAs(UnmanagedType.LPWStr)] string pOldSid, [MarshalAs(UnmanagedType.LPWStr)] string pNewSid);
"@
$api = Add-Type -MemberDefinition $sig -Name 'msi_MsiNotifySidChangeW' -Namespace Win32 -PassThru
# $api::MsiNotifySidChangeW(pOldSid, pNewSid)
#uselib "msi.dll"
#func global MsiNotifySidChangeW "MsiNotifySidChangeW" wptr, wptr
; MsiNotifySidChangeW pOldSid, pNewSid   ; 戻り値は stat
; pOldSid : LPCWSTR -> "wptr"
; pNewSid : LPCWSTR -> "wptr"
; ※HSP3.7は #func のため戻り値はシステム変数 stat に格納されます。
#uselib "msi.dll"
#cfunc global MsiNotifySidChangeW "MsiNotifySidChangeW" wstr, wstr
; res = MsiNotifySidChangeW(pOldSid, pNewSid)
; pOldSid : LPCWSTR -> "wstr"
; pNewSid : LPCWSTR -> "wstr"
; DWORD MsiNotifySidChangeW(LPCWSTR pOldSid, LPCWSTR pNewSid)
#uselib "msi.dll"
#cfunc global MsiNotifySidChangeW "MsiNotifySidChangeW" wstr, wstr
; res = MsiNotifySidChangeW(pOldSid, pNewSid)
; pOldSid : LPCWSTR -> "wstr"
; pNewSid : LPCWSTR -> "wstr"
import (
	"golang.org/x/sys/windows"
	"unsafe"
)

var (
	msi = windows.NewLazySystemDLL("msi.dll")
	procMsiNotifySidChangeW = msi.NewProc("MsiNotifySidChangeW")
)

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