0

Windows サービスに関する簡単な質問です。Windows サービスのセットアップ プロジェクトを追加し、それに 4 つのテキスト フィールドを含むカスタム ダイアログを追加しましたが、これらの情報/変数を取得するにはどうすればよいですか?

また、Windows サービスのインストーラーも追加し、その後、カスタム ダイアログを使用してセットアップ プロジェクトを追加しました。

情報は、データベース接続文字列などのようなもので、文字列値のみです。

これは、「プロジェクト インストーラー」のコードです。ご覧になりたい場合は、Windows サービス用に追加されたインストーラー項目をご覧ください。

    Imports System
Imports System.ComponentModel
Imports System.Configuration.Install
Imports System.ServiceProcess
Imports System.Runtime.InteropServices



Public Class ProjectInstaller

    Public Sub New()
        MyBase.New()

        'This call is required by the Component Designer.
        InitializeComponent()

        My.Settings.TestSetting = Context.Parameters.Item("PathValue")

#If DEBUG Then

        Dim ServicesToRun As ServiceBase()
        ServicesToRun = New ServiceBase() {New tdsCheckService()}
        ServiceBase.Run(ServicesToRun)

#Else

        Dim listener As New tdsCheckService()
        listener.Start()

#End If

    End Sub

    Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
        MyBase.Install(stateSaver)
        Dim regsrv As New RegistrationServices
        regsrv.RegisterAssembly(MyBase.GetType().Assembly, AssemblyRegistrationFlags.SetCodeBase)
    End Sub
    Public Overrides Sub Uninstall(ByVal savedState As System.Collections.IDictionary)
        MyBase.Uninstall(savedState)
        Dim regsrv As New RegistrationServices
        regsrv.UnregisterAssembly(MyBase.GetType().Assembly)
    End Sub

    Private Sub ServiceProcessInstaller1_AfterInstall(sender As Object, e As InstallEventArgs) Handles ServiceProcessInstaller1.AfterInstall

    End Sub

    Private Sub ServiceInstaller1_AfterInstall(sender As Object, e As InstallEventArgs) Handles ServiceInstaller1.AfterInstall

    End Sub
End Class
4

1 に答える 1

0

Context オブジェクトを使用してそれらにアクセスできるはずです。

 'Get Protected Configuration Provider name from custom action parameter
        Dim variableName As String = Context.Parameters.Item("dialogSettingName")


  Public Overrides Sub Install(ByVal stateSaver As System.Collections.IDictionary)
    MyBase.Install(stateSaver)
于 2012-09-27T14:02:46.937 に答える