我怎样才能修改微星在内存中?微星、内存

2023-09-04 12:23:50 作者:诉情长

我想读MSI文件到MemoryStream(或类似的东西),并对其进行修改。怎样做最简单的方法,而不会破坏MSI?

我只需要能够做的就是修改微星的属性之一的价值。我想美元的净p $ PFER的东西,但我开到其他平台。

更新:

这是我的工作code,使用Windows平台的SDK,一个COM引用Microsoft Windows安装程序对象库和命名空间WindowsInstaller:

 安装程序安装= Activator.CreateInstance(Type.GetTypeFromProgID(WindowsInstaller.Installer))的安装程序;

数据库MSI = installer.OpenDatabase(WixTest.msi,MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);

查看查看= msi.OpenView(更新`Property` SET`Property`.`Value` = '99'在哪里'Property` ='USERID');

view.Execute(空);

msi.Commit();
 

解决方案

检查出的 Windows SDK的,还有包括在使用的 Windows安装程序API 。

下面是一个命令行的一个简化版本的VBScript我用它来做到这一点:

 显式的选项


常量msiOpenDatabaseModeReadOnly = 0
常量msiOpenDatabaseModeTransact = 1

昏暗的openMode:的openMode = msiOpenDatabaseModeTransact

昏暗的argCount:argCount = Wscript.Arguments.Count

如果(argCount 3;)然后WScript.Echo用法:msisetproperty.vbs< MSI><性><价值>中:WScript.Quit 1

昏暗MY_MSI:MY_MSI = Wscript.Arguments(0)
昏暗sProp1:sProp1 = Wscript.Arguments(1)
昏暗sVal1:sVal1 = Wscript.Arguments(2)

昏暗的filesys:设置的filesys =的CreateObject(Scripting.FileSystemObject的)

如果不filesys.FileExists(MY_MSI)然后WScript.Echo无法找到微星,退出:WScript.Quit 1

昏暗的安装程序,数据库,视图结果

设置安装=的CreateObject(WindowsInstaller.Installer)
昏暗sumInfo:设置sumInfo = installer.SummaryInformation(MY_MSI,0)

设置数据库= installer.OpenDatabase(MY_MSI,的openMode)

设置视图= database.OpenView(UPDATE属性设置值='&放大器; sVal1&安培;'凡财产='&放大器; sProp1&安培;')
view.Execute

database.Commit
设置数据库=什么
 
微星主板怎么改内存时序 虽然这块主板价格有点小贵,但用过之后,感觉还是可以接受的...

I'd like to read an MSI file into a MemoryStream (or something similar), and modify it. What's the easiest way to do this, without corrupting the MSI?

All I need to be able to do is modify the value of one of the properties in the MSI. I'd prefer something in .Net, but I'm open to other platforms.

Update:

Here's my working code, using the Windows platform SDK, a COM reference to Microsoft Windows Installer Object Library and namespace WindowsInstaller:

Installer installer = Activator.CreateInstance(Type.GetTypeFromProgID("WindowsInstaller.Installer")) as Installer;

Database msi = installer.OpenDatabase("WixTest.msi", MsiOpenDatabaseMode.msiOpenDatabaseModeTransact);

View view = msi.OpenView("update `Property` SET `Property`.`Value`='99' where `Property`='USERID'");

view.Execute(null);

msi.Commit();

解决方案

Check out the Windows SDK, there are a bunch of samples included on using the Windows Installer API.

Here's a simplified version of a command line VBScript I use to do this:

Option Explicit


Const msiOpenDatabaseModeReadOnly     = 0
Const msiOpenDatabaseModeTransact     = 1

Dim openMode : openMode = msiOpenDatabaseModeTransact

Dim argCount:argCount = Wscript.Arguments.Count

If (argCount < 3) Then  WScript.Echo "usage: msisetproperty.vbs <msi> <property> <value>" :     WScript.Quit 1

Dim MY_MSI : MY_MSI = Wscript.Arguments(0)
Dim sProp1 : sProp1 = Wscript.Arguments(1)
Dim sVal1  : sVal1 = Wscript.Arguments(2)

Dim filesys : Set filesys=CreateObject("Scripting.FileSystemObject")

If Not filesys.FileExists(MY_MSI) Then WScript.Echo "Unable to find msi, exiting" : WScript.Quit 1

Dim installer, database, view, result

Set installer = CreateObject("WindowsInstaller.Installer")
Dim sumInfo  : Set sumInfo = installer.SummaryInformation(MY_MSI, 0)

Set database = installer.OpenDatabase (MY_MSI, openMode)

Set view = database.OpenView ("UPDATE Property SET Value='" & sVal1 & "' WHERE Property='" & sProp1 & "'")
view.Execute

database.Commit
Set database = nothing