dsoframer控件注册,解注册和检查注册情况
生活随笔
收集整理的這篇文章主要介紹了
dsoframer控件注册,解注册和检查注册情况
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
public class DsoframerHelper{private static string dsoframerPath = System.Windows.Forms.Application.StartupPath + @"/Plugins/dsoframer.ocx";private static string sys32Path = @"c:\windows\System32\dsoframer.ocx";//32位系統(tǒng)存放dsoframer.ocx的目錄private static string sys64Path = @"c:\windows\SysWOW64\dsoframer.ocx";//64位系統(tǒng)存放dsoframer.ocx的目錄/// <summary>/// 判斷ocx控件是否注冊的/// </summary>/// <param name="clsid"></param>/// <returns></returns>private static bool IsRegistered(string clsid){String key = String.Format(@"CLSID\{{{0}}}", clsid);Microsoft.Win32.RegistryKey Regkey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(key);if (Regkey != null)return true;elsereturn false;}/// <summary>/// 執(zhí)行cmd.exe/// </summary>/// <param name="cmdExe"></param>/// <param name="cmdPara"></param>private static void Cmd(string cmdExe, string cmdPara){using (System.Diagnostics.Process myPro = new System.Diagnostics.Process()){myPro.StartInfo.FileName = "cmd.exe";myPro.StartInfo.UseShellExecute = false; //是否使用操作系統(tǒng)shell啟動myPro.StartInfo.RedirectStandardInput = true;//接受來自調(diào)用程序的輸入信息 myPro.StartInfo.RedirectStandardOutput = true;//由調(diào)用程序獲取輸出信息myPro.StartInfo.RedirectStandardError = true;//重定向標準錯誤輸出myPro.StartInfo.CreateNoWindow = true;//不顯示程序窗口myPro.Start();string strCmd = $@"{cmdExe} {cmdPara} &exit"; //這里使用 & 是批處理命令的符號,表示前面一個命令不管是否執(zhí)行成功都執(zhí)行后面(exit)命令myPro.StandardInput.WriteLine(strCmd);myPro.StandardInput.AutoFlush = true;myPro.WaitForExit();//等待程序執(zhí)行完退出進程}}/// <summary>/// 判斷dsoframer是否注冊/// </summary>/// <returns></returns>public static bool IsRegisteredDsoframer(){return IsRegistered("00460182-9E5E-11d5-B7C8-B8269041DD57");}/// <summary>/// 注冊dsoframer/// </summary>public static void RegisteredDsoframer(){if (!File.Exists(dsoframerPath))return;//將dsoframer.ocx拷貝到系統(tǒng)目錄string sysPath = "";if (Environment.Is64BitOperatingSystem)sysPath = sys64Path;elsesysPath = sys32Path;if (!File.Exists(sysPath))File.Copy(dsoframerPath, sysPath);Cmd("regsvr32.exe", sysPath);}/// <summary>/// 解注冊dsoframer/// </summary>public static void UnRegisteredDsoframer(){Cmd("regsvr32.exe", $@" -u {dsoframerPath}");}}
(1)準備工作:
在解決方案下創(chuàng)建Plugins目錄,然后將dsoframer.ocx復制到Plugins目錄下
(2)使用:
if (!DsoframerHelper.IsRegisteredDsoframer())DsoframerHelper.RegisteredDsoframer();
?
檢查ocx控件是否注冊需要用到clsid,一下是查找方法
查看ocx控件CLSID的方法(轉(zhuǎn)載)
dsoframer.ocx(32位)下載地址:https://pan.baidu.com/s/16Jd60vgU09KYxzOlZsti-A? ? 提取碼:7xgh? ?內(nèi)涵函數(shù)使用方法
轉(zhuǎn)載于:https://www.cnblogs.com/yaosj/p/10877384.html
總結(jié)
以上是生活随笔為你收集整理的dsoframer控件注册,解注册和检查注册情况的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 模态框之Uncaught Error:
- 下一篇: 好程序员大数据笔记之:Hadoop集群搭