cancel
Showing results for 
Search instead for 
Did you mean: 

video tutorial about addon installer (package) ???

Former Member
0 Kudos

hi,

i'm new to vb.net. I'm using VS2005.net and SBO2005. I have a sample code and want to generate a real adddon. Is there a video tutorial where i can see how i have to make an addon installation package.

The sample addoninstaller don't work on my machine.

Maybe there is a video tutorial ?

best regards

Markus

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

i have got this link today from Frank.

<a href="http://service.sap.com/sapidb/011000358700000468252006E.zip">http://service.sap.com/sapidb/011000358700000468252006E.zip</a>

There is descriped how to make addon installers.

If there are some specialised questions, i also dingin into the addon installer stuff.

Regards,

Christian

Former Member
0 Kudos

hi Christian,

i have already seen this video. But thats not excactly what i want. I want to link my application to the addon installer. Maybe i have to try once more.

thanks a lot

Markus

Former Member
0 Kudos

Hi,

Send me your eMail. I have an AddOn Installer Project Template for VB 2005.

I will send it to you.

Here ist the source code off one of my installer projects.

How have just to replace the Filenames in the Module FileList.vb

Rest does the frmInstall class for you.

REgards,

Christian

Class frmInstall.vb

'//  SAP MANAGE DI API 6.7 SDK Sample
'//****************************************************************************
'//
'//  File:      frmInstall.vb
'//
'//  Copyright (c) SAP MANAGE
'//
'// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
'// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
'// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
'// PARTICULAR PURPOSE.
'//
'//****************************************************************************
'// This sample creates an add-on installer for SBO.
'// An installation for SBO should be build in a spesific way.
'// 1) It should be able to accept a command line parameter from SBO.
'//    This parameter is a string built from 2 strings devided by "|".
'//    The first string is the path recommended by SBO for installation folder.
'//    The second string is the location of "AddOnInstallAPI.dll".
'//    For example, a command line parameter that looks like this:
'//    "C:MyAddon|C:Program FilesSAP ManageSAP Business OneAddOnInstallAPI.dll"
'//    Means that the recommended installation folder for this addon is "C:MyAddon"
'//    and the location of "AddOnInstallAPI.dll" is - 
'//                 "C:Program FilesSAP ManageSAP Business OneAddOnInstallAPI.dll"
'// 2) When the installation is complete the installer must call the function 
'//    "EndInstall" from "AddOnInstallAPI.dll" to inform SBO the installation is complete.
'//    This dll contains 3 functions that can be used during the installation.
'//    The functions are: 
'//         1) EndInstall - Signals SBO that the installation is complete.
'//         2) SetAddOnFolder - Use it if you want to change the installation folder.
'//         3) RestartNeeded - Use it if your installation requires a restart, it will cause
'//            the SBO application to close itself after the installation is complete.
'//    All 3 functions return a 32 bit integer. There are 2 possible values for this integer.
'//    0 - Success, 1 - Failure.
'// 3) The installer must be one executable file.
'// 4) After your installer is ready you need to create an add-on registration file.
'//    In order to create it you have a utility - "Add-On Registration Data Creator"
'//    you can find it in -
'//       "..SAP ManageSAP Business One SDKToolsAddOnRegDataGenAddOnRegDataGen.exe".
'//    This utility creates a file with the extention 'ard', you will be asked to 
'//    point to this file when you register your addon.

Imports System
Imports System.Runtime.InteropServices


Public Class frmInstall
	Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

	Public Sub New()
		MyBase.New()

		'This call is required by the Windows Form Designer.
		InitializeComponent()

		'Add any initialization after the InitializeComponent() call

	End Sub

	'Form overrides dispose to clean up the component list.
	Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
		If disposing Then
			If Not (components Is Nothing) Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(disposing)
	End Sub

	'Required by the Windows Form Designer
	Private components As System.ComponentModel.IContainer

	'NOTE: The following procedure is required by the Windows Form Designer
	'It can be modified using the Windows Form Designer.  
	'Do not modify it using the code editor.
	Friend WithEvents lblHeadLine As System.Windows.Forms.Label
	Friend WithEvents Label1 As System.Windows.Forms.Label
	Friend WithEvents Label2 As System.Windows.Forms.Label
	Friend WithEvents txtDest As System.Windows.Forms.TextBox
	Friend WithEvents chkRestart As System.Windows.Forms.CheckBox
	Friend WithEvents chkDefaultFolder As System.Windows.Forms.CheckBox
	Friend WithEvents cmdInstall As System.Windows.Forms.Button
	Friend WithEvents FileWatcher As System.IO.FileSystemWatcher
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.cmdInstall = New System.Windows.Forms.Button
		Me.lblHeadLine = New System.Windows.Forms.Label
		Me.Label1 = New System.Windows.Forms.Label
		Me.Label2 = New System.Windows.Forms.Label
		Me.txtDest = New System.Windows.Forms.TextBox
		Me.chkRestart = New System.Windows.Forms.CheckBox
		Me.chkDefaultFolder = New System.Windows.Forms.CheckBox
		Me.FileWatcher = New System.IO.FileSystemWatcher
		CType(Me.FileWatcher, System.ComponentModel.ISupportInitialize).BeginInit()
		Me.SuspendLayout()
		'
		'cmdInstall
		'
		Me.cmdInstall.Location = New System.Drawing.Point(24, 216)
		Me.cmdInstall.Name = "cmdInstall"
		Me.cmdInstall.Size = New System.Drawing.Size(96, 23)
		Me.cmdInstall.TabIndex = 1
		Me.cmdInstall.Text = "Install Add-on"
		'
		'lblHeadLine
		'
		Me.lblHeadLine.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(177, Byte))
		Me.lblHeadLine.Location = New System.Drawing.Point(16, 16)
		Me.lblHeadLine.Name = "lblHeadLine"
		Me.lblHeadLine.Size = New System.Drawing.Size(416, 24)
		Me.lblHeadLine.TabIndex = 2
		Me.lblHeadLine.Text = "This Installer is a sample for Sap Business One. "
		'
		'Label1
		'
		Me.Label1.Font = New System.Drawing.Font("Microsoft Sans Serif", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(177, Byte))
		Me.Label1.Location = New System.Drawing.Point(16, 40)
		Me.Label1.Name = "Label1"
		Me.Label1.Size = New System.Drawing.Size(416, 24)
		Me.Label1.TabIndex = 3
		Me.Label1.Text = "It will install a ""abC Aphona"" add-on"
		'
		'Label2
		'
		Me.Label2.Location = New System.Drawing.Point(24, 88)
		Me.Label2.Name = "Label2"
		Me.Label2.Size = New System.Drawing.Size(256, 23)
		Me.Label2.TabIndex = 4
		Me.Label2.Text = "Installation Folder recieved from SBO application"
		'
		'txtDest
		'
		Me.txtDest.Enabled = False
		Me.txtDest.Location = New System.Drawing.Point(24, 112)
		Me.txtDest.Name = "txtDest"
		Me.txtDest.Size = New System.Drawing.Size(472, 20)
		Me.txtDest.TabIndex = 5
		Me.txtDest.Text = ""
		'
		'chkRestart
		'
		Me.chkRestart.Location = New System.Drawing.Point(24, 176)
		Me.chkRestart.Name = "chkRestart"
		Me.chkRestart.TabIndex = 6
		Me.chkRestart.Text = "Ask for a restart"
		'
		'chkDefaultFolder
		'
		Me.chkDefaultFolder.Checked = True
		Me.chkDefaultFolder.CheckState = System.Windows.Forms.CheckState.Checked
		Me.chkDefaultFolder.Location = New System.Drawing.Point(24, 144)
		Me.chkDefaultFolder.Name = "chkDefaultFolder"
		Me.chkDefaultFolder.Size = New System.Drawing.Size(160, 24)
		Me.chkDefaultFolder.TabIndex = 7
		Me.chkDefaultFolder.Text = "Use path supplied by SBO"
		'
		'FileWatcher
		'
		Me.FileWatcher.EnableRaisingEvents = True
		Me.FileWatcher.SynchronizingObject = Me
		'
		'frmInstall
		'
		Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
		Me.ClientSize = New System.Drawing.Size(522, 263)
		Me.Controls.Add(Me.chkDefaultFolder)
		Me.Controls.Add(Me.txtDest)
		Me.Controls.Add(Me.chkRestart)
		Me.Controls.Add(Me.Label2)
		Me.Controls.Add(Me.Label1)
		Me.Controls.Add(Me.lblHeadLine)
		Me.Controls.Add(Me.cmdInstall)
		Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
		Me.MaximizeBox = False
		Me.MinimizeBox = False
		Me.Name = "frmInstall"
		Me.Text = "Addon Installation Sample"
		CType(Me.FileWatcher, System.ComponentModel.ISupportInitialize).EndInit()
		Me.ResumeLayout(False)

	End Sub

#End Region


	' Declaring the functions inside "AddOnInstallAPI.dll"

	'EndInstall - Signals SBO that the installation is complete.
	Declare Function EndInstall Lib "AddOnInstallAPI.dll" () As Int32
	'SetAddOnFolder - Use it if you want to change the installation folder.
	Declare Function SetAddOnFolder Lib "AddOnInstallAPI.dll" (ByVal srrPath As String) As Int32
	'RestartNeeded - Use it if your installation requires a restart, it will cause
	'the SBO application to close itself after the installation is complete.
	Declare Function RestartNeeded Lib "AddOnInstallAPI.dll" () As Int32

	Private strDll As String	' The path of "AddOnInstallAPI.dll"
	Private strDest As String	' Installation target path
	Private bFileCreated As Boolean	' True if the file was created

    ' This function extracts the add-on into the path specified
	Private Sub ExtractFile(ByVal path As String)
        Dim AddonFile As IO.FileStream
		Dim thisExe As System.Reflection.Assembly
		thisExe = System.Reflection.Assembly.GetExecutingAssembly()

		Dim file As System.IO.Stream
        Dim buffer() As Byte
        For Each strFile As String In getFiles()
            file = thisExe.GetManifestResourceStream("AddOnInstaller." + strFile)
            ' Create a tmp file first, after file is extracted change to exe
            AddonFile = IO.File.Create(path & "" + strFile + ".tmp")
            ReDim buffer(file.Length)
            file.Read(buffer, 0, file.Length)
            AddonFile.Write(buffer, 0, file.Length)
            AddonFile.Close()

            ' Change file extension to exe
            Try
                IO.File.Move(path & "" + strFile + ".tmp", path & "" + strFile)
            Catch
                IO.File.Delete(path & "" + strFile)
                IO.File.Move(path & "" + strFile + ".tmp", path & "" + strFile)
            End Try
        Next
    End Sub

	Private Sub Install()
        Environment.CurrentDirectory = strDll       ' For Dll function calls will work

		If chkDefaultFolder.Checked = False Then		' Change the installation folder
			SetAddOnFolder(txtDest.Text)
			strDest = txtDest.Text
		End If

		If Not (IO.Directory.Exists(strDest)) Then
			IO.Directory.CreateDirectory(strDest)			' Create installation folder
		End If

		FileWatcher.Path = strDest
		FileWatcher.EnableRaisingEvents = True

		ExtractFile(strDest)		' Extract add-on to installation folder

		If chkRestart.Checked Then
			RestartNeeded()			' Inform SBO the restart is needed
		End If
		EndInstall()		' Inform SBO the installation ended
		MessageBox.Show("Finished Installing", "Installation ended", MessageBoxButtons.OK, MessageBoxIcon.Information)
		Windows.Forms.Application.Exit()		' Exit the installer
	End Sub

	Private Sub frmInstall_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' The command line parameters, seperated by '|' will be broken to this array
		Dim strCmdLineElements(2) As String

		Dim strCmdLine As String		' The whole command line
		Dim NumOfParams As Integer		'The number of parameters in the command line (should be 2)

		NumOfParams = Environment.GetCommandLineArgs.Length
		Select Case NumOfParams
			Case 2
				strCmdLine = Environment.GetCommandLineArgs.GetValue(1)
                If strCmdLine = "/U" Then
                    For Each strFile As String In getFiles()
                        IO.File.Delete(Application.StartupPath & "" & "" + strFile)
                    Next
                    Windows.Forms.Application.Exit()
                Else
                    strCmdLineElements = strCmdLine.Split("|")

                    ' Get Install destination Folder
                    strDest = strCmdLineElements.GetValue(0)
                    txtDest.Text = strDest

                    ' Get the "AddOnInstallAPI.dll" path
                    strDll = strCmdLineElements.GetValue(1)
                    strDll = strDll.Remove((strDll.Length - 19), 19)                    ' Only the path is needed
                End If
			Case Else
				MessageBox.Show("This installer must be run from Sap Business One", _
				 "Incorrect installation", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
				Windows.Forms.Application.Exit()
		End Select

	End Sub

	Private Sub chkDefaultFolder_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkDefaultFolder.CheckedChanged
		txtDest.Enabled = Not (chkDefaultFolder.Checked)
	End Sub

	' This event happens when the addon exe file is renamed to exe extention
	Private Sub FileWatcher_Renamed(ByVal sender As Object, ByVal e As System.IO.RenamedEventArgs) Handles FileWatcher.Renamed
		bFileCreated = True
		FileWatcher.EnableRaisingEvents = False
	End Sub

	Private Sub cmdInstall_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdInstall.Click
		Install()
	End Sub
End Class

Module Filelist.vb

Module FileList
    Public Function getFiles() As ArrayList
        Dim alFiles As ArrayList
        alFiles = New ArrayList
        alFiles.Add("abc_SBOTools.dll")
        alFiles.Add("BudgetArtikel.exe")
        alFiles.Add("Interop.SAPbobsCOM.dll")
        alFiles.Add("Interop.SAPbouiCOM.dll")
        Return alFiles
    End Function

End Module

Former Member
0 Kudos

hi Christian,

if you could send me a template and maybe a mini example it would be great. Thanks a lot. May email is m.rewak@gmx.de

thanks

Markus

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

I have the same problem... could you send me your “installer template” by email?

My email:fabri.soares@gmail.com

Thanks

Fabricio

Former Member
0 Kudos

Check your mail box. I sent you the project template and a sample projekt.

Regards,

Christian

Former Member
0 Kudos

Hi Christian,

I am currently looking for help with the Installer for add-ons developed with VB.Net2005 and I saw this thread. Could you please email me the installer template too? I have been having problems for so long with the Installation setup and Registering of Add-ons for SBO2005.

My email is: noormuhammed@gmail.com

Thanks

Former Member
0 Kudos

Hi,

I have the same problem... could you send me your “installer template” by email?

My email:nspeedpower@gmail.com

Thanks