Hi, I would like to know how to write a "Console application" in dll form for a patch installer so that I could call it from the installers and find out the installation of a program.

I have created a VB.NET class project and checked the COM Interoperation or sort of on project's property, build section.

Now the main thing is on receiving parameters and returning the value. (I try to do this DLL as "all-in-one" DLL because this application is part of a bigger suite family, which means there are few others applications that requires the similar approach, and I want to avoid to re-write a dll for each application, and their respective versions.)

Thanks a lot!

Any class can have a contructor.
The constructor is a

Sub New() 
... 
End Sub

You can define wich kind of parameters you need to create the new instance of the class like

Sub New( Byval Parm1 As String, Byval Parm2 as Integer )

You can define as many parameters as you need

Inside the sub new you can do whatever you need.

Also you can define som public methods or functions to do the work

In order to return values, you can or define functions or define some properties for the class

On the Caller you must create a new instance of the class
Using the created instance you can Call the methods, call functions returning values or get the properties.

Hope this helps

Any class can have a contructor.
The constructor is a

Sub New() 
... 
End Sub

You can define wich kind of parameters you need to create the new instance of the class like

Sub New( Byval Parm1 As String, Byval Parm2 as Integer )

You can define as many parameters as you need

Inside the sub new you can do whatever you need.

Also you can define som public methods or functions to do the work

In order to return values, you can or define functions or define some properties for the class

On the Caller you must create a new instance of the class
Using the created instance you can Call the methods, call functions returning values or get the properties.

Hope this helps

Thanks for the tip, that helps a lot. As part of reference, I shall open my dll source.

Imports System.IO //This dll is meant to get the installation path of Adobe Encore and might be extended on other product series
Imports System.Data.SQLite 'The recent Adobe products (CS4 onwards, not sure on CS3s) are known to be using Sqlite to store installation location (AMT folder)
Public Class Main
    Public Shared AdobeDBLocation As String 'To get installation directory from Adobe PCD DB
    Public Shared dbConn As New SQLiteConnection
    Public Shared dbCommand As New SQLiteCommand
    Public Shared SubDomain As String 'To avoid the need to provide the "Payload code twice"
    Public Sub New(ByVal GetSubDomain As String)
        If IntPtr.Size = 4 Then 'To ensure it is compatible with both X64 and X86 systems.
            AdobeDBLocation = System.Environment.GetEnvironmentVariable("ProgramFiles")
        ElseIf IntPtr.Size = 8 Then
            AdobeDBLocation = System.Environment.GetEnvironmentVariable("ProgramFiles(x86)")
        End If
        AdobeDBLocation &= "\Common Files\Adobe\Adobe PCD\pcd.db"
        SubDomain = GetSubDomain
        GetDirectory()
    End Sub
    Public Function GetDirectory() As String
        dbConn.ConnectionString = "Data Source =" & AdobeDBLocation
        dbCommand.Connection = dbConn
        dbCommand.CommandText = "select value From domain_data where SubDomain = '" & SubDomain & "' And key = 'AMTConfigPath'" 'Adobe's Subdomain is the payload code.
        dbConn.Open()
        Dim InstallPath As String = dbCommand.ExecuteScalar() 'The return value is most likely a "C:\Program Files\Adobe\<Application Name>\AMT\application.xml"
        dbConn.Close()
        Try
            InstallPath = Directory.GetParent(InstallPath).ToString() 'Get where the AMTConfigPath directory is (The returned value should be a filename, which we do not need that) , and becomes: "C:\Program Files\Adobe\<Application Name>\AMT"
            InstallPath = Directory.GetParent(InstallPath).ToString() 'We do not want the AMT folder directory. Finally, it means "C:\Program Files\Adobe\<Application Name>"
        Catch ex As Exception
            Return String.Empty 'Should there any error as the directory is not found, then return it as empty value, so that installer will prompt the application is NOT installed.
        End Try
        Return InstallPath
    End Function
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.