Regsvr32 is a command-line tool that registers .dll files as command components in the registry.
Syntax:
regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dllname
Parameters
/u : Unregisters server.
/s : Specifies regsvr32 to run silently and to not display any message boxes.
/n : Specifies not to call DllRegisterServer. You must use this option with /i.
/i :cmdline : Calls DllInstall passing it an optional [cmdline]. When used with /u, it calls dll uninstall.
dllname : Specifies the name of the dll file that will be registered.
/? : Displays help at the command prompt.
Examples
regsvr32 filename.dll
The following code sample can be used to invoke the Regsvr32(command-line tool) file in C# and register a dll file programatically. We should suuply the necessary arguments to the regsvr32.exe. In the sample below, it shows you how to register a given file silently without displaying any messages.
This code sample also shows you how to invoke an external application from C#, start it and wait for it until it exits. The standard output of that external process or application can be read in C#.
public static void Registar_Dlls(string filePath)
{
try
{
//'/s' : Specifies regsvr32 to run silently and to not display any message boxes.
string arg_fileinfo = "/s" + " " + "\"" + filePath + "\"";
Process reg = new Process();
//This file registers .dll files as command components in the registry.
reg.StartInfo.FileName = "regsvr32.exe";
reg.StartInfo.Arguments = fileinfo;
reg.StartInfo.UseShellExecute = false;
reg.StartInfo.CreateNoWindow = true;
reg.StartInfo.RedirectStandardOutput = true;
reg.Start();
reg.WaitForExit();
reg.Close();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}
}




