---restore content starts---
The Dsoframer.ocx control was used recently to help the company develop an application similar to a Help document, and it was provided by Microsoft with an open source control for online editing, including registration, And the use of methods online already has a lot of tutorials. But when I have developed my own application in accordance with my predecessors ' tutorials, I found that I wrote something that could not be runon someone else's computer, why? Because the user's PC must also register dsoframer.ocx to run, And my app is dedicated to non-developers. It's not realistic to put the control in the system tray and then register it with the command line, and it also affects the user experience. This online also has the big God to give the solution. But because I caishuxueqian, after many attempts, I had to think about solutions, Here's my solution:
1. Write the bat for registration, where 32 bits and 64 are slightly different, as shown below
32-bit copy dsoframer.ocx c:\windows\system32\dsoframer.ocxregsvr32.exe c:\windows\system32\dsoframer.ocx//64 bit copy Dsoframer.ocx C:\windows\SysWOW64\dsoframer.ocxregsvr32.exe C:\windows\SysWOW64\dsoframer.ocx
2. Because it is a relative path, to store the Dsoframer.ocx control, two folders are placed and packaged in the same folder as shown in
3. Specific implementation code:
//This judgment code is put into the constructor, because if you do not start loading the control in the constructor method, the computer is loaded and the control is not found, then the error will be directlyBOOLisregisted = isregistered ("00460182-9e5e-11d5-b7c8-b8269041dd57");//This is the sequence in the registration table, 32 and 64 are the sameif(!isregisted) {REGISTERDSO (); }//determine if the control is already registered Private Static BOOLisregistered (String CLSID) {if(String.IsNullOrEmpty (CLSID))return false; String Key= String.Format (@"clsid\{{{0} }}", CLSID); RegistryKey RegKey=Registry.ClassesRoot.OpenSubKey (key); if(RegKey! =NULL) return true; Else return false; } /// <summary> ///Register Dsoframer/// </summary> Private voidRegisterdso () {stringTargetDir =""; stringReg ="";
Determine the number of computer operating systems specific digits 32 and 64 distinguish betweenif(environment.is64bitoperatingsystem) {TargetDir= System.Windows.Forms.Application.StartupPath +"\\64 registration \ \";//string. Format ();//PathReg ="Reg64.bat"; } Else{TargetDir= System.Windows.Forms.Application.StartupPath +"\\32 registration \ \";//string. Format ();//PathReg ="Reg32.bat"; } Process proc=NewProcess (); Proc. Startinfo.workingdirectory=TargetDir; Proc. Startinfo.filename=reg; Proc. Startinfo.arguments=string. Format ("Ten"); Proc. Startinfo.createnowindow=false; Proc. Startinfo.verb="runas";//Administrator RunProc. Start (); Proc. WaitForExit (); }
The above is my plan to achieve concrete implementation, the first time to write a blog, if there is no, please do not hesitate to enlighten. Thanks for watching!
---restore content ends---
Using C # to implement Dsoframer.ocx registration methods