Results 1 to 7 of 7

Thread: Changing Windows Wallpaper using Managed Code? [Resolved]

  1. #1

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718

    Question Changing Windows Wallpaper using Managed Code? [Resolved]

    In VB6 i have this terrific piece of code that i use to change the Windows wallpaper. It changes JPEGs, BMPs etc. How would i do this in VB.NET 2003? Any ideas?

    VB Code:
    1. Private Declare Function SystemParametersInfo Lib "user32" Alias _
    2.   "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, _
    3.   ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
    4.  
    5.  
    6. Private Const SPIF_SENDWININICHANGE = &H2
    7. Private Const SPIF_UPDATEINIFILE = &H1
    8. Private Const SPI_SETDESKWALLPAPER = 20

    VB Code:
    1. SavePicture pPicture, "C:\WINDOWS\Web\Wallpaper\Current Wallpaper.bmp"
    2.    
    3.     ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ByVal "C:\WINDOWS\Web\Wallpaper\Current Wallpaper.bmp", _
    4.     SPIF_SENDWININICHANGE Or SPIF_UPDATEINIFILE)
    Last edited by Ideas Man; May 21st, 2004 at 09:44 PM.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  2. #2
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682

    Re: Changing Windows Wallpaper using Managed Code?

    Just look in MSDN under API functions and you should be able to find a way to wrap the declaration in a way that works from vb.net.
    I don't live here any more.

  3. #3

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    I have no idea how to do that, i found this code while searching a couple of months back
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Although having said that, I just tried it myself and it wouldnt show the new picture, it wouls get rid of the old one and show nothing instead.

    Odd, no errors though. Curious.
    I don't live here any more.

  5. #5

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Well there might be more ot it than that, it's broken up when i got the code to do various things in different places. If all or part of it can't be managed code, i spose it'll have to do, but i'd think that some of it could be managed code.

    Oh pPicture has to be a path I think too, the path to the source picture.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

  6. #6
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    Change longs to integers
    \m/\m/

  7. #7

    Thread Starter
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Don't worry about my code, i just realised it's all over the place doing differnet things lol, can't even remember how it worked . Anyway i gave up trying to find a managed solution, i figure there isn't any unfortunatly, so i used the code found here: http://www.vbforums.com/showthread.p...ferrerid=35425 that MrGTI posted for all those looking. It works, but I'd still rather be managed code. Never mind.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

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