Esempio n. 1
0
        //-------------------------------------------------
        // CApplication - Constructor
        //
        // Initializes some variables, and determines the icon
        // we'll be displaying for this application.
        //-------------------------------------------------
        internal CApplication(AppFiles appInfo)
        {
            // Standard stuff we need to set for all nodes
            m_sGuid        = "C338CBF6-2F60-4e1b-8FB5-12FEAE2DD937";
            m_sHelpSection = "";
            m_appInfo      = appInfo;

            // Let's pull the path and extension off of the application filename
            // so we can display just the application name to the user

            // We're guarenteed to have at least the config file, but not necessarily the
            // application file... let's get our best name

            String sName = (m_appInfo.sAppFile.Length > 0) ? m_appInfo.sAppFile : m_appInfo.sAppConfigFile;

            // Get the file description
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(sName);

            if (fvi.FileDescription != null && fvi.FileDescription.Length > 0 && !fvi.FileDescription.Equals(" "))
            {
                m_sDisplayName = fvi.FileDescription;
            }
            else
            {
                String[] sWords = sName.Split(new char[] { '\\' });
                m_sDisplayName = sWords[sWords.Length - 1];
            }

            // Can't set this up until we know what our display name is
            m_oResults = new CApplicationTaskPad(this);

            // Let's try and get the icon that explorer would use to display this file
            m_hIcon = (IntPtr)(-1);
            SHFILEINFO finfo   = new SHFILEINFO();
            uint       iRetVal = 0;

            // Grab an icon for this application
            iRetVal = SHGetFileInfo(sName, 0, out finfo, 20, SHGFI.ICON | SHGFI.SMALLICON);

            // If this function returned a zero, then we know it was a failure...
            // We'll just grab a default icon
            if (iRetVal == 0)
            {
                m_hIcon   = CResourceStore.GetHIcon("application_ico");
                m_bBigPic = new Bitmap(Bitmap.FromHicon(m_hIcon), new Size(32, 32));
            }
            // We could get a valid icon from the shell
            else
            {
                m_hIcon = finfo.hIcon;
                // Obtain a cookie for this icon
                int iIconCookie = CResourceStore.StoreHIcon(m_hIcon);
                // Put this icon in MMC's image list
                CNodeManager.ConsoleImageListSetIcon(m_hIcon, iIconCookie);

                // We can also get the 'big' icon to use in the property page
                iRetVal   = SHGetFileInfo(sName, 0, out finfo, 20, SHGFI.ICON);
                m_bBigPic = new Bitmap(Bitmap.FromHicon(finfo.hIcon));
            }
        }// CApplication