C#、ASP.Net、batの書き込みDDTEKコントロールレジストリ方式


batバッチファイル
REG ADD "HKLM\SOFTWARE\DataDirect\Connect for ADO.NET 3.5" /V LicFileLocation /T REG_SZ /D "D:\Avidm"

C#、ASP.Netのコードファイルは同じですが、新しい工事タイプが違うだけで、一つはwinformで、一つはwebformです.なぜwebformの登録プロジェクトを構築するのか、サーバのバックグラウンドでDDTEKを呼び出す場合、ファイルを登録するパスが必要で、webfromで書かれたパスしか見つからないからです.具体的な原因は分からない.WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Win32;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string path = System.Configuration.ConfigurationManager.AppSettings["Path"];
            RegistryKey docNetItem = null;

            RegistryKey ndpItem = null;

            //RegistryKey versionItem;

            RegistryKey machinelocalItem = Registry.LocalMachine;

            RegistryKey softwareItem = machinelocalItem.OpenSubKey("SOFTWARE", true);

            if (softwareItem != null) docNetItem = softwareItem.CreateSubKey("DataDirect");

            if (docNetItem != null) ndpItem = docNetItem.CreateSubKey("Connect for ADO.NET 3.5");

            if (ndpItem != null) ndpItem.SetValue("LicFileLocation", path);

            RegistryKey checkKey = machinelocalItem.OpenSubKey(@"SOFTWARE\DataDirect\Connect for ADO.NET 3.5");
            if (checkKey != null)
            {
                Console.WriteLine("Registry OK!");
            }
        }
    }
}

Web.config


<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
  system.web>
  <appSettings>
    <add key="Path" value="D:\Avidm"/>
  appSettings>
configuration>