// Declare a BarTender application variable
BarTender.Application btApp;
// Create a new instance of BarTender
btApp = new BarTender.Application();
// Set the BarTender application visible
btApp.Visible = true;
// Show the port of the BarTender Licensing Service if BarTender is connected to it
if (btApp.LicenseServer.Connect())
{
MessageBox.Show(btApp.LicenseServer.Port.ToString());
}
else
{
MessageBox.Show("Not Connected");
}
// End the BarTender process
btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges);