News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Physical disk activity monitor

Started by KSS, January 10, 2024, 03:12:35 PM

Previous topic - Next topic

KSS

Physical disk activity monitor show icon in system tray for all in/out operation for all disks in system with three states: no active, min active, active.
Can run/show! taskmgr.exe, run current screen saver (with predefined hot key) and run config screen saver standart Windows dialog.
As based source/idea used hdactmon1.zip from this old masm32 forum. Download: You cannot view this attachment.

I used this program when coming to clients (many years ago when HDD was slow-w-w...) and want view HDD activity (virus, swaping, background program used disk, etc) and now when connect remote to clients.

Program may be more perfect, but I am just (re)wrote that places where need use less CPU and add function that I need.
I think this program may be useful not only for support clients, but and in home environment too.

About program work/code:
• Restore TaskMgr window by click/dblClick (not as %badword% Explorer - just run every time TaskMgr [read from disk, run, find own old copy, restore window — long time as for me :mrgreen: ]), or run TaskMgr (if not running), on 64-bit system run 64-bit version! My program 32bit :cool:
• Run screen saver by Ctrl+Alt+Shift+* — that just for me (Explorer always forget about hot kay in LNK file on desktop, after windows forks few days. This was on all Windows XP/7/10, but not on the server edition!)
• Open standart config dialog for screen saver (only 32-bit version, not used often - no time to rewrite procedure :toothy: )
• Program used ANSI (where we run code only one time) and Unicode (for less CPU usage) version WinAPI.
• Added more error handling and other way to get PerfCounters (not worked on some computers)

Update: (2024-02-25)
• Update to latest Masm32 SDK (thanks jj2007)
• Added MANIFEST
• Check for application already running (shared section :cool: )
• Now use Shell_NotifyIconW
• Remove icon from popup menu: not work with Win10 manifest (only 2000/XP)
• Use "my own" struct MENUITEMINFO


Download: You cannot view this attachment.

Comments and ideas welcome! :icon_idea:

P.S. sorry for my English - haven't talked for a long time.


jj2007

Hi Digger,

Well done :thumbsup:

Minor corrections:
- line 7:     include \masm32\macros\ucmacros.asm
- line 399ff:
SetMenuIcon PROC
LOCAL mii:MENUITEMINFO ;tagMENUITEMINFOW
; Need zero memory? pfff�E
MOV mii.cbSize,sizeof(MENUITEMINFO)
MOV mii.fMask,MIIM_BITMAP
MOV mii.fType,MFT_BITMAP
; no such struct member: MOV mii.hbmpItem,HBMMENU_POPUP_CLOSE
invoke  SetMenuItemInfoW,hPopupMenu,IDM_EXIT,0,ADDR mii
 RET
SetMenuIcon ENDP

Are you sure you have the latest Masm32 SDK?

NoCforMe

Quote from: jj2007 on January 10, 2024, 09:12:49 PM; no such struct member: MOV mii.hbmpItem,HBMMENU_POPUP_CLOSE
Actually, yes, there is such a struct member:

typedef struct tagMENUITEMINFOA {
  UINT      cbSize;
  UINT      fMask;
  UINT      fType;
  UINT      fState;
  UINT      wID;
  HMENU    hSubMenu;
  HBITMAP  hbmpChecked;
  HBITMAP  hbmpUnchecked;
  ULONG_PTR dwItemData;
  LPSTR    dwTypeData;
  UINT      cch;
  HBITMAP  hbmpItem;
} MENUITEMINFOA, *LPMENUITEMINFOA;
(from learn.Microsoft.com)

but it's missing from (at least my copy of) windows.inc, though. I thought my MASM32 was pretty up-to-date.
Assembly language programming should be fun. That's why I do it.

TimoVJL

typedef struct tagMENUITEMINFOA
{
    UINT     cbSize;
    UINT     fMask;
    UINT     fType;         // used if MIIM_TYPE (4.0) or MIIM_FTYPE (>4.0)
    UINT     fState;        // used if MIIM_STATE
    UINT     wID;           // used if MIIM_ID
    HMENU    hSubMenu;      // used if MIIM_SUBMENU
    HBITMAP  hbmpChecked;   // used if MIIM_CHECKMARKS
    HBITMAP  hbmpUnchecked; // used if MIIM_CHECKMARKS
    ULONG_PTR dwItemData;   // used if MIIM_DATA
    __field_ecount_opt(cch) LPSTR    dwTypeData;    // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
    UINT     cch;           // used if MIIM_TYPE (4.0) or MIIM_STRING (>4.0)
#if(WINVER >= 0x0500)
    HBITMAP  hbmpItem;      // used if MIIM_BITMAP
#endif /* WINVER >= 0x0500 */
}   MENUITEMINFOA, FAR *LPMENUITEMINFOA;
May the source be with you

jj2007

Quote from: TimoVJL on January 11, 2024, 05:27:34 PM#if(WINVER >= 0x0500)
    HBITMAP  hbmpItem;      // used if MIIM_BITMAP

So that means that
a) Windows.inc is a bit outdated (rare, but it happens)
b) OP uses a modified Windows.inc, otherwise it would not assemble on his machine.

The latter is a recipe for disaster, as it makes your code incompatible with the rest of the World, pardon: of the Masm32 forum. The right thing to do in such cases is to use a modified MyMENUITEMINFO in source code that requires it.

NoCforMe

Regarding Timo's post, I find it interesting that the current Micro$oft documentation omits that conditional inclusion of the hbmpItem member. Apparently now we're supposed to assume** that WINVER >= 0x0500. (What is that anyhow, XP? Vista?)

** When you ASSUME you make an ASS out of U and ME ...

And yes, that's just another example of how ridiculously behind the times our windows.inc is. I'll be having more to say on that subject here soon ...
Assembly language programming should be fun. That's why I do it.

TimoVJL

//
// _WIN32_WINNT version constants
//
#define _WIN32_WINNT_NT4                    0x0400 // Windows NT 4.0
#define _WIN32_WINNT_WIN2K                  0x0500 // Windows 2000
#define _WIN32_WINNT_WINXP                  0x0501 // Windows XP
#define _WIN32_WINNT_WS03                   0x0502 // Windows Server 2003
#define _WIN32_WINNT_WIN6                   0x0600 // Windows Vista
#define _WIN32_WINNT_VISTA                  0x0600 // Windows Vista
#define _WIN32_WINNT_WS08                   0x0600 // Windows Server 2008
#define _WIN32_WINNT_LONGHORN               0x0600 // Windows Vista
#define _WIN32_WINNT_WIN7                   0x0601 // Windows 7
#define _WIN32_WINNT_WIN8                   0x0602 // Windows 8
#define _WIN32_WINNT_WINBLUE                0x0603 // Windows 8.1
#define _WIN32_WINNT_WINTHRESHOLD           0x0A00 // Windows 10
#define _WIN32_WINNT_WIN10                  0x0A00 // Windows 10
//
May the source be with you

KSS

Thanks to all for comments!

Updated first post in topic.

P.S. I am digged about using MANIFEST in app and what "we have" in result. Short answer: always use manifest!

fearless

I use SetMenuItemBitmap instead to set bitmaps in the menu:

https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setmenuitembitmaps

It should work for win2k+

Example:

Invoke AppendMenu, hESMenu, MF_STRING, IDM_ES_SEARCH_CODE, Addr szES_SEARCH_CODE
Invoke LoadBitmap, hInstance, BMP_FILTER_SEARCH_CODE
mov hBitmap, eax
Invoke SetMenuItemBitmaps, hTVLRCMenu, IDM_ES_SEARCH_CODE, MF_BYCOMMAND, hBitmap, 0

KSS

#9
Quote from: fearless on February 26, 2024, 01:38:14 AMIt should work for win2k+
From my code:
SetMenuIcon PROC
; NOTE: not work with Win10 manifest :(
LOCAL mii:MENUITEMINFO5
    invoke RtlZeroMemory,ADDR mii,sizeof(MENUITEMINFO)
    MOV mii.cbSize,sizeof(MENUITEMINFO)
    MOV mii.fMask,MIIM_BITMAP
    MOV mii.fType,MFT_BITMAP
    MOV mii.hbmpItem,HBMMENU_POPUP_CLOSE
    invoke  SetMenuItemInfoW,hPopupMenu,IDM_EXIT,0,ADDR mii
 RET
SetMenuIcon ENDP
Need use system icon HBMMENU_POPUP_CLOSE, work only on Win2k/XP  :angelic:

I will try use:
invoke LoadBitmap, 0, OBM_OLD_CLOSE
May by it work... Thanks for idea  :icon_idea:

UPD:
Mybad  :hmmm:
LOCAL mii:MENUITEMINFO5
MOV mii.cbSize,sizeof(MENUITEMINFO :toothy: )

Now all work  :eusa_boohoo:

greenozon

Quote from: TimoVJL on January 12, 2024, 05:44:27 PM#define _WIN32_WINNT_WIN10                  0x0A00 // Windows 10


how about Windows 11?