[转载]C#中注册Dll的问题
生活随笔
收集整理的這篇文章主要介紹了
[转载]C#中注册Dll的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
我在C#下做的POS客戶端程序調用別人的一個api_com.dll程序,然后,我又使用了一個第三方的工具實現了客戶端的自動更新,現在就出現問題了,每次有新版本時,該自動更新程序總是把原來的目錄重新拷貝一份到新目錄中,這樣導致新產生的目錄中的api_com.dll沒有注冊,程序無法運行,請問,有什么方法可以讓api_com.dll只用注冊一次(在安裝時),或者說可以將它注冊為全局的?;蛘?#xff0c;在C#中,如何寫代碼來實現dll的注冊功能????????????
ExeCommand("regsvr32 path\***.dll")public string ExeCommand(string commandText){Process p = new Process();p.StartInfo.FileName = "cmd.exe";p.StartInfo.UseShellExecute = false;p.StartInfo.RedirectStandardInput = true;p.StartInfo.RedirectStandardOutput = true;p.StartInfo.RedirectStandardError = true;p.StartInfo.CreateNoWindow = true;string strOutput = null;try{p.Start();p.StandardInput.WriteLine(commandText);p.StandardInput.WriteLine("exit");strOutput = p.StandardOutput.ReadToEnd();p.WaitForExit();p.Close();}catch(Exception e){strOutput = e.Message;}return strOutput;}
ExeCommand("regsvr32 path\***.dll")public string ExeCommand(string commandText){Process p = new Process();p.StartInfo.FileName = "cmd.exe";p.StartInfo.UseShellExecute = false;p.StartInfo.RedirectStandardInput = true;p.StartInfo.RedirectStandardOutput = true;p.StartInfo.RedirectStandardError = true;p.StartInfo.CreateNoWindow = true;string strOutput = null;try{p.Start();p.StandardInput.WriteLine(commandText);p.StandardInput.WriteLine("exit");strOutput = p.StandardOutput.ReadToEnd();p.WaitForExit();p.Close();}catch(Exception e){strOutput = e.Message;}return strOutput;}
轉載于:https://www.cnblogs.com/ruiruizhang/archive/2010/01/19/1651240.html
總結
以上是生活随笔為你收集整理的[转载]C#中注册Dll的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 陈慧琳的10招不节食瘦身法 - 健康程序
- 下一篇: C# 关键字