From: Tim J. <toj...@gm...> - 2008-04-05 11:55:52
|
Oops. Trying again from an account that is actually a member of the list. On Fri, Apr 4, 2008 at 4:45 PM, Tim Johnson <toj...@gm...> wrote: > I was tasked with making a quick and dirty uninstaller that can be > launched through SMS in order to give people without admin rights the right > to uninstall things, and so I whipped up something quick and dirty (code > below). It actually works pretty well, but there's one big problem: The > combo box is longer than the height of the window, and while I can use the > arrow keys to scroll up and down, I would much rather have a scroll bar in > order to view the rest of the list. What am I missing? A quick search of > the Google didn't really help much. > > > ######################################## > > use strict; > use warnings; > use Win32::GUI; > use Win32::TieRegistry (Delimiter => '/'); > > > sub MainWindow_Terminate() { > -1; > } > > sub GetUninstallInfo() { > my %uninstall = (); > my $uninstall_key = > $Registry->{'HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/' . > 'CurrentVersion/Uninstall'}; > no warnings qw(uninitialized); > > foreach my $key(keys %{$uninstall_key}) { > if ($uninstall_key->{$key . "DisplayName"}) { > my $name = join(' ', $uninstall_key->{$key . "Publisher"}, > $uninstall_key->{$key . "DisplayName"}, > $uninstall_key->{$key . "DisplayVersion"}); > $name =~ s/^\s+//; > $uninstall{$name} = $uninstall_key->{$key . "UninstallString"} > } > } > use warnings qw(uninitialized); > return %uninstall; > } > > my $main_app_name = "Google Universal Uninstaller 1.0"; > my $icon = new Win32::GUI::Icon('g.ico') or die(); > my $window = Win32::GUI::Window->new(-name => 'MainWindow', > -width => 550, > -height => 150, > -title => $main_app_name); > $window->ChangeIcon($icon); > > my %uninstall = GetUninstallInfo(); > > my $combo_box = $window->AddCombobox(-name => "UninstallList", > -text => "Applications", > -width => 500, > -height => 120, > -left => 10, > -top => 10, > -sort => 1, > -dropdown => 1, > -resizable => 0, > ); > > > foreach my $application (keys %uninstall) { > if ($uninstall{$application}) { > $combo_box->AddString($application); > } > } > > $combo_box->SetCurSel(0); > > my $button = $window->AddButton(-name => "BtnRemove", > -text => "Uninstall the selected > application.", > -width => "300", > -height => "40", > -top => 50, > -left => 100); > $button->Show(); > > > $window->Show(); > Win32::GUI::Dialog(); > > > sub BtnRemove_Click() { > my $index = $combo_box->GetCurSel(); > if ($index > -1){ > my $app = $combo_box->GetString($index); > system($uninstall{$app}); > } > } > > > ########################################## > > > -- > _____________________ > Ceci n'est pas un email. -- _____________________ Ceci n'est pas un email. |