SetDeskWallpaper

機能
デスクトップの壁紙を変更する
宣言文
Declare Function SetDeskWallpaper Lib "user32.dll" _
    (ByVal FileName As String) As Long
引数
FileName
壁紙に設定するbmpファイル
戻り値
正常終了のとき		0以外
失敗したとき		0
備考
壁紙の表示方法はこの関数では設定できない。
つまり並べて表示になっていれば、並べて表示されてしまう。

壁紙は基本的にビットマップファイルしか表示できない。
JpegやGIFを表示できるのは、Windowsがファイルが選択された時点で
ビットマップファイルに変換しているからである。
サンプル
ダウンロード(SetDeskWallpaper.lzh 1.55kB)
'デスクトップの壁紙を変更する
Private Declare Function SetDeskWallpaper Lib "user32.dll" _
    (ByVal FileName As String) As Long

Private Sub Command1_Click() '背景画像の設定 '(ただし、拡大なのか並べて表示なのか、中央に表示なのかは設定しだい) Call SetDeskWallpaper(Me.Text1.Text) End Sub
Private Sub Command2_Click() With Me.CommonDialog1 .Filter = "*.bmp|*.bmp|*.*|*.*" .ShowOpen If .FileName <> "" Then Me.Text1.Text = .FileName End If End With End Sub
Private Sub Command3_Click() Call SetDeskWallpaper("") End Sub
Private Sub Form_Load() Me.Command1.Enabled = False End Sub
Private Sub Text1_Change() If Me.Text1.Text <> "" Then Me.Command1.Enabled = True Me.Picture1.Picture = LoadPicture(Me.Text1.Text) Else Me.Command1.Enabled = False End If End Sub