Click here to Skip to main content
15,904,023 members
Home / Discussions / C#
   

C#

 
AnswerRe: change a db value of 1 to "Administrator" Pin
Luis Alonso Ramos25-Jul-07 6:15
Luis Alonso Ramos25-Jul-07 6:15 
AnswerRe: change a db value of 1 to "Administrator" Pin
Eliz.k26-Jul-07 22:13
Eliz.k26-Jul-07 22:13 
QuestionDataGridView and System.ComponentModel attributes Pin
Jon Hulatt25-Jul-07 5:21
Jon Hulatt25-Jul-07 5:21 
AnswerRe: DataGridView and System.ComponentModel attributes Pin
Judah Gabriel Himango25-Jul-07 5:53
sponsorJudah Gabriel Himango25-Jul-07 5:53 
QuestionShred secured folder access Pin
ThaScorpion25-Jul-07 5:15
ThaScorpion25-Jul-07 5:15 
AnswerRe: Shred secured folder access Pin
Dave Kreskowiak25-Jul-07 7:28
mveDave Kreskowiak25-Jul-07 7:28 
Questionuser's current wallpaper Pin
likefood25-Jul-07 4:28
likefood25-Jul-07 4:28 
AnswerRe: user's current wallpaper Pin
ashukasama25-Jul-07 4:53
ashukasama25-Jul-07 4:53 
Microsoft.Win32 is used for accessing the registry, while System.Runtime.InteropServices is used for accessing the unmanaged user32.dll.

Next comes the preparation of the unmanaged function SystemParametersInfo() - this should be located at the top of theSmile | :) class definition:


[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
<br />
static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);


First thing is to retrieve the current desktop wallpaper, and to do that we don't need to use a function, but simply read a value in the Windows registry. Let's create the method for that:


private string GetCurrentWallpaper()<br />
<br />
{<br />
<br />
    // The current wallpaper path is stored in the registry at HKEY_CURRENT_USER\\Control Panel\\Desktop\\WallPaper<br />
<br />
    RegistryKey rkWallPaper = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", false);<br />
<br />
    string WallpaperPath = rkWallPaper.GetValue("WallPaper").ToString();<br />
<br />
    rkWallPaper.Close();<br />
<br />
    // Return the current wallpaper path<br />
<br />
    return WallpaperPath;<br />
<br />
}


Next comes the definition of the method that actually sets the wallpaper, Additional for you . And it's only a few lines of code:


private void SetWallpaper(string WallpaperLocation, int WallpaperStyle, int TileWallpaper)

{

// Sets the actual wallpaper

SystemParametersInfo(20, 0, WallpaperLocation, 0x01 | 0x02);

// Set the wallpaper style to streched (can be changed to tile, center, maintain aspect ratio, etc.

RegistryKey rkWallPaper = Registry.CurrentUser.OpenSubKey("Control Panel\\Desktop", true);

// Sets the wallpaper style

rkWallPaper.SetValue("WallpaperStyle", WallpaperStyle);

// Whether or not this wallpaper will be displayed as a tile

rkWallPaper.SetValue("TileWallpaper", TileWallpaper);

rkWallPaper.Close();

}

Smile | :)
GeneralRe: user's current wallpaper Pin
likefood25-Jul-07 5:01
likefood25-Jul-07 5:01 
QuestionHow to make setup & deploy a Pocket Pc application Pin
Raza Hussain25-Jul-07 4:19
Raza Hussain25-Jul-07 4:19 
AnswerRe: How to make setup & deploy a Pocket Pc application Pin
Jalpesh B. Patel25-Jul-07 4:21
Jalpesh B. Patel25-Jul-07 4:21 
AnswerRe: How to make setup & deploy a Pocket Pc application Pin
Jalpesh B. Patel25-Jul-07 4:25
Jalpesh B. Patel25-Jul-07 4:25 
GeneralRe: How to make setup & deploy a Pocket Pc application Pin
Raza Hussain26-Jul-07 2:00
Raza Hussain26-Jul-07 2:00 
Questionplaying video files? Pin
Tarun.Suneja25-Jul-07 4:07
Tarun.Suneja25-Jul-07 4:07 
AnswerRe: playing video files? Pin
ashukasama25-Jul-07 4:21
ashukasama25-Jul-07 4:21 
GeneralRe: playing video files? Pin
Tarun.Suneja25-Jul-07 4:37
Tarun.Suneja25-Jul-07 4:37 
GeneralRe: playing video files? Pin
ekynox25-Jul-07 4:50
ekynox25-Jul-07 4:50 
QuestionSynchronizing Mulithreaded Loops Pin
Salamandras25-Jul-07 4:05
Salamandras25-Jul-07 4:05 
AnswerRe: Synchronizing Mulithreaded Loops Pin
PhilDanger25-Jul-07 4:37
PhilDanger25-Jul-07 4:37 
AnswerRe: Synchronizing Mulithreaded Loops Pin
pbraun25-Jul-07 12:48
pbraun25-Jul-07 12:48 
QuestionTab Controls...How can I select a Tab with a keyboard press? plz help Pin
flyingnome25-Jul-07 4:03
flyingnome25-Jul-07 4:03 
Answer[Message Deleted] Pin
flyingnome25-Jul-07 6:53
flyingnome25-Jul-07 6:53 
GeneralRe: Tab Controls...How can I select a Tab with a keyboard press? plz help Pin
Dave Kreskowiak25-Jul-07 7:22
mveDave Kreskowiak25-Jul-07 7:22 
GeneralRe: Tab Controls...How can I select a Tab with a keyboard press? plz help Pin
Paul Conrad25-Jul-07 7:40
professionalPaul Conrad25-Jul-07 7:40 
GeneralRe: Tab Controls...How can I select a Tab with a keyboard press? plz help [modified] Pin
flyingnome25-Jul-07 8:16
flyingnome25-Jul-07 8:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.