This project has moved and is read-only. For the latest updates, please go here.

Code to check Bloomberg Terminal is being installed

May 1, 2013 at 11:23 AM
How to check whether Bloomberg Terminal was being installed in user machine using c#?
Coordinator
May 1, 2013 at 4:10 PM
vijayathii,

It looks like the Session.Start() member returns a bool that let's you know if the Bloomberg Terminal is installed. Try this code:
private static bool CheckBBRunning()
{
    SessionOptions sessionOptions = new SessionOptions();
    sessionOptions.ServerHost = "localhost";
    sessionOptions.ServerPort = 8194;

    Session session = new Session(sessionOptions);
    if (!session.Start())
    {
        Console.WriteLine("BB API not installed on this computer.");
        return false;
    }
    else
    {
        Console.WriteLine("BB API is installed on this computer");
        return true;
    }
}
I tried this both on a computer that doesn't have the the terminal installed, and one that does. It seems to work. I am not sure what would happen if the terminal was installed, but for some other reason you couldn't make API requests. It's possible that once a session is started, a call to session.OpenService("//blp/refdata") returns false. I am not sure why this would return false. Maybe your BB account disallows some types of API services.

In my code, I have something similar to the code below that I use to check to see if I can make a request before I actually send any requests:
SessionOptions sessionOptions = new SessionOptions();
sessionOptions.ServerHost = "localhost";
sessionOptions.ServerPort = 8194;

Session session = new Session(sessionOptions);
if (!session.Start())
{
    Console.WriteLine("Could not start session.");
    return false;
}
if (!session.OpenService("//blp/refdata"))
{
    Console.WriteLine("Could not open service //blp/refdata");
    return false;
}
//send BB requests and process responses
May 2, 2013 at 5:15 AM
Thanks.