1
I need to register a dll by Delphi (xe2) in Windows XP, but when running the windows method opens a "Run as" window where you need to indicate the user who will perform the action. Even though my user is an administrator on the machine.
I used the following method to record the Dll:
procedure TForm1.ExecAdmin(Programa, Parametros: string);
var sei: TShellExecuteInfo;
begin
ZeroMemory(@sei, SizeOf(sei));
sei.cbSize := SizeOf(TShellExecuteInfo);
sei.Wnd := Application.Handle;
sei.fMask := SEE_MASK_FLAG_DDEWAIT or SEE_MASK_FLAG_NO_UI;
sei.lpVerb := PChar('runas');
sei.lpFile := PChar(Programa);
if Parametros <> '' then
sei.lpParameters := PChar(Parametros);
sei.nShow := SW_SHOWNORMAL;
ShellExecuteEx(@sei);
end;
The call of the method:
ExecAdmin('regsvr32.exe', '/s c:/sistema/msxml5.dll');
Doubts:
a) Need administrator privilege to register the dll? b) How to execute the method silently without the user check box appearing?
This program you are doing will distribute or sell. The ideal is to use a program that creates an installer for your application (for example, Inno setup), or put the program at the root of the system, where it will be run. I had many problems with DLL, I decided to put in the folder where the . exe of the system is installed, and included in the file that generates the installer. As for regsvr32.exe, it needs administrator privilege and '/s' is the silent.
– Luiz Vichiatto