[ create a new paste ] login | about

Link: http://codepad.org/QNVGlGXC    [ raw code | fork ]

hurracane - C, pasted on Jan 7:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using System.Threading;
using System.Runtime.InteropServices;

namespace ConsoleApplication1
{
    public class WinAPI
    {
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);
    }
    class Program
    {
        static void Main(string[] args)
        {
            for (int timer = 3; timer > 0; timer--)
            {
                Console.Out.Write(timer + "\n");
                System.Threading.Thread.Sleep(1000);
            }
            string showpath = "";
            string[] allfiles = Directory.GetFiles(@"C:\Documents and Settings\Sam\Mijn documenten\Mijn afbeeldingen\wallpaper");
            string fullpath = @"C:\Documents and Settings\Sam\Mijn documenten\Mijn afbeeldingen\wallpaper\currentwallpaper.bmp";
            if (fullpath != null)
            {
                File.Delete(fullpath);
                Console.Out.WriteLine("Deleted the already existing wallpaper Bitmap file\n");
                System.Threading.Thread.Sleep(1000);
            }
            while(true)
            {
                Random rand = new Random();
                string rand_wallpaper = ""; 
                rand_wallpaper = allfiles[rand.Next(allfiles.Length)];
                if (showpath != null && showpath != "")
                    Console.Out.Write(rand_wallpaper + "\n");
                if (rand_wallpaper.EndsWith(".jpg") || rand_wallpaper.EndsWith(".png"))
                {
                    Console.Out.WriteLine("Building current Wallpaper, Converting to .Bmp\n");
                    System.Drawing.Image converted_wpaper = System.Drawing.Image.FromFile(@rand_wallpaper);
                    System.Threading.Thread.Sleep(1500);
                    string path = rand_wallpaper.Substring(0, rand_wallpaper.LastIndexOf("\\")) + "\\";
                    converted_wpaper.Save(@path + "currentwallpaper.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
                    System.Threading.Thread.Sleep(500);
                    WinAPI.SystemParametersInfo(20, 0, path + "currentwallpaper.bmp", 0x1 | 0x2);
                    System.Threading.Thread.Sleep(1000);
                    Environment.Exit(0);
                }
                else if (rand_wallpaper.EndsWith(".bmp"))
                {
                    System.Threading.Thread.Sleep(500);
                    WinAPI.SystemParametersInfo(20, 0, rand_wallpaper, 0x1 | 0x2);
                }
                else
                {
                    Console.Out.Write("File is not a .jpg or .png. Picking another file\n");
                    showpath = "doitfaggot";
                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
    }
}


Create a new paste based on this one


Comments: