[转载]C#中注册Dll的问题
生活随笔
收集整理的這篇文章主要介紹了
[转载]C#中注册Dll的问题
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
我在C#下做的POS客戶端程序調(diào)用別人的一個(gè)api_com.dll程序,然后,我又使用了一個(gè)第三方的工具實(shí)現(xiàn)了客戶端的自動(dòng)更新,現(xiàn)在就出現(xiàn)問題了,每次有新版本時(shí),該自動(dòng)更新程序總是把原來的目錄重新拷貝一份到新目錄中,這樣導(dǎo)致新產(chǎn)生的目錄中的api_com.dll沒有注冊(cè),程序無法運(yùn)行,請(qǐng)問,有什么方法可以讓api_com.dll只用注冊(cè)一次(在安裝時(shí)),或者說可以將它注冊(cè)為全局的。或者,在C#中,如何寫代碼來實(shí)現(xiàn)dll的注冊(cè)功能????????????
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;}
轉(zhuǎn)載于:https://www.cnblogs.com/ruiruizhang/archive/2010/01/19/1651240.html
總結(jié)
以上是生活随笔為你收集整理的[转载]C#中注册Dll的问题的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 陈慧琳的10招不节食瘦身法 - 健康程序
- 下一篇: c# char unsigned_dll