The problem with the COM components i.e. DLL is that they need to be registered in the windows to put them to work. Registry Server can be used to register those DLLs. While doing this task manually one need to use command window to register the DLL file using Registry Server executable. Whoever, sometimes we also need to register some DLL from our application code using either C# or Visual Basic.Net. In this post I'll show you the code to register a COM DLL using C# code. This procedure can also be used with Visual Basic.Net as well with a slight modifications in syntax.
Following code snippet uses Process class of System.Diagnostics namespace. Just create an object of process class and pass few arguments to get the DLL registered in windows.
System.Diagnostics.Process Proc = new System.Diagnostics.Process(); Proc.StartInfo.FileName = "regsvr32.exe";
Proc.StartInfo.Arguments = "filename.dll /s";
Proc.StartInfo.CreateNoWindow = true;
Proc.Start();
Proc.WaitForExit();
No comments:
Post a Comment