Page 1 of 1 1
Topic Options
#189943 - 2008-09-30 05:40 PM Orca .Net
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
I love Orca, it's THE most useful tool when editing MSI packages.
However opening an MSI package with Orca has one problem, it edits it by default somehow when it opens the package. So seeying no way to prevent this I thought I'd write my own Orca. Currently the only thing it does is READ every table and information of the msi file but next versions will "probably contain edit functions and/or add transforms. Anyway don't hold your breath for it \:\)
Those familiar with Orca will feel right at home since it looks more or less the same.

Without further ado:
 Code:
$=SetOption('Explicit','On')
Global $System, $Form1, $MainMenu, $MenuItem1, $MenuItem2, $MenuItem3
Global $Listbox1, $ListView1, $StatusBar1, $OpenFileDialog1, $dlgOpen

$System = CreateObject("Kixforms.System")
If Not $System
  $=MessageBox("KiXforms.Net Not Initiated. This Script Will Now Close.","Error",16)
  Quit()
EndIf
$=$System.Application.EnableVisualStyles

$Form1 = $System.Form()
$Form1.Left = 0
$Form1.StartPosition = 0  ;FormStartPosition_Manual
$Form1.Size = $System.Size(603,495) ;(Width,Height)
$Form1.Text = "Orca .Net"
$Form1.Top = 0

$MainMenu = $System.MainMenu()
$MenuItem1 = $MainMenu.MenuItems.Add($System.MenuItem("File"))
$MenuItem2 = $MenuItem1.MenuItems.Add($System.MenuItem("Open"))
$MenuItem2.Click = "$$=OpenMSI"
$MenuItem3 = $MenuItem1.MenuItems.Add($System.MenuItem("Exit"))
$MenuItem3.Click = "Quit"
$Form1.Menu = $MainMenu

$ListBox1 = $System.ListBox()
$ListBox1.Anchor = 7  ;Top,Bottom,Left
$ListBox1.Height = 440
$ListBox1.Left = 0
$ListBox1.Top = 0
$ListBox1.Width = 250
$ListBox1.Sorted = -1
$ListBox1.Click = "$$=ListInfo($$dlgOpen)"
$=$Form1.Controls.Add($ListBox1)

$ListView1 = $System.ListView()
$ListView1.Anchor = 15  ;Top,Left,Bottom,Right
$ListView1.Height = 440
$ListView1.Left = 250
$ListView1.Top = 0
$ListView1.Width = 345
$ListView1.View = $System.View_Details
$=$Form1.Controls.Add($ListView1)

$StatusBar1 = $System.StatusBar()
$StatusBar1.Text = ""
$=$Form1.Controls.Add($StatusBar1)

$OpenFileDialog1 = $System.OpenFileDialog()
$OpenFileDialog1.InitialDirectory = "@SCRIPTDIR"
$OpenFileDialog1.Filter = "Windows Installer (*.msi)|*.msi"
$OpenFileDialog1.FilterIndex = 1
$OpenFileDialog1.RestoreDirectory = 1 ;True

$Form1.Center
$Form1.Show  ;Displays the Form

While $Form1.Visible
  $=Execute($Form1.DoEvents())
Loop
Exit 0

Function ListInfo($strMsiFile)
  Dim $objMSI, $objMSIdb, $objMSIview, $strMSIRecords, $i, $a, $e
  If NOT $ListBox1.Text = ""
    $objMSI = CreateObject("WindowsInstaller.Installer")
    $objMSIdb = $objMSI.OpenDataBase($strMsiFile,0)
    $objMSIview = $objMSIdb.OpenView("SELECT `Name` FROM `_Columns` WHERE `Table` = "+"'"+$ListBox1.Text+"'")
    $objMSIview.Execute()
    $strMSIrecords = $objMSIview.Fetch

    $=$ListView1.Columns.Clear
    $Form1.UseWaitCursor = 1
    $ListView1.BeginUpdate
    $i=0
    While NOT $strMSIRecords = ""
      $i=$i+1
      $=$ListView1.Columns.Add($System.ColumnHeader($strMSIRecords.StringData(1),150,$System.HorizontalAlignment_Left))
      $strMSIrecords = $objMSIview.Fetch
    Loop

    $objMSIview = $objMSIdb.OpenView("SELECT * FROM "+"`"+$ListBox1.Text+"`")
    $objMSIview.Execute()
    $strMSIrecords = $objMSIview.Fetch
    $=$ListView1.Items.Clear
    While NOT $strMSIRecords = ""
      $a=$ListView1.Items.Add($strMsiRecords.StringData(1))
      For $e=1 To $i
        $=$a.SubItems.Add($System.ListViewSubItem($strMsiRecords.StringData($e+1)))
      Next
      $strMSIrecords = $objMSIview.Fetch
    Loop
    $ListView1.EndUpdate
    $Form1.UseWaitCursor = 0
  EndIf
EndFunction

Function ListTables($strMsiFile)
  Dim $objMSI, $objDB, $objView, $objRS, $intA
  $=$ListBox1.Items.Clear
  $ListBox1.BeginUpdate
  $Form1.UseWaitCursor = 1
  $objMSI = CreateObject("WindowsInstaller.Installer")
  $objDB = $objMSI.OpenDatabase($strMsiFile,0)
  $=Split($strMsiFile,"\")
  $Form1.Text = $[Ubound($)] +" - Orca .Net"
  $objView = $objDB.OpenView("SELECT * FROM _Tables")
  $objView.Execute()
  $objRS = $objView.Fetch
  $intA = 0
  While Not $objRS = ""
    $intA=$intA+1
    $=$ListBox1.Items.Add($objRS.StringData(1))
    $objRS = $objView.Fetch
  Loop
  $ListBox1.EndUpdate
  $Form1.UseWaitCursor = 0
  $StatusBar1.Text = "Tables: "+CStr($intA)
EndFunction

Function OpenMsi()
  $=$ListView1.Columns.Clear
  $=$ListView1.Items.Clear
  $=$ListBox1.Items.Clear
  If $OpenFileDialog1.ShowDialog() = 1
    $dlgOpen = $OpenFileDialog1.Filename
    If NOT $dlgOpen = ""
      $=ListTables($dlgOpen)
    EndIf
  EndIf
EndFunction


Edited by apronk (2008-10-01 11:21 AM)
Edit Reason: Updated code

Top
#189953 - 2008-10-01 11:23 AM Re: Orca .Net [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Updated the code, fixed some errors:
1. Error when cancelling to select an MSI file.
2. Error when clicking in an empty listbox.
3. Silenced all console output.
4. Made the whole script Option Explicit compliant.

Top
#189972 - 2008-10-01 06:24 PM Re: Orca .Net [Re: Arend_]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
5. Refreshing fixed, no more flickering (thx again Shawn!)
Top
#189976 - 2008-10-02 02:00 AM Re: Orca .Net [Re: Arend_]
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
eh, what i do ?
Top
#189980 - 2008-10-02 09:14 AM Re: Orca .Net [Re: Shawn]
Arend_ Moderator Offline
MM club member
*****

Registered: 2005-01-17
Posts: 1894
Loc: Hilversum, The Netherlands
Showing me in the previous ScriptOMatic how to prevent the flickering when updating listview and listbox items.
Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.096 seconds in which 0.061 seconds were spent on a total of 14 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org