The Regsvr32 tool is used to register or un-register DLL or OCX files.
Eg.:
Regsvr32 [/u] [/s] [/n] [/i[:cmdline]] dll_name
/u – un-register server
/s – to run silently without display any message boxes
dll_name – indicates the path and file name of the DLL to register. More than one DLL is allowed in this command.
Example:
regsvr32 C:\example.ocx
regsvr32 /u C:\example.ocx
Sometimes we need to register DLLs programmatically, the codes below will show you how to invoke the regsvr32.exe and register a dll file in C#.
/////////////////////
using System.Diagnostics;
public static void registerDLL(string dllPath)
{
try {
//'/s' : indicates regsvr32.exe to run silently.
string fileinfo = "/s" + " " + "\"" + dllPath + "\"";
Process dllreg = new Process();
dllreg.StartInfo.FileName = "regsvr32.exe";
dllreg.StartInfo.Arguments = fileinfo;
dllreg.StartInfo.UseShellExecute = false;
dllreg.StartInfo.CreateNoWindow = true;
dllreg.StartInfo.RedirectStandardOutput = true;
dllreg.Start();
dllreg.WaitForExit();
dllreg.Close();
}
catch(Exception ex) {
MessageBox.Show(ex.Message);
}
}
Thanks.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment