Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Help a newbie... Small Application.. Uninstaller

I'm new to this forum so first and foremost, hi!

Ok down to business, basically, I need a program that will end a few processes, remove some files and registry entries, with a progress indicator and a start button and completed/exit button...

So, basically your a presented with form1 onload, with a start remove button, then that closes form1 and opens form2 > I need it to find and stop cirtain processes, for example the ones that relate to the application I wish to remove. This must be able to have defined process endtask, because I dont want it ending system tasks by mistake, so I'd like a more c:myfilesmyprocess.exe endtask for example.

if I define it to find c:myfiledeletethis.exe and c:myexesanotherfile.exe and any number of files I wish to define, so it needs to be simple like

Tfindfile
All files I wish to find go here
.deletefile

(thats just an example of how I would like it to operate, not actual code, I'm new to delphi you see.)

and delete.

While, also, it will remove a few defined registry entries, same way as removing files. Easy so I can add any entires to this.
Form2, which will have a progress indicator if possible to show progress, if possible, also show action that is being carried out.

When completed I wish to have form 2 closed another form3 displayed with Completed on, and an exit button.

Is this possible and can anyone help me? It's pretty urgent, as yet I dont have a way of uninstalling. I'm sure this application is [pretty simple for you guys. I havent started it yet so if anyone can post code that would be very, very, kind of you.

Thanks in advance.

Many Regards,
G25

Comments

  • zibadianzibadian Member Posts: 6,349
    : I'm new to this forum so first and foremost, hi!
    :
    : Ok down to business, basically, I need a program that will end a few processes, remove some files and registry entries, with a progress indicator and a start button and completed/exit button...
    :
    : So, basically your a presented with form1 onload, with a start remove button, then that closes form1 and opens form2 > I need it to find and stop cirtain processes, for example the ones that relate to the application I wish to remove. This must be able to have defined process endtask, because I dont want it ending system tasks by mistake, so I'd like a more c:myfilesmyprocess.exe endtask for example.
    :
    : if I define it to find c:myfiledeletethis.exe and c:myexesanotherfile.exe and any number of files I wish to define, so it needs to be simple like
    :
    : Tfindfile
    : All files I wish to find go here
    : .deletefile
    :
    : (thats just an example of how I would like it to operate, not actual code, I'm new to delphi you see.)
    :
    : and delete.
    :
    : While, also, it will remove a few defined registry entries, same way as removing files. Easy so I can add any entires to this.
    : Form2, which will have a progress indicator if possible to show progress, if possible, also show action that is being carried out.
    :
    : When completed I wish to have form 2 closed another form3 displayed with Completed on, and an exit button.
    :
    : Is this possible and can anyone help me? It's pretty urgent, as yet I dont have a way of uninstalling. I'm sure this application is [pretty simple for you guys. I havent started it yet so if anyone can post code that would be very, very, kind of you.
    :
    : Thanks in advance.
    :
    : Many Regards,
    : G25
    :
    Before going writing your own uninstaller, check out the configuration screen, then the software section. This should list all the installed software on your PC, and give you the option to remove or change it.

    The Delphi way:

    First some advice; I wouldn't use different forms, but a TPageControl with all the tabs hidden. Here is a code to hide the tabs during runtime:
    [code]
    for i := 0 to PageControl1.TabCount-1 do
    PageControl1.Tabs[i].TabVisible := false;
    [/code]
    You can then jump from page to page using this code:
    [code]
    PageControl1.ActivePageIndex := PageControl1.ActivePageIndex + 1;
    [/code]

    Next: Removing the Registry keys

    The best way to access the registry is using the TRegistry object.
    [b][red]!!! ALWAYS MAKE A BACKUP OF YOUR REGISTRY BEFORE TESTING YOUR PROGRAM !!![/red][/b]
    Here is a code, which removes some keys from a certain hive:
    [code]
    MyReg := TRegistry.Create;
    with MyReg do
    try
    RootKey := HKEY_LOCAL_MACHINE;
    OpenKey(Edit1.Text); // Open the hive
    for i := 0 to Memo1.Lines.Count-1 do
    begin
    if KeyExists(Memo1.Lines[i]) then
    DeleteKey(Memo1.Lines[i])
    else if ValueExists(Memo1.Lines[i]) then
    DeleteValue(Memo1.Lines[i]);
    finally
    MyReg.Free;
    end;
    [/code]
    This code might fail in Win2000 and WinXP, if the keys contain subkeys.

    Deleting Files:

    Once you have your list of files to delete, you can loop through it and call the DeleteFile() function for each of them. That's pretty simple to code.

    Stopping processes:

    This is quite difficult and elaborate, because nowadays windows protects the different processes quite well. The coding method to find the process is called "Process Walking" and has its own entry in the Windows API help. It uses the CreateToolhelp32Snapshot(), Process32First(), and process32Next() functions. From those functions you will get a lot of handles and IDs, which provide access to the individual processes and modules. It also lists the filenames of the executables. You can then use ExitProcess() to close the processes you want to close.
  • gareth25gareth25 Member Posts: 4
    How do I use the code here:

    http://www.festra.com/eng/mtut08.htm

    I get a undeclared identifer with Tregistry? and a host of other messages. Where do I place the code?
  • zibadianzibadian Member Posts: 6,349
    : How do I use the code here:
    :
    : http://www.festra.com/eng/mtut08.htm
    :
    : I get a undeclared identifer with Tregistry? and a host of other messages. Where do I place the code?
    :
    Paste it into your source and call the procedure. For the "undeclared identifier" or "unknown identifier" place the correct unit in the uses list. You can find which unit declares wich identifier in the help files.
    If you are looking for a simple way to learn Delphi, you should take the "Developer's Guide" by Teixeira and Pacheco. It's excellent.
  • gareth25gareth25 Member Posts: 4
    Thanks...

    Got another problem

    Reg := TRegistry.Create;
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    if Reg.KeyExists('SoftwareMicrosoftWindowsCurrentVersionRuncalc') then
    Reg.DeleteKey('SoftwareMicrosoftWindowsCurrentVersionRuncalc')
    Reg.Free;
    end;

    does not delete the key?
  • zibadianzibadian Member Posts: 6,349
    : Thanks...
    :
    : Got another problem
    :
    : Reg := TRegistry.Create;
    : Reg.RootKey := HKEY_LOCAL_MACHINE;
    : if Reg.KeyExists('SoftwareMicrosoftWindowsCurrentVersionRuncalc') then
    : Reg.DeleteKey('SoftwareMicrosoftWindowsCurrentVersionRuncalc')
    : Reg.Free;
    : end;
    :
    : does not delete the key?
    :
    That is because SoftwareMicrosoftWindowsCurrentVersionRuncalc isn't a key, but a value. Thus the KeyExists() method returns false and the DeleteKey() is never called.
  • gareth25gareth25 Member Posts: 4
    : : Thanks...
    : :
    : : Got another problem
    : :
    : : Reg := TRegistry.Create;
    : : Reg.RootKey := HKEY_LOCAL_MACHINE;
    : : if Reg.KeyExists('SoftwareMicrosoftWindowsCurrentVersionRuncalc') then
    : : Reg.DeleteKey('SoftwareMicrosoftWindowsCurrentVersionRuncalc')
    : : Reg.Free;
    : : end;
    : :
    : : does not delete the key?
    : :
    : That is because SoftwareMicrosoftWindowsCurrentVersionRuncalc isn't a key, but a value. Thus the KeyExists() method returns false and the DeleteKey() is never called.
    :

    You see, thats because VB, which I have used just works in that way, so It's me thinking Delphi would be the same.

    I figured it eventually, and now it works.

    Thanks!
Sign In or Register to comment.