Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSI Automation Interface

Status
Not open for further replies.

SpiderBear6

Programmer
Sep 17, 2003
422
0
0
AU
Does anyone have any experience with the MSI Automation Interface? This is the code that I am trying to get to work...

Code:
        Dim rec As WindowsInstaller.Record

        rec = m_objInstaller.CreateRecord(7)
        With rec
            .StringData(1) = sRegistry
            .IntegerData(2) = iRoot
            .StringData(3) = sKey
            .StringData(4) = sName
            .StringData(5) = sValue
            .StringData(6) = sComponent
        End With

        Dim vw As WindowsInstaller.View

        vw = m_db.OpenView("INSERT INTO 'Registry' ('Registry', 'Root', 'Key', 'Name', 'Value', 'Component_') " _
            & "VALUES (?, ?, ?, ?, ?, ?)")  

        vw.Execute(rec)


        vw.Close()
        m_db.Commit()

        rec = Nothing
        vw = Nothing

I have tried to use the view modify code, but ran into an interesting problem. It would actually insert the record but the data would be from a previous insert. I have checked the data that was in the rec record object just before I do the view modify and it is correct so I have no idea where it is getting the old data from. I have no module level variables.

Code:
           vw.Modify(WindowsInstaller.MsiViewModify.msiViewModifyAssign, rec)

I know this is a long shot, but I have been trying desparately to get this to work. All I want to do is insert a record into a few of the tables of an msi file.

Thanks a bundle.


--------------------------------------
"We are star-stuff. We are the universe made manifest trying to figure itself out."
-- Delenn in Babylon 5 - "A Distant Star"
 
Have you resolved these issues? I have written a VB.NET app that automates alot of things that we need for MSI, but for some reason I cannot work out how to close the link to the MSI database that I am opening, setting to 'Nothing' does not close the handle.

To cut a long story short, I need to assign another Database handle to an MSI that I have editted on the same OnClick event, but because I have not worked out a way to terminate the handle, I cannot do this. In C you would call MsiCloseHandle, I have declared the function, but it does not work.

Cam.
 
Finally found out what I needed. Apparently in VB.NET setting an object to Nothing does not immediately get rid of it, it has to wait until the Garbage Collector (GC) is run to finally rid the object, but the GC can run at anytime, including minutes from when your object was set to Nothing.

Now, for anyone out there that has/have/had the same problem as me, set all your objects to nothing, once you have left your function/sub run

GC.Collect()
GC.WaitForPendingFinalizers()

GC is a known object, so just type in GC. and you will get the rest of the methods for that. Ensure you are out of the function/sub, or the GC wont do anything for you.

I hope that helps someone out there! :)

Cam.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top