Imports System.Drawing
Imports System.Windows.Forms
Imports System.Drawing.Imaging
Public Class Form1
Private Declare Function SetParam Lib "user32" Alias "SystemParametersInfoA" _
(Optional ByVal uAction As Integer = 20, Optional ByVal uParam As Integer = 0, Optional ByVal lpvParam As String = "", _
Optional ByVal fuWinIni As Integer = &H1) As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim V_Day As Integer
V_Day = Date.Now.DayOfWeek
'MsgBox(V_Day)
SetWallPaper(V_Day & ".jpg", WallpaperStyle.延展)
Me.Close()
End Sub
Public Sub SetWallPaper(ByVal V_file_name As String, Optional ByVal Style As WallpaperStyle = WallpaperStyle.延展)
'Dim ic As New Bitmap(Path)
'ic.Save(Application.StartupPath & "\" & V_file_name, Drawing.Imaging.ImageFormat.Bmp)
'ic.Dispose()
Dim DesktopKey As Microsoft.Win32.RegistryKey = My.Computer.Registry.CurrentUser. _
OpenSubKey("Control Panel", True). _
OpenSubKey("Desktop", True)
'DesktopKey.SetValue("ConvertedWallpaper", Path, Microsoft.Win32.RegistryValueKind.String)
DesktopKey.SetValue("OriginalWallpaper", Application.StartupPath & "\" & V_file_name, Microsoft.Win32.RegistryValueKind.String)
DesktopKey.SetValue("Wallpaper", Application.StartupPath & "\" & V_file_name, Microsoft.Win32.RegistryValueKind.String)
If Style = WallpaperStyle.並排 Then
DesktopKey.SetValue("WallpaperStyle", 0, Microsoft.Win32.RegistryValueKind.String)
DesktopKey.SetValue("TileWallpaper", 1, Microsoft.Win32.RegistryValueKind.String)
ElseIf Style = WallpaperStyle.居中 Then
DesktopKey.SetValue("WallpaperStyle", 0, Microsoft.Win32.RegistryValueKind.String)
DesktopKey.SetValue("TileWallpaper", 0, Microsoft.Win32.RegistryValueKind.String)
ElseIf Style = WallpaperStyle.延展 Then
DesktopKey.SetValue("WallpaperStyle", 2, Microsoft.Win32.RegistryValueKind.String)
DesktopKey.SetValue("TileWallpaper", 0, Microsoft.Win32.RegistryValueKind.String)
End If
'My.Computer.FileSystem.GetFileInfo(Path).LastWriteTime = Now
SetParam(20, 0, Application.StartupPath & "\" & V_file_name)
End Sub
Public Enum WallpaperStyle
居中 = 0
並排 = 1
延展 = 2
End Enum
End Class
沒有留言:
張貼留言