Example: .NET Script Add-in - ContentViewer for EXE file infos

This is an example Add-in written in VB.Net Script. It registers a ContentViewer which handles *.exe and *.dll files and displays their file information in a PropertyGrid. The information is determined by the System.Diagnostics.FileVersionInfo class.



Source code

Save the following code to C:\yPara\scriptIDE4\addIns\FileVer.nsa:
#Implements IAddinConnect
#Para DebugMode Internal
#Para SilentMode true

<AddIn name        = "FileVer"
       displayname = "File Version Info"
       author      = "Max Weller"
       url         = "http://wiki-lab.net"
       description = "Displays version info of Windows PE Files (Exe/Dll)"
       icon        = "">
    <Identity name="CCompile" version = ""/>
  <!-- registering a Content Viewer -->
  <Path name="/Workspace/ContentViewers">
    the class attribute is composed of: Namespace (always "ScriptClass" for .NET Scripts), ".", main class name (= file name), "+", sub class name.
    It is important to use a plus sign here!
    <Class id="FileVersionInfo" mode="dockcontent" filefilter="*.exe;*.dll" class="ScriptClass.FileVer+FileVersionInfoContent" />


#Reference System.Windows.Forms.dll
#Reference siaIDEMain.dll

#Imports System.Windows.Forms
#Imports System.Diagnostics
#Imports ScriptIDE.Core

Dim WithEvents IDE As IIDEHelper

Public Sub Connect(ByVal application As Object, ByVal connectMode As Core.ConnectMode, ByVal addInInst As Core.AddinInstance, ByRef custom As Object) Implements Core.IAddinConnect.Connect
  IDE = Main.cls_IDEHelper.Instance
End Sub

Public Sub Disconnect(ByVal removeMode As Core.DisconnectMode, ByRef custom As Object) Implements Core.IAddinConnect.Disconnect
End Sub

Public Function GetAddinWindow(ByVal PersistString As String) As Form Implements IAddinConnect.GetAddinWindow
End Function

Public Sub OnNavigate(ByVal kind As Core.NavigationKind, ByVal source As String, ByVal command As String, ByVal args As Object, ByRef returnValue As Object) Implements Core.IAddinConnect.OnNavigate
End Sub

Public Sub OnAddinUpdate(ByVal addinChanged As String, ByRef custom As Object) Implements Core.IAddinConnect.OnAddinUpdate
End Sub

Public Sub OnBeforeShutdown(ByRef cancel As Boolean, ByRef custom As Object) Implements Core.IAddinConnect.OnBeforeShutdown
End Sub

Public Sub OnStartupComplete(ByRef custom As Object) Implements Core.IAddinConnect.OnStartupComplete
End Sub

Public Class FileVersionInfoContent
  Inherits ScriptIDE.Main.GenericDockContent
  Dim pgrid as PropertyGrid
  ' Initialize controls in onLazyInit to improve startup time
  Public Overrides Sub onLazyInit()
    pgrid = New PropertyGrid
    pgrid.Dock = DockStyle.Fill
  End Sub
  ' Load data in onRead because it is guaranteed that Me.URL will be set here
  Public Overrides Sub onRead()
    ' Load the information object
    Dim fvi As FileVersionInfo = _
    ' Display it in the PropertyGrid
    pgrid.SelectedObject = fvi
  End Sub

End Class

Last edited Feb 23, 2012 at 1:04 PM by max_weller, version 5


No comments yet.