line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Win32::Wallpaper;
|
2
|
|
|
|
|
|
|
require Exporter;
|
3
|
|
|
|
|
|
|
@Win32::Wallpaper::ISA = qw(Exporter);
|
4
|
|
|
|
|
|
|
@Win32::Wallpaper::EXPORT = qw(wallpaper);
|
5
|
|
|
|
|
|
|
$VERSION = '0.04';
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7756
|
use Win32::API;
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use File::Spec::Functions qw(rel2abs);
|
9
|
|
|
|
|
|
|
use Win32::TieRegistry(Delimiter=>"/");
|
10
|
|
|
|
|
|
|
use Image::Size;
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub wallpaper {
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my ( $file, $style ) = @_;
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
unless ($file) {
|
17
|
|
|
|
|
|
|
my $CW = $Registry->{"CUser/Control Panel/Desktop/Wallpaper"};
|
18
|
|
|
|
|
|
|
return($CW);
|
19
|
|
|
|
|
|
|
}
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
open( IN, $file ) or die "Cannot open $file: $!";
|
22
|
|
|
|
|
|
|
my ( $width, $height, $id ) = imgsize( \*IN );
|
23
|
|
|
|
|
|
|
die "Only Windows BitMaP images supported. You used a $id."
|
24
|
|
|
|
|
|
|
unless ( $id =~ /bmp/i );
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
if ( $style =~ /\btile\b|\bstretch\b|\bcenter\b/i ) {
|
27
|
|
|
|
|
|
|
my $opt1 = "CUser/Control Panel/Desktop/TileWallpaper";
|
28
|
|
|
|
|
|
|
my $opt2 = "CUser/Control Panel/Desktop/WallpaperStyle";
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
if ( $style =~ /tile/i ) {
|
32
|
|
|
|
|
|
|
$Registry->{$opt1}=1;
|
33
|
|
|
|
|
|
|
$Registry->{$opt2}=0;
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
elsif ( $style =~ /stretch/i ) {
|
37
|
|
|
|
|
|
|
$Registry->{$opt1}=0;
|
38
|
|
|
|
|
|
|
$Registry->{$opt2}=2;
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
}
|
41
|
|
|
|
|
|
|
else {
|
42
|
|
|
|
|
|
|
$Registry->{$opt1}=0;
|
43
|
|
|
|
|
|
|
$Registry->{$opt2}=0;
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
}
|
46
|
|
|
|
|
|
|
}
|
47
|
|
|
|
|
|
|
else {
|
48
|
|
|
|
|
|
|
die
|
49
|
|
|
|
|
|
|
"Your wallpaper style - $style - is unsupported. Try \"Center\" \"Tile\" or \"Stretch\""
|
50
|
|
|
|
|
|
|
if $style;
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
}
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$file = rel2abs $file;
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
my $SystemParametersInfo =
|
57
|
|
|
|
|
|
|
new Win32::API(qw(user32 SystemParametersInfoA NNPN N)) || die $^E;
|
58
|
|
|
|
|
|
|
use constant SPIF_SETDESKWALLPAPER => 20;
|
59
|
|
|
|
|
|
|
use constant SPIF_UPDATEINIFILE => 1;
|
60
|
|
|
|
|
|
|
$SystemParametersInfo->Call( SPIF_SETDESKWALLPAPER, 0, $file,
|
61
|
|
|
|
|
|
|
SPIF_UPDATEINIFILE ) || die $^E;
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
}
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1;
|
66
|
|
|
|
|
|
|
__END__
|