Win32 examples



examples/win32/eventlog.pl
use 5.010;
use Modern::Perl;
use Win32::EventLog;

my $h = Win32::EventLog->new('System', $ENV{ComputerName}) or die;
my $recs;
my $base;
$h->GetNumber($recs);
say $recs;

$h->GetOldest($base);
say $base;

examples/win32/gui.pl
use 5.010;
use Modern::Perl;
use Win32::GUI;

examples/win32/ipconfig.pl
use 5.010;
use Modern::Perl;
use Win32::IPConfig;

#my $host = '127.0.0.1';
my $host = 'dwarf';
my $ipconfig = Win32::IPConfig->new($host) or die;

say 'hostname=', $ipconfig->get_hostname;
say 'domain=',   $ipconfig->get_domain;

examples/win32/message.pl
use 5.010;
use Modern::Perl;

use Win32;


# Win32::MsgBox('hello');

my $resp = Win32::MsgBox('hello', 3, 'Some title');
Win32::MsgBox($resp);

examples/win32/send_gmail.pl
use 5.010;
use Modern::Perl;
use Email::Send::SMTP::Gmail;

my $mail=Email::Send::SMTP::Gmail->new( 
      -smtp   =>'gmail.com',
      -login  =>'szabgab@gmail.com',
      -pass   =>'',
#      -debug  => 0,
);

$mail->send(-to=>'szabgab@gmail.com',
               -subject  =>'Hello! 2',
               -verbose  => 0,
               -body     =>'Just testing it',
           #    -attachments=>'full_path_to_file',
           );

$mail->bye;
say 'DONE';

examples/win32/simple.pl
use 5.010;
use Modern::Perl;
use File::Find::Rule;

my $rule = File::Find::Rule->file()
                           ->name( '*.log' )
                           ->maxdepth(1)
                           ->size( '>7K' )
                           ->start( 'C:\Windows' );
                           
while (my $file = $rule->match) {
    say $file, '  ', -s $file;
}
say 'DONE';


# list all the files ordered by date
# ordered by the number of 'Error' strings in each file