Results 1 to 10 of 10

Thread: Code to place a user selected picture as the Background Picture

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270

    Code to place a user selected picture as the Background Picture

    This is an odd request. My company (in its infinite wisdom) has decided to automatically place the company logo as the background picture at network logon.

    I'd like to write a little VB program that I could put in the Startup folder that would replace that with my selected picture automatically.

    Any ideas on how to access the Windows Background property? Thanks.

    Nate

  2. #2
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    Change the background, then find the value at the following registry key:

    HKEY_CURRENT_USER\Control Panel\Desktop:WallPaper

    Write a program that will change that to another value on load, then (not sure how this is possible) send an F5 to the desktop so it refreshes.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    The administrators have disable RegEdit. So, I can't look at it to find that reference. Any documentation sources?

  4. #4
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Disabling RegEdit, etc, won't stop access to the registry - use a third party tool or query the keys via VB.
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  5. #5
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    You can use the SystemParametersInfo:

    Code:
    'Put this in a module
    Public Declare Function SystemParametersInfo Lib "user32.dll" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uiParam As Long, pvParam As Any, ByVal fWinIni As Long) As Long
    Public Const SPI_SETDESKWALLPAPER = 20
    Public Const SPIF_SENDWININICHANGE = &H2
    Public Const SPIF_UPDATEINIFILE = &H1
    
    'use this in your program:
    
    dim retval as long
    dim picturepath as string
    
    picturepath = "c:\windows\clouds.bmp"
    retval = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal picturepath, SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    Code:
    query the keys via VB
    This is what I don't have a clue how to do. I don't know how to access the registry at all. Nor do I know the syntax of the registry statements. Is the registry basically a text file so I can do something like an instr function or do I need to use an API function or a series of API functions. I just started working through the API tutorial http://www.vbapi.com yesterday.

    Thanks.
    Nate

  7. #7
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180
    With the code I posted above you don't have to worry about querying keys or messing with the register. Just leave that to windows.

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Omaha, NE
    Posts
    270
    I tried this. I browsed for some of the files in my background list & found them in a path. So, I changed the picturepath line to:
    Code:
    picturepath = "C:\WINNT\WEB\WALLPAPER\CHATEAU.JPG"
    Nothing happens. The background is still the same picture it has been.

    Thanks.
    Nate

  9. #9
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    SystemParametersInfo onlu accepts *.bmp files - to set *.jpg files, you need to use the IActiveDesktop interface, and Active Desktop has to be turned on.

    http://www.domaindlx.com/e_morcillo/....asp?esp=false
    http://www.msjogren.net/dotnet/eng/s...dwallpaper.asp
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  10. #10
    Banned Michael_Kamen's Avatar
    Join Date
    May 2001
    Location
    The Netherlands
    Posts
    1,180

    Or convert it......

    Or just convert your .JPG into .BMP with Irfanview

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width