//Static Constructor
        static SAPIWrapper()
        {
            try
            {
                SAPI = new SAPICryptClass();
            }
            catch
            {
                System.Windows.Forms.MessageBox.Show("SAPI is not installed");
                System.Windows.Forms.Application.Exit();
            }

            int rc = SAPI.Init();
            if (rc != 0)
            {
                System.Windows.Forms.MessageBox.Show("Failed to initialize SAPI (" + rc.ToString("X") + ")");
                System.Windows.Forms.Application.Exit();
            }

            rc = SAPI.HandleAcquire(out hSession);
            if (rc != 0)
            {
                System.Windows.Forms.MessageBox.Show("Failed in SAPIHandleAcquire (" + rc.ToString("X") + ")");
                System.Windows.Forms.Application.Exit();
            }

            isLoggedIn = false;
        }
        //Checks if SAPI is initialized or not.
        private static bool isSAPIInitialized(SAPICrypt SAPI)
        {
            SESHandle hSes;
            int rc;
            if ((rc = SAPI.HandleAcquire(out hSes)) != 0)
                return false;

            SAPI.HandleRelease(hSes);
            return true;
        }