News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Talking to the desktop

Started by Jimg, April 11, 2008, 05:34:27 PM

Previous topic - Next topic

Jimg

Quote from: sinsi on April 12, 2008, 10:18:43 PM
Looking at FFlags, is it the FOLDERFLAGS enum?
It sure looks like it.

MichaelW

All I had to do to make my test code work under Windows 98 SE (and presumably also under 98 FE and 95) is change the environment variable from USERPROFILE to WINDIR.

At least for 95, this functionality appears to be dependent on the version of IE installed:

http://support.microsoft.com/kb/190355
eschew obfuscation

sinsi

You can also use EnumWindows and minimize each window
Light travels faster than sound, that's why some people seem bright until you hear them.

Jimg

All of these are good solutions, however, what is the drawback of four simple invokes to keybd_event to send the windows-M command?  I'm all for simplicity unless there is some reason not to.

Jimg

And, of course, all this is just one giant kludge because I can't find any other way to set the Desktop-Changed flag so it will save it's new positions when the computer is shut down or rebooted.  I'm sure there's a simple message to send to FolderView or Progman to set it, it's just not documented anywhere I can think to look.

sinsi

To manually save positions, click the desktop and hit F5. When I did this (after deleting the ItemPos... value) it was recreated straight away.
I don't know how to do this in code though.
Light travels faster than sound, that's why some people seem bright until you hear them.

sinsi

I found MinimizeAll and UndoMinimizeAll in my copy of shell32.dll (XPSP2), but the PSDK says supported (even on 95) via shell32.dll version 4.71+

MinimizeAll:

    include \masm32\include\masm32rt.inc
    .data
    x1 db 'Shell_TrayWnd',0
    .code
start:
    invoke FindWindow,offset x1,0
    test eax,eax
    jz done
    invoke PostMessage,eax,WM_COMMAND,19fh,0
done:
    exit
end start


UndoMinimizeAll:

    include \masm32\include\masm32rt.inc
    .data
    x1 db 'Shell_TrayWnd',0
    .code
start:
    invoke FindWindow,offset x1,0
    test eax,eax
    jz done
    invoke PostMessage,eax,WM_COMMAND,1a0h,0
done:
    exit
end start

Light travels faster than sound, that's why some people seem bright until you hear them.

Jimg

Quote from: sinsi on April 14, 2008, 08:38:25 AM
To manually save positions, click the desktop and hit F5. When I did this (after deleting the ItemPos... value) it was recreated straight away.
I don't know how to do this in code though.
I know how to do it in code (with keybd_event), now all I need is to find the correct key to delete for the current resolution.

Jimg

Quote from: sinsi on April 14, 2008, 11:53:58 AM
I found MinimizeAll and UndoMinimizeAll in my copy of shell32.dll (XPSP2), but the PSDK says supported (even on 95) via shell32.dll version 4.71+
What tool did you use to find this, I have been looking for many hours with no success.  I can see them with ResHacker in the typelib, but that didn't really help me.
Quote

    invoke PostMessage,eax,WM_COMMAND,19fh,0
    invoke PostMessage,eax,WM_COMMAND,1a0h,0

How did you find out these message numbers?  They aren't in the menu items.

sinsi

That code is basically the code from shell32.dll, found with IDA
Light travels faster than sound, that's why some people seem bright until you hear them.

Jimg

Well, it certainly works better then using keybd_event, but I sure wish I could find some hard documentation on it before including it.  Blindly including code with a hardcoded message number is what bit me before.  Now I iterate through the menus of the shell32 to find Auto Arrange so even if the number changes again, I should at least have a fighting chance.   These aren't menu commands as far as I can tell.  You wouldn't know how to iterate through to find these two, would you?

In this link http://msdn2.microsoft.com/en-us/library/bb774083.aspx Microsoft shows how to do it in three different languages, none of which helps me at all with Masm.

sinsi

That was the link that made me think there was a function in shell32.dll to minimize all - the code is from IShellDispatch::MinimizeAll, not an exported function  :(
I tested it on NT4 SP6, 2000 SP4 and XP SP2 with no worries.
Light travels faster than sound, that's why some people seem bright until you hear them.

jj2007

See this link:

(Bond) used Resource Hacker on explorer.exe and found it to be 415, though they BOTH seem to work.
Code:

MENUITEM "&Adjust Date/Time", 408
MENUITEM "Ca&scade Windows", 403
MENUITEM "Tile Windows &Horizontally", 404
MENUITEM "Tile Windows V&ertically", 405
MENUITEM SEPARATOR
MENUITEM "&Minimize All Windows", 415
MENUITEM "&Undo", 416
MENUITEM SEPARATOR
MENUITEM "Tas&k Manager...", 420
MENUITEM SEPARATOR
MENUITEM "P&roperties", 413


Finally, if there is a MASM equivalent to this code, let me know - I am willing to learn  :wink

FUNCTION  IShellDispatch_MinimizeAll ( _
  BYVAL pthis AS DWORD PTR _
  ) AS LONG

  LOCAL HRESULT AS LONG
  CALL DWORD @@pthis[14] USING IShellDispatch_MinimizeAll (pthis) TO HRESULT
  FUNCTION = HRESULT

END FUNCTION