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

<?xml version="1.0"?>
<!--
  有关如何配置 ASP.NET 应用程序的详细信息,请访问
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
    <httpRuntime/>
  </system.web>
  <appSettings>
    <add key="Path" value="D:\Avidm"/>
  </appSettings>
</configuration>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值