The MASM Forum

Microsoft 64 bit MASM => Examples => Topic started by: hutch-- on May 28, 2017, 12:31:01 PM

Title: MASM 64 Desktop mini app.
Post by: hutch-- on May 28, 2017, 12:31:01 PM
The attached zip file contains a small working app that functions as a simple desktop that has programmable menus that can be set in a plain text file. I have used this app as a test piece to develop the 64 bit version of the programmable menus that I use in my editors and it seems to be working well at the moment. It splits the calling of programs between the old but well behaved "WinExec()" and the newer but limited "ShellExecute()". WinExec handles command lines for exe/bat files with no problems where "ShellExecute()" will run non executable files. It supports HLP, CHM and PDF extensions.

The 9k icon blew the size out to 21k but I doubt it will break any hard disks in terms of storage space.  :P

Tested only on Win10 64 but it should run on Win7/8 64 as well.

 :biggrin: One day I will make a post with no typos.  :P
Title: Re: MASM 64 Desktop mini app.
Post by: caballero on May 28, 2017, 04:56:24 PM
Hello. Works well on W7 64 bit. It creates a window without frames with WS_VISIBLE+WS_POPUP and paints the desktop with PaintDesktop and the WinExec for the menu entries.
Title: Re: MASM 64 Desktop mini app.
Post by: Raistlin on May 31, 2017, 03:19:00 PM
Just a quick question / clarification needed. The explanation on technet/ms seems to be implicit, that
the execution of the called application context is independent of caller. The caller has no further control
over the initiated target except the ability to have exit codes passed. RE: Shellexecute(). The thread choice
in which the application context executes is controlled by the OS and cannot be manipulated by the caller
re: Processor Affinity. However it would theoretically be possible to shift the run-time priority of the application

 Is this assumption correct ?
Title: Re: MASM 64 Desktop mini app.
Post by: TWell on May 31, 2017, 05:34:13 PM
In ShellExecuteEx() it is possible get hProcess with mask SEE_MASK_NOCLOSEPROCESS and then use SetProcessAffinityMask().
Title: Re: MASM 64 Desktop mini app.
Post by: Raistlin on June 02, 2017, 03:43:29 PM
Code: [Select]
Use to indicate that the hProcess member receives the process handle. This handle is typically used to allow an application to find out when a process created with ShellExecuteEx
terminates. In some cases, such as when execution is satisfied through a DDE conversation, no handle will be returned. The calling application is responsible for closing the handle
when it is no longer needed
Code: [Select]
typedef struct _SHELLEXECUTEINFO {
  DWORD     cbSize;
  ULONG     fMask;
  HWND      hwnd;
  LPCTSTR   lpVerb;
  LPCTSTR   lpFile;
  LPCTSTR   lpParameters;
  LPCTSTR   lpDirectory;
  int       nShow;
  LPVOID    lpIDList;
  LPCTSTR   lpClass;
  HKEY      hkeyClass;
  DWORD     dwHotKey;
  union {
    HANDLE hIcon;
    HANDLE hMonitor;
 HANDLE    hProcess;

Code: [Select]
(Note: ShellExecuteEx runs on a background thread by default if the caller's threading model is not Apartment.)