August 25, 2001

Play with OS:Hide Cursor, Change Wallpaper, Start ScrnSaver, Del Recycle Bin

Hide Mouse Cursor

You can use the API function Showcursor to control the visibility of the mouse cursor. The Parameter lShow show be set to True (non-zero) to display the cursor, False to hide it.

Public Declare Function ShowCursor& Lib "user32" (ByVal lShow As Long)

Changing The Wallpaper


SetWallpaper () where filename is the full path to your .BMP file.

Public Const SPIF_UPDATEINIFILE = &H1
Public Const SPI_SETDESKWALLPAPER = 20
Public Const SPIF_SENDWININICHANGE = &H2

Private Declare Function SystemParametersInfo Lib "User32" Alias "SystemParametersInfoA" _
(ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As String, _
ByVal fuWinIni As Long) As Long

Public Sub SetWallpaper(ByVal pFileName As String)
Dim Ret as long
Ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0&, pFileName, _
SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)
End Sub



Start A Screen Saver

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long

Private Const WM_SYSCOMMAND = &H112&
Private Const SC_SCREENSAVE = &HF140&

Private Sub Command1_Click()
Dim Ret As Long
Ret = SendMessage(Form1.hWnd, WM_SYSCOMMAND, SC_SCREENSAVE, 0&)
End Sub

Delete to Recycle Bin

Private Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Long
hNameMappings As Long
lpszProgressTitle As Long
End Type

Private Declare Function SHFileOperation Lib "shell32.dll" Alias _
"SHFileOperationA" (lpFileOp As SHFILEOPSTRUCT) As Long
Private Const FO_DELETE = &H3
Private Const FOF_ALLOWUNDO = &H40
Private Const FOF_NOCONFIRMATION = &H10
Private Const FOF_SLIENT = &H4

Private Sub DeleteFileToRecycleBin(ByVal Filename As String)
Dim op As SHFILEOPSTRUCT
Dim Ret As Long

With op
.wFunc = FO_DELETE
.pFrom = Filename
.fFlags = FOF_ALLOWUNDO
End With

Ret = SHFileOperation(op)
End Sub