Click here to Skip to main content
15,884,986 members
Articles / Programming Languages / C#

Create a Vista Gadget Using Visual Studio IDE (updated)

Rate me:
Please Sign up or sign in to vote.
4.84/5 (46 votes)
8 Feb 2011CPOL13 min read 263.4K   19.5K   254  
This article describes how to use Visual Studio for developing a Vista Gadget.
using System;
using System.Collections.Generic;
using System.Text;
using EnvDTE;
using EnvDTE80;
using System.IO;

namespace RunVistaGadget21.AdditionalApplicationsWrappers
{
    public class SigntoolRunner : ApplicationRunner
    {
        String SigntoolPath;
        String WindowsSDKDirectoryPath = String.Empty;        

        public SigntoolRunner(DTE2 applicationObject)
            : base(applicationObject, false)
        {

        }

        public SigntoolRunner(DTE2 applicationObject, bool isRunAsWinApp)
            : base(applicationObject, isRunAsWinApp)
        {

        }

        public override string GetAppArguments()
        {
            String PFXFilePath = gp.PfxFilePath;
            String Password = gp.PfxPassword;
            String TimeStampDllUrl = @"http://timestamp.verisign.com/scripts/timstamp.dll";
            String SigntoolArgs = String.Format(" sign /v /f {0} /p {1} /t {2}  {3}", PFXFilePath, Password, TimeStampDllUrl, GadgetPath);

            return SigntoolArgs;
        }

        public override string GetOutputAndRunApplication()
        {
            string SigntoolOutput = string.Empty;

            SigntoolPath = gp.SigntoolPath;
            if (File.Exists(SigntoolPath))
            {
                base.CalledApplicationPath = SigntoolPath;
                SigntoolOutput = base.GetOutputAndRunApplication();
            }
            else
            {
                SigntoolOutput = "Couldn't find signtool.exe file for signing gadget. Please, define path to 'signtool.exe'";
            }
            return SigntoolOutput;
        }

    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Canada Canada
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions