c# - 在 C# 中在 Windows 7 上注册 dll

标签 c# dll windows-7 registry

如何在 Windows 7 上注册我编写的 dll?

我找到了这个代码片段,但它似乎在 Windows 7 中不起作用:

public static void registerDLL(string dllPath) 
{
  try {
    //'/s' : indicates regsvr32.exe to run silently.
    string fileinfo = "/s" + " " + "\"" + dllPath + "\"";

    Process reg = new Process();
    reg.StartInfo.FileName = "regsvr32.exe";
    reg.StartInfo.Arguments = fileinfo;
    reg.StartInfo.UseShellExecute = false;
    reg.StartInfo.CreateNoWindow = true;
    reg.StartInfo.RedirectStandardOutput = true;
    reg.Start();
    reg.WaitForExit();
    reg.Close();
    }
catch(Exception ex) {
    MessageBox.Show(ex.Message);
    }
}

最佳答案

工具“regsvr32.exe”只能注册 native COM-Dll。如果要注册用 C# 编写的 DotNet COM 对象,则必须改用“regasm.exe”。为此,您需要提升权限,因为它会写入注册表中的 HKEY_LOCAL_MACHINE。

关于c# - 在 C# 中在 Windows 7 上注册 dll,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7401197/

相关文章:

c# - NHibernate 选择符合条件的最新记录

css - Sublime Text 3 - 代码片段不会在选项卡上触发,仅在 CSS 文件上触发

visual-studio-code - Visual Studio Code 远程 SSH 在 ssh_config 中使用 Windows 用户名而不是用户名

c# - .Net chart control XY graph 当所有X值都相同时输出错误

c# - Xamarin Forms 导航问题

c# - 如何在 C# 中为动态文本框设置 textMode = Multiline

c++ - 需要 dll 入口点问题/建议

c++ - 有关保护 DLL 代码的任何提示?

c# - 制作C#工程DLL和EXE

c++ - CEdit::GetLine() Windows 7