Daily Dilbert

By | 2002-06-01

This program Downloads the archive page from
‘ http://www.unitedmedia.com/comics/dilbert
‘ extracts the file name of the picture. Download it. Convert it to bitmap.
‘ Changes the desktop wallpaper to the new dilbert strip.

Original Author: Bjorn Larsson

Assumptions

You must have an internet connection..

Returns

2 files on c: dilbert.gif and dilbert.bmp
‘ A changed wallpaper.

Side Effects

Sometimes the desktop wallpaper is not visible
‘ unless you refresh the desktop yourself
‘ or select it manually. I don’t know why this happends…

API Declarations

Declare Function SystemParametersInfo Lib “user32” Alias “SystemParametersInfoA” (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long

Code

' 1. Create a new form.
' 2. Add a Textbox,a pictureBox and an Inet control.
' 3. Let them all have their default name.
' 4. Put all the code expect the global decleration in the "form load procedure"
Dim Pos As Integer
Dim Pos2 As Integer
Dim Bilden() As Byte
Dim NrString As String
Text1.Text = Inet1.OpenURL ("http://www.unitedmedia.com/comics/dilbert/archive/") 'Download the page.
Pos = InStr(1, Text1.Text, "/comics/dilbert/archive/images/dilbert")
Pos2 = InStr(Pos, Text1.Text, ".gif")
NrString = Mid(Text1.Text, Pos, Pos2 - Pos)
Text1.Text = "http://www.unitedmedia.com" + NrString + ".gif" ' Debug filename
Bilden() = Inet1.OpenURL("http://www.unitedmedia.com" + NrString + ".gif", icByteArray) ' Download picture.
Open "C:dilbert.gif" For Binary Access Write As #1 ' Save the file.
Put #1, , Bilden()
Close #1
Picture1.Picture = LoadPicture("c:dilbert.gif") 'Reload it to PictureBox
SavePicture Picture1.Picture, "c:dilbert.bmp"  'Converted to bmp..

Call SystemParametersInfo(20, 0, "c:dilbert.bmp", 1) 'Change the wallpaper.
Unload Me ' Exit program

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.