Results 1 to 6 of 6

Thread: RefreshDeskTop

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Kalpetta,Wayanad,Kerala,india
    Posts
    25

    Smile RefreshDeskTop

    Let me give you an Exe that can refresh desktop
    if you are happy with this exe ,I may send you the code also
    Attached Files Attached Files

  2. #2
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

  3. #3
    Junior Member
    Join Date
    May 2001
    Location
    Damascus - Syria
    Posts
    16

    Exclamation Re: RefreshDeskTop


    and how can we be soo sure it's safe? not a trojan or something? u wanna help provide the code

    Originally posted by brijmohank
    Let me give you an Exe that can refresh desktop
    if you are happy with this exe ,I may send you the code also
    -/-

  4. #4

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Kalpetta,Wayanad,Kerala,india
    Posts
    25

    Wink refreshdesktop

    Don't worry
    here 's the code
    try it
    this code is useful if you are trying to change desktop wallpaper
    That is ,if "Show Web Content " is enabled for active desktop you should refresh desktop in order to change the wallpaper.
    By using the API systemparameter info and using this code you can change the wallpaper with very ease.There are somany codes to refresh the desktop in this forums.but they only redraw the desktop icons .
    They can't really refresh the desktop. please use this and tell me any modifications required etc, thankyou

    Private Type POINTAPI
    x As Long
    y As Long
    End Type
    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
    Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
    Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Private Declare Function FindWindow Lib "user32" _
    Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
    lpWindowName As String) As Long

    Private Declare Function PostMessage Lib "user32" _
    Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As _
    Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    Private Const WM_COMMAND As Long = &H111
    Private Const MIN_ALL As Long = 419
    Private Const MIN_ALL_UNDO As Long = 416
    Const SW_SHOWNORMAL = 1
    Const VK_F5 = &H74
    Const KEYEVENTF_KEYUP = &H2
    Const MOUSEEVENTF_LEFTDOWN = &H2
    Const MOUSEEVENTF_LEFTUP = &H4
    Dim a As Integer, b As Integer
    Dim cname As String
    Dim cp As POINTAPI
    Dim rval As Long

    Private Sub Form_Load()
    rval = GetCursorPos(cp)
    If a = 0 Then a = cp.x
    If b = 0 Then b = cp.y
    SetCursorPos 5, 5
    Me.Hide
    Timer1.Enabled = True
    Timer1.Interval = 10
    End Sub
    Public Sub refreshdesktop()
    mouse_event &H2, 0, 0, 0, 0
    mouse_event &H4, 0, 0, 0, 0
    keybd_event &H74, 0, 0, 0
    keybd_event &H74, 0, KEYEVENTF_KEYUP, 0
    Restore
    SetCursorPos a, b
    Unload Me
    End
    End Sub
    Private Sub Timer1_Timer()
    Dim hwnd As Long
    Dim name As String
    rval = GetCursorPos(cp)
    hwnd = WindowFromPoint(cp.x, cp.y)
    cname = Space(128)
    rval = GetClassName(hwnd, cname, 128)
    Form1.Caption = Left(cname, InStr(cname, Chr(0)) - 1)
    name = Left(cname, InStr(cname, Chr(0)) - 1)
    Minimize
    If name = "Internet Explorer_Server" Then refreshdesktop
    If name = "SysListView32" Then refreshdesktop
    End Sub
    Private Sub Minimize()
    Dim r As Long
    r = FindWindow("Shell_TrayWnd", vbNullString)
    Call PostMessage(r, WM_COMMAND, MIN_ALL, 0&)
    End Sub

    Private Sub Restore()
    Dim r As Long
    r = FindWindow("Shell_TrayWnd", vbNullString)
    Call PostMessage(r, WM_COMMAND, MIN_ALL_UNDO, 0&)
    End Sub
    Attached Files Attached Files

  5. #5
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530
    Perhaps this is more efficient, I got this on this forum but don't remember source.

    Code:
    Public Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long) As Long
    Public Const SPI_SCREENSAVERRUNNING = 97
    Public Const SPI_SETDESKWALLPAPER = 20
    Public Const SPIF_SENDWININICHANGE = &H2
    Public Const SPIF_UPDATEINIFILE = &H1
      Call SystemParametersInfo(SPI_SETDESKWALLPAPER, True, "C:\Test.bmp", SPIF_UPDATEINIFILE Or SPIF_SENDWININICHANGE)

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Nov 2000
    Location
    Kalpetta,Wayanad,Kerala,india
    Posts
    25

    Talking Hai Nucleus

    To change the wallpaper you can use the code you 've given
    But ,if "show web content" ,(that is when you right click
    on the desktop)is enabled .the desktop should be refreshed
    to so that new wallpaper is displayed.
    so the code which i've given should be used after you use
    your code.then only new wallpaper will be displayed otherwise you
    should restart your computer.
    let me make it clear again
    1.my code is not used to change wallpaper it will only
    refresh desktop
    2. It should be used after you call 'systemparameter info'

    thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width