:eek: could someone do me a favor and write -and then post it here- the (MASM) code for a program which, when executed, refreshes the Windows Desktop (in particular active desktop elements need refreshing)?

thanks!
Posted on 2003-02-22 03:55:54 by LazyCoder



push 0FFFFh ; TRUE
push 0 ; whole region
push 0 ; desktop handle
call [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_4c32.asp]InvalidateRgn[/url]

push 0 ; desktop handle
call [url=http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/pantdraw_4zef.asp]UpdateWindow[/url]



MASM32




.386
.model flat,stdcall
option casempa: none

include windows.inc
include kernel32.inc
include user32.inc

includelib kernel32.lib
includelib user32.lib

.code
start:
invoke InvalidateRgn, NULL, NULL, TRUE
invoke UpdateWindow, NULL

xor eax,eax
invoke ExitProcess, eax
end start

Posted on 2003-02-22 04:58:31 by Hiroshimator
thanks, only problem: it doesn't refresh the desktop-- neither with ActiveDesktop disabled or enabled

(and it's casemap for anyone else)


I'd need the F5 (update) command for the desktop - only thing: I don't know enough about Win32asm in order to know how to achieve that.
(the ActiveDesktop->UpdateNow command doesn't work)
Posted on 2003-02-22 05:22:03 by LazyCoder

Try using the handle returned by GetDesktopHandle, instead of 0.
Posted on 2003-02-22 05:25:47 by Maverick
and how do i do that?
Posted on 2003-02-22 05:32:40 by LazyCoder


The GetDesktopWindow function returns the handle of the Windows desktop window.
The desktop window covers the entire screen. The desktop window is the area on top
of which all icons and other windows are painted.

HWND GetDesktopWindow(VOID)


Parameters

This function has no parameters.

Return Values

The return value is the handle of the desktop window.
Use the above function
to retrieve a DWORD value that you will PUSH instead of the 0 in the PUSH immediately
above the two function calls that Hiroshimator showed you on the first code.

In plain Japanese:


push 0FFFFh ; TRUE
push 0 ; whole region
push 0 ; desktop handle
call InvalidateRgn

push 0 ; desktop handle
call UpdateWindow

turns into:


call GetDesktopWindow
mov ebx,eax ; save handle

push 0FFFFh ; TRUE
push 0 ; whole region
push eax ; desktop handle
call InvalidateRgn

push ebx ; desktop handle
call UpdateWindow

or a perhaps more elegant:


call GetDesktopWindow
push eax ; save handle

push 0FFFFh ; TRUE
push 0 ; whole region
push eax ; desktop handle
call InvalidateRgn

call UpdateWindow
Posted on 2003-02-22 05:45:16 by Maverick
Here we come back to my "use our search engine" complain...

http://www.asmcommunity.net/board/index.php?topic=5039&highlight=refresh+desktop
Posted on 2003-02-22 05:45:32 by bazik
sorry Maverick, but it still doesn't work;


and I really don't know much about Win32 programming either: Has the problem been solved in that other post?

doesn't seem so?


it might just be the same command (with an appropriate parameter) as the command used to update explorer after file operations, as WinZip for example does after creating a Zip file.


any other help?


thanks all
Posted on 2003-02-22 06:03:00 by LazyCoder

and I really don't know much about Win32 programming either: Has the problem been solved in that other post?


Yes.
SHChangeNotify is the same what Windows sends when you hit F5 when your desktop got the focus.
Posted on 2003-02-22 06:09:43 by bazik
so SHChangeNotify(SHCNE_ALLEVENTS, SHCNF_IDLIST, lpil, 0) will do it?



could you put that in MASM code for me ...?


thanks in advance
Posted on 2003-02-22 06:14:46 by LazyCoder
if he uses active desktop would trhat be another layer? I remeber that you could have a background on the real desktop and a background on the active one. maybe that's what happens here?
Posted on 2003-02-22 06:28:33 by Hiroshimator
<CTRL+D>
bpx SHChangeNotify
<CTRL+D>
*click on desktop*
<F5>

Didn't break!


aweX <-
Posted on 2003-02-22 07:24:44 by aweX

<CTRL+D>
bpx SHChangeNotify
<CTRL+D>
*click on desktop*
<F5>

Didn't break!


aweX <-



Yeah, I didnt remember correct about a system I didnt touch for ages ;)
Posted on 2003-02-22 07:39:17 by bazik
:stupid:


I don't really know what to make of that, so...

could you write that as a complete MASM program for me?


like


.586
.model flat,stdcall
option casemap: none

include C:\masm32\include\Windows.inc ;which are needed?
include C:\masm32\include\kernel32.inc
include C:\masm32\include\user32.inc

includelib C:\masm32\lib\kernel32.lib
includelib C:\masm32\lib\user32.lib


.code

start:

call SHChangeNotify ;how to do?

xor eax,eax
invoke ExitProcess, eax

end start
Posted on 2003-02-22 07:45:11 by LazyCoder
AnotherForumAnotherName,

Get the drift of this, this forum is not a code ordering facility and you tread on dangerous grounds treating it like that.

If you have a technical question, ask it but spare us the idea that someone should be writing your code for you. Try "rent a coder" if you have that mentality, keep it up here and you will receive the appropriate motivation to ask elsewhere.

Then you can change your nick to AnotherForumAnotherNameAgain.

Regards,

hutch@movsd.com
Posted on 2003-02-22 07:52:19 by hutch--
ah yes,


I thought if s.o. knows the answer, it might be a 1 liner (or 3 or 4)



regarding the function call reference: msdn yielded "0 results" when searching for these function names; can you recommend any place to look them up (I suspect I'll be able to make out their call syntax in MASm myself (partly I know, I currently just dont know how to "use" the constants in that function arguments)
Posted on 2003-02-22 07:59:08 by LazyCoder
Afternoon, LazyCoder.

Get the Platform SDK from Microsoft. It's far better to use that than searching MSDN over the Net.

If you want to learn how to use the Win32 API with assembly then go through the examples which are included within the Masm32 package and Iczelions' tutorials.

Cheers,
Scronty
Posted on 2003-02-22 17:18:10 by Scronty
:eek: :rolleyes: :tongue: :) :o

thaanky
Posted on 2003-02-22 22:22:48 by LazyCoder
Weird... it won't even work like this:

SendMessage(GetDesktopHandle(), WM_KEYDOWN, VK_F5, MapVirtualKey(VK_F5, 0) << 16);
Posted on 2003-02-23 00:38:17 by aweX
aweX, send a WM_KEYUP, too and it should work. (I guess :))

Has anyone tried:
invoke SendMessage, 0, WM_COMMAND, WM_REFRESH_DESKTOP, 0
...(edit) doesn't appear to do anything on WinXP.
Posted on 2003-02-23 00:49:00 by bitRAKE