create a bitmap for win32

hi there,

normally i would try to do this on myself, but i have very few time these days so i put this into the community.

i need a script that is to be run at windows-startup and that should do the following:

a) determine username and computername
b) create a bitmap with that information (eg. with text "<username> on <computername>" and black background)
c) set that bitmap as the background image (wallpaper)

i know i could solve a) and c) using windows-api, but i have no clue about part b).
i just installed imager.pm and image-magick.pm but did not have time to read their documentation.

any help appreciated,

tx holli

LVL 6
holliAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

holliAuthor Commented:
p.s.

if one could solve a) without using win-API, it will also be very welcome.
0
roee_fCommented:
Here you go:
#!/usr/bin/perl

use Win32::API;

use constant SPI_SETDESKWALLPAPER  => 20;
use constant SPIF_UPDATEANDSENDINI => 3;
use constant NULL                  => 0;

use Image::Magick;

my $filename = "C:/winnt/logindata.bmp";
$image=Image::Magick->new(size => '400x300');

$rc = $image->Read('xc:white');

#this a. on your question
my $text = "$ENV{USERNAME} on $ENV{COMPUTERNAME}";
# This is b.
$rc = $image->Annotate(
                              text => $text,
                              font => 'Tahoma',
                              fill => 'green',
                              geometry => '+20+30',
                              pointsize => 16);

$rc = $image->Write("$filename");
undef $image;

# This is C.
my $syspinf = Win32::API->new('user32','SystemParametersInfo', [I,I,P,+I], I)
  or die "Could not import function.\n";

$syspinf->Call(SPI_SETDESKWALLPAPER, 0, $filename, SPIF_UPDATEANDSENDIN+I);
0
holliAuthor Commented:
thank you for your comment.

i tried the script and found that the bitmap produced seems not to be a valid bitmap.
i can view the file with IrfanView but i cannot use it as wallpaper, not even manually.

any idea?
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

holliAuthor Commented:
i just "saved the file as" (using IrfanView) into a new file and suddenly it works.
maybe the output-format must be especially specified somewhere?
0
roee_fCommented:
Sorry, you'll have to change one line:
from
$rc = $image->Write("$filename");
to
$rc = $image->Write("bmp2:$filename");

This should do the job.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
holliAuthor Commented:
excellent. this does the job.

thank you
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.