0

私の問題は、バックグラウンド アプリケーションを作成したいが、システム トレイに復元して最小化できるユーザー インターフェイスを使用し、Windows で起動することです。起動方法を検索してみましたが、UI のない Windows サービスに関するスレッドや、フォームを作成して非表示にするスレッドしか見つかりませんでした。だから私の質問は、どうやって始めればいいですか?Windows フォーム ? サービスと何らかの形でインターフェースを追加しますか?

ありがとうございました!

4

2 に答える 2

0

ユーザーがログインしたときにアプリケーションを起動したい場合は、フォームを作成して非表示にする方法があります。

ユーザーがログインしていなくてもコードを実行したい場合は、Windows サービスが必要になります。

その道を進むことを選択した場合、何らかの形でサービスと対話するアプリケーションが必要になる可能性が高くなります。

于 2015-10-02T14:07:45.720 に答える
0

フォームに関連付けられていないアプリを作成する方法を次に示します。標準の WinForms プロジェクトを使用しますが、ApplicationContextのカスタム実装を次のように渡しますApplication.Run()

static class Program
{
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        Application.Run(new MyContext());
    }

}

public class MyContext : ApplicationContext
{

    public MyContext()
    {
        // this is the new "entry point" for your application

        // use Application.Exit() to shut down the application

        // you can still create and display a NotifyIcon control via code for display in the tray
        // (the icon for the NotifyIcon can be an embedded resource)
        // you can also display forms as usual when necessary
    }

}
于 2015-10-02T14:32:47.293 に答える