Search code examples
c#ocxregsvr32

How to register .ocx file from code


How to register .ocx file with (regsvr32) from code in C# ?

i use below code but says :

The system cannot find the file specified

System.Diagnostics.Process.Start("regsvr32 " + ocxfile_path);

Solution

  • When you call Process.Start you need to specify arguments separately.

    System.Diagnostics.Process.Start("regsvr32 ", ocxfile_path);
    

    All I changed is + to ,. If ocxfile_path has spaces in it, you need to enclose it in quotes.