The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: bomz on May 04, 2011, 08:21:43 PM

Title: TB_GETRECT
Post by: bomz on May 04, 2011, 08:21:43 PM
Quote
.386

.model flat, stdcall
option casemap :none

   include \masm32\include\windows.inc

   include \masm32\include\user32.inc
   include \masm32\include\kernel32.inc
   include \masm32\include\shell32.inc
   include \masm32\include\masm32.inc

   includelib \masm32\lib\user32.lib
   includelib \masm32\lib\kernel32.lib
   includelib \masm32\lib\shell32.lib
   includelib \masm32\lib\masm32.lib


EXTRADATA struct
        Wnd dd ?
        uID dd ?
EXTRADATA ends

.data
mestitle   db "RECT",0
form      db "ID process: %d", 9,"TOP: %d", 9,"LEFT: %d", 9,"BOTTOM: %d", 9,"RIGHT: %d",  0
Class1      db 'Shell_TrayWnd',0
Class2      db 'TrayNotifyWnd',0
Class3      db 'SysPager',0
Class4      db 'ToolbarWindow32',0

.data?
extra      EXTRADATA <>
button      TBBUTTON <>
rect1      RECT <>
rect      RECT <>
buffer      db 512 dup(?)
hWnd      HWND ?
ProcId      dd ?
hProcess   dd ?
lpData      dd ?
IconNumber   dd ?
BytesRead   dd ?
ProcTrayId   dd ?

.code
start:

   invoke FindWindow,addr Class1, NULL
   mov hWnd, eax
   invoke FindWindowEx,hWnd,NULL,addr Class2, NULL
   mov hWnd, eax
   invoke FindWindowEx,hWnd,NULL,addr Class3, NULL
   mov hWnd, eax
   invoke FindWindowEx,hWnd,NULL,addr Class4, NULL
   mov hWnd, eax
   invoke GetWindowRect, hWnd,addr rect
   invoke  SendMessage,hWnd,TB_BUTTONCOUNT,0,0
   mov IconNumber, eax
   invoke  GetWindowThreadProcessId,hWnd,addr ProcId
   invoke  OpenProcess,PROCESS_ALL_ACCESS,FALSE,ProcId
   mov hProcess,eax
   invoke  VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
         mov lpData, eax
NEXT:
;   dec IconNumber
   mov IconNumber, 0 ;Mozilla Firefox

   invoke  SendMessage,hWnd,TB_GETBUTTON,IconNumber,lpData
   invoke  ReadProcessMemory, hProcess, lpData,addr button, sizeof button, addr BytesRead
   invoke  ReadProcessMemory,hProcess,button.dwData,addr extra, sizeof extra,addr BytesRead
   invoke  GetWindowThreadProcessId, extra.Wnd,addr ProcTrayId

;   invoke  SendMessage,hWnd,TB_GETRECT, button.idCommand, addr rect1 ;(http://smiles.kolobok.us/standart/not_i.gif)FATAL SYSTEM CRASH

   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect1.top, rect1.left,  rect1.bottom, rect1.right
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK
   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect.top, rect.left, rect.bottom, rect.right
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK

;cmp IconNumber,0
;jnz NEXT
   invoke  VirtualFreeEx,ProcId,lpData,0,MEM_RELEASE
   invoke  CloseHandle,ProcId
   invoke ExitProcess,0

end start
Title: Re: TB_GETRECT
Post by: qWord on May 04, 2011, 08:52:54 PM
Quoteaddr rect1
:snooty:
Title: Re: TB_GETRECT
Post by: bomz on May 04, 2011, 08:55:08 PM
Quote
   invoke  VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
         mov lpData, eax   
   invoke  VirtualAllocEx,hProcess,NULL,sizeof rect1,MEM_COMMIT,PAGE_READWRITE
         mov lpData1, eax
   mov IconNumber, 0

   invoke  SendMessage,hWnd,TB_GETBUTTON,IconNumber,lpData
   invoke  ReadProcessMemory, hProcess, lpData,addr button, sizeof button, addr BytesRead
   invoke  ReadProcessMemory,hProcess,button.dwData,addr extra, sizeof extra,addr BytesRead
   invoke  GetWindowThreadProcessId, extra.Wnd,addr ProcTrayId

   invoke  SendMessage,hWnd,TB_GETRECT, button.idCommand, lpData1
   invoke  ReadProcessMemory, hProcess, lpData1,addr rect1, sizeof rect1, addr BytesRead


   mov eax, rect1.top
   inc eax
   add rect.top, eax
   mov eax, rect1.left
   inc eax
   add rect.left, eax
   mov eax, rect1.right
   dec eax
   add rect.right, eax
   mov eax, rect1.bottom
   dec eax
   add rect.bottom, eax


;   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect1.top, rect1.left,  rect1.bottom, rect1.right
;   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK
   invoke wsprintf,ADDR buffer,ADDR form, ProcTrayId, rect.top, rect.left, rect.bottom, rect.right
   invoke MessageBox,0,ADDR buffer,ADDR mestitle,MB_OK + MB_ICONASTERISK

May be so - no fatal error but I can't understand what I get
Title: Re: TB_GETRECT
Post by: qWord on May 04, 2011, 09:08:56 PM
Quote from: bomz on May 04, 2011, 08:55:08 PMMay be so - no fatal error but I can't understand what I get
so? What is your question?
Title: Re: TB_GETRECT
Post by: bomz on May 04, 2011, 09:19:36 PM
at first - is it right? second may I get tray icon position?
Title: Re: TB_GETRECT
Post by: baltoro on May 04, 2011, 09:26:53 PM
I have two suggestions:

Click on the Additional Option link just under the reply box to see how to attach a file (they must be zipped).
Title: Re: TB_GETRECT
Post by: bomz on May 04, 2011, 10:23:54 PM
find position of icon in system tray

(http://s39.radikal.ru/i083/1105/4d/518bf5e67430.png)
Title: Re: TB_GETRECT
Post by: baltoro on May 05, 2011, 12:11:42 AM
bomz,
Hi. I did a Google search. And, I found a number of things which you might find useful:
Why Do Some People Call the Taskbar the "Tray"? (http://blogs.msdn.com/b/oldnewthing/archive/2003/09/10/54831.aspx)
Should All Windows Appear in the Taskbar? (http://blogs.msdn.com/b/oldnewthing/archive/2007/01/17/1483974.aspx)
The Taskbar, MSDN (http://msdn.microsoft.com/en-us/library/cc144179(v=vs.85).aspx)
Notification Area MSDN (http://msdn.microsoft.com/en-us/library/aa511448.aspx)
Windows Shell MSDN (http://msdn.microsoft.com/en-us/library/bb773177(v=VS.85).aspx)
Also, here is an article for C++ programmers about the, Shell_NotifyIcon function: Basic Use of Shell_NotifyIcon in Win32 (http://www.codeproject.com/KB/shell/StealthDialog.aspx).
Here is the MSDN documentation for the: Shell_NotifyIcon Function (http://msdn.microsoft.com/en-us/library/bb762159(v=vs.85).aspx)
I hope this helps. I don't know anything about it, sorry,...but, I'm guessing that you are not approaching the problem in the correct way. I don't think calling FindWindowEx repeatedly with the "class names" listed in your code above is going to work.
Title: Re: TB_GETRECT
Post by: bomz on May 05, 2011, 12:48:05 AM
The problem in correct manipulate with explorer memory
Title: Re: TB_GETRECT
Post by: qWord on May 05, 2011, 12:54:50 AM
what is the purpose of knowing the icons postion? - what should be the result of all your efforts?
Title: Re: TB_GETRECT
Post by: bomz on May 05, 2011, 01:13:39 AM
balon popup apear from icon. see picture
Title: Re: TB_GETRECT
Post by: bomz on May 05, 2011, 09:57:28 AM
Is it possible free system memory application use. For example application use invoke GetOpenFileName, addr ofn, at this moment system add 3 mb of memory to application , after close GetOpenFileName this memory don't free
Title: Re: TB_GETRECT
Post by: baltoro on May 05, 2011, 03:58:12 PM
You seem to be a minimalist in terms of providing us with details about your application. This is why the forum members are reluctant to help you.
I have to suspect that maybe English is not your native language.
So,...the obvious questions are: to which application does this icon with the balloon belong ??? Is this an access problem ???
Also, which Windows version of the Operating System is installed on the computer that this application will run on ??? (I ask this because, the security characteristics of the various versions are different.) Do you understand this ???
ReadProcessMemory will fail for numerous reasons,...but, typically, it is an access denied error. And, I notice in the little code that posted above,...you don't even check the return value to see if the function actually succeeded. This makes no sense,...
Title: Re: TB_GETRECT
Post by: bomz on May 05, 2011, 04:13:40 PM
Quote from: baltoro on May 05, 2011, 03:58:12 PM
You seem to be a minimalist in terms of providing us with details about your application. This is why the forum members are reluctant to help you.
I have to suspect that maybe English is not your native language.
So,...the obvious questions are: to which application does this icon with the balloon belong ??? Is this an access problem ???
Also, which Windows version of the Operating System is installed on the computer that this application will run on ??? (I ask this because, the security characteristics of the various versions are different.) Do you understand this ???
ReadProcessMemory will fail for numerous reasons,...but, typically, it is an access denied error. And, I notice in the little code that posted above,...you don't even check the return value to see if the function actually succeeded. This makes no sense,...
My application 40 kb long - this code in post - test. In future this part of code I would use in all my application
No native - I try to limit by emotions. MASM for all nonative
Windows XP but this code must work Windows 7, lazy for verify - it's need to repack W7 from Acronis Archive.
No error for text limit
Title: Re: TB_GETRECT
Post by: baltoro on May 05, 2011, 04:15:54 PM
Well,...OK,...then,...that's that,...
Title: Re: TB_GETRECT
Post by: bomz on May 05, 2011, 04:23:22 PM
(http://i058.radikal.ru/1105/ba/ba8988401b14.gif)

I want this - but it was vary hard to do because system fatal crashes after each examination. and now I want be shure that all OK
Title: Re: TB_GETRECT
Post by: baltoro on May 05, 2011, 04:31:27 PM
YOU'RE RUSSIAN ! Why didn't you say so ???
We have a Russian-speaking programmer here on the Forum,...and, he is alot better at this than I am,...
Title: Re: TB_GETRECT
Post by: qWord on May 05, 2011, 04:39:28 PM
For assigning an ToolTip to the task bar, it's probably needed to to inject a DLL in Explorers process. For an general solution this also implies, that you must at least create two DLLs: 32Bit and 64Bit.
However, DLL injection is an topic, that's not allowed to discuss in this forum.
Title: Re: TB_GETRECT
Post by: dedndave on May 05, 2011, 04:42:10 PM
i think i can understand why he wants the icon position
the fact that he is Russian makes it hard for him to verbalize it, is all   :P
Title: Re: TB_GETRECT
Post by: baltoro on May 05, 2011, 04:50:23 PM
Thank God you guys showed up,...I'm afraid I've badly misled the guy,... :green
...And, to be perfectly honest,...I'm quite confused about the whole thing,...
Title: Re: TB_GETRECT
Post by: donkey on May 05, 2011, 07:28:46 PM
From what I understand you are just trying to get the rect for the icon. The function for that is Shell_NotifyIconGetRect (http://msdn.microsoft.com/en-us/library/dd378426%28v=vs.85%29.aspx). Win7 and above though.
Title: Re: TB_GETRECT
Post by: Tedd on May 05, 2011, 11:37:11 PM
You guys worry me ::)

Title: Re: TB_GETRECT
Post by: qWord on May 05, 2011, 11:53:38 PM
Tedd, he was talking about adding an ToolTip to the Icon of Mozilla Firefox (AFAIKS)
Title: Re: TB_GETRECT
Post by: baltoro on May 06, 2011, 12:21:57 AM
...Ya know,...I didn't quite get it either,...he has the phrase 'Mozilla Firefox' in his code, but, it doesn't make sense.
Also, one of his responses was:
Quote from: BOMZ...The problem in correct manipulate with explorer memory,...
which confused the hell out of me. I don't think he knew himself. But, he didn't approach the problem by calling Shell functions,...which is what I would have done,...instead, he calls FindWindowEx using a Hwnd that is probably Null,...hell, we don't even know that,...
...And, I didn't recognize the names he listed in his original code for the Window Class Names as registered system names,...
Class1      db 'Shell_TrayWnd',0
Class2      db 'TrayNotifyWnd',0
Class3      db 'SysPager',0
Class4      db 'ToolbarWindow32',0


I actually googled those phrases, and I found several forum references to them in various places,...but, one was a NET type, one was VB,..

BOMZ,...are you out there ???
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 12:27:16 AM
I am talking about - why error in this string, I don't say anything what I am doing. Mozilla I signed to show that this icon realy exist and it's not antivirus.

NEXT:
;   dec IconNumber
   mov IconNumber, 0 ;Mozilla Firefox

;cmp IconNumber,0
;jnz NEXT

I don't understand that memory must be double readed
Title: Re: TB_GETRECT
Post by: baltoro on May 06, 2011, 12:28:50 AM
But, you are referring to the Windows desktop and not Internet Explorer ???
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 12:30:57 AM
Yes. any IE
You see level of my English: "memory context" - this may be understood very different

System crashes, after 2 hour I hope for help
Title: Re: TB_GETRECT
Post by: baltoro on May 06, 2011, 12:36:59 AM
Yes,...I can see it is difficult for you. Well, thank God, you aren't trying to decipher my Russian,...because,...it would be alot worse.
So, my next question is: How can you be sure you have the correct Window handle for the running Internet Explorer instance ???
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 12:39:22 AM
as I understand you right - for My process (application) I do this by HWND, for IE need ID of process with name iexplorere.exe
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 12:41:45 AM
Quote
PopupProc   PROTO :DWORD,:DWORD

EXTRADATA struct
        Wnd dd ?
        uID dd ?
EXTRADATA ends
............................................................
Class1         db 'Shell_TrayWnd',0
Class2         db 'TrayNotifyWnd',0         ; область уведомлений
Class3         db 'SysPager',0
Class4         db 'ToolbarWindow32',0
TOOLTIPS_CLASS      db "tooltips_class32",0
...............................................

invoke PopupProc, MsgPopup, hWnd

...............................................

PopupProc proc   PopupText:DWORD, HWnD:HWND
LOCAL      rect:RECT
LOCAL      toolinfo:TOOLINFO
LOCAL      extra:EXTRADATA
LOCAL      button:TBBUTTON
LOCAL      rect1:RECT
LOCAL      ToolbarHandle:HWND
LOCAL      ProcId:DWORD
LOCAL      hProcess:DWORD
LOCAL      lpData:DWORD
LOCAL      lpData1:DWORD
LOCAL      IconNumber:DWORD
LOCAL      ProcTrayId:DWORD
LOCAL      ButtonID:DWORD

   invoke FindWindow,addr Class1, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke FindWindowEx,eax,NULL,addr Class2, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke FindWindowEx,eax,NULL,addr Class3, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke FindWindowEx,eax,NULL,addr Class4, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke  SendMessage,ToolbarHandle,TB_BUTTONCOUNT,0,0
   test eax, eax
   jz NoHandle
   mov IconNumber, eax
   invoke  GetWindowThreadProcessId,ToolbarHandle,addr ProcId
   test eax, eax
   jz NoHandle
   invoke  OpenProcess,PROCESS_ALL_ACCESS,FALSE,ProcId
   test eax, eax
   jz NoHandle
   mov hProcess,eax
   invoke  VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
   test eax, eax
   jz NoMemory
         mov lpData, eax
   invoke  VirtualAllocEx,hProcess,NULL,sizeof rect1,MEM_COMMIT,PAGE_READWRITE
   test eax, eax
   jz NoMemory1
         mov lpData1, eax
NEXT:
   dec IconNumber
   invoke  SendMessage,ToolbarHandle,TB_GETBUTTON,IconNumber,lpData
   invoke  ReadProcessMemory, hProcess, lpData,addr button, sizeof button, addr bytesRead
   invoke  ReadProcessMemory,hProcess,button.dwData,addr extra, sizeof extra,addr bytesRead
   mov eax, extra.Wnd
   cmp eax, HWnD
   je found10

   cmp IconNumber,0
   jnz NEXT
   jmp NoFound
found10:
   invoke  SendMessage,ToolbarHandle,TB_GETRECT, button.idCommand, lpData1
   invoke  ReadProcessMemory, hProcess, lpData1,addr rect1, sizeof rect1, addr bytesRead
NoFound:
   invoke  VirtualFreeEx,ProcId,lpData1,0,MEM_RELEASE
NoMemory1:
   invoke  VirtualFreeEx,ProcId,lpData,0,MEM_RELEASE
NoMemory:
   invoke  CloseHandle,ProcId
NoHandle:
   invoke GetWindowRect, ToolbarHandle,addr rect
   mov eax, rect1.top
   inc eax
   add rect.top, eax
   mov eax, rect1.left
   inc eax
   add rect.left, eax

   invoke sndPlaySound, addr SoundPopup, SND_SYNC
   invoke WindowFromPoint,rect.right,rect.top
   push eax
   invoke CreateWindowEx,WS_EX_TOPMOST,ADDR TOOLTIPS_CLASS,NULL,\
   TTS_ALWAYSTIP or TTS_BALLOON,CW_USEDEFAULT, CW_USEDEFAULT,\
   CW_USEDEFAULT,CW_USEDEFAULT,HWnD,NULL,hInstance,NULL
   mov hToolTips,eax
   mov toolinfo.cbSize,sizeof TOOLINFO
   mov toolinfo.uFlags,TTF_IDISHWND or TTF_TRACK
   mov toolinfo.hWnd,NULL
   pop toolinfo.uId
   mov toolinfo.hInst,NULL
   push PopupText
   pop toolinfo.lpszText
   invoke SendMessage,hToolTips,TTM_ADDTOOL,0,addr toolinfo
   invoke SendMessage,hToolTips,TTM_SETMAXTIPWIDTH,0,500
   invoke SendMessage,hToolTips,TTM_SETTITLE,1,addr ToolTipsCaption
   mov ecx,rect.top
   shl ecx,10h
   mov eax,rect.left
   or ecx,eax
   invoke SendMessage,hToolTips,TTM_TRACKPOSITION,0,ecx
   invoke SendMessage,hToolTips,TTM_TRACKACTIVATE,TRUE,addr toolinfo
   ret

PopupProc endp
Title: Re: TB_GETRECT
Post by: baltoro on May 06, 2011, 12:42:42 AM
...Ah,...you are testing for a valid handle now,...much better. Does it work?
The reason I ask that question is that, the HWND you obtain from FindWindowEx can only be used by that process.
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 12:45:21 AM
invoke  GetWindowThreadProcessId,extra.Wnd,IEID


Yes it work OK.
Title: Re: TB_GETRECT
Post by: baltoro on May 06, 2011, 12:47:44 AM
Ok,...well, then, I must be confusing you at this point.
You run this app with Administrative Privileges ???
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 12:50:17 AM
yes administrator - my computer


invoke  RtlAdjustPrivilege,13h,1h,0h,esp - ??????????????? need
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 08:37:52 AM
first create USER - not administrator on my PC. my application absolutly not working. (http://smiles.kolobok.us/standart/black_eye.gif)

as for determine tray icon position - this work OK

PS problem was with access to file from old adminidtrator USER directory . all work OK. (http://smiles.kolobok.us/standart/dance2.gif)
Title: Re: TB_GETRECT
Post by: Tedd on May 06, 2011, 10:21:01 AM
Are there any legitimate reasons for making a tooltip/balloon/notification appear as though it came from a program other than your own?
The only ones I can think of involve a trojan spoofing information to the effect of "fake update available, click here to download and install your new malware" or similar.
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 10:34:19 AM
Tray Icon - this is button of explorer, other application
Title: Re: TB_GETRECT
Post by: ragdog on May 06, 2011, 02:30:49 PM
hey Bomz

I found This i Hope it help


;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; FileName: TrayIcon.asm
;   Function: Demo the way to enum the icons in system tray
;       Author: Purple Endurer | 紫郢剑侠㊣ (PurpleEndurer@163.com)
;     DevEnv: Win2000 pro SP4, MASM32 v8
;
;  log
; ----------------------------------------------------------------------------------
; 2007-09-29  Can run under Win XP
; 2007-09-22  Created!
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc

include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib

GetSysTrayToolBarHandle proto
EnumSubCtl proto :HWND, :LPARAM
GetSysTrayIconCount proto
EnumSysTrayIcon proto

.data
g_szAppName db "EnumSysTrayIcon", 0
g_szTaskBarCls db "Shell_TrayWnd", 0
g_szSysPagerCls db "SysPager", 0    ;WinXP need!
g_szTrayNotifyWndCls db "TrayNotifyWnd", 0
g_szToolbarWindow32Cls db "ToolbarWindow32", 0
g_szFailGetSysTray db "Fail to get system tray!", 0
g_hSysTray      HANDLE ?
g_dwTrayIconCount dword ?
g_stTbButton TBBUTTON <>
g_szIconText db MAX_PATH dup (?)

.code
start:
invoke GetSysTrayToolBarHandle
test   eax, eax ; .if  eax==NULL
.if ZERO?
    invoke MessageBox, NULL, addr g_szFailGetSysTray, addr g_szAppName, MB_ICONERROR
.else
    mov     g_hSysTray, eax
    invoke EnumSysTrayIcon
.endif
invoke ExitProcess,NULL

;////////////////////////////////////////////////////////////////////////////////
; Function: Get the handle ToolbarWindow32 of in system tray
;           Shell_TrayWnd -> TrayNotifyWnd -> (WinXP:SysPager) -> ToolbarWindow32
;    Onput: if  fail eax=NULL, else eax = handle
;/////////////////////////////////////////////////////////////////////////////////
GetSysTrayToolBarHandle proc
   ;--- Get the handle of task bar
   invoke FindWindow, addr g_szTaskBarCls, NULL
   cmp     eax, NULL
   je         @GetSysTrayToolBarHandleRet ; fail

     ; HWND FindWindowEx(
     ;     HWND hwndParent,    // handle to parent window
     ;     HWND hwndChildAfter,    // handle to a child window
     ;     LPCTSTR lpszClass,    // pointer to class name
     ;     LPCTSTR lpszWindow    // pointer to window name
     ; );

    ;--- Get the handle of TrayNotifyWnd in task bar
    invoke FindWindowEx, eax, NULL,  addr  g_szTrayNotifyWndCls,   NULL
    cmp    eax, NULL
    je         @GetSysTrayToolBarHandleRet

    ;--- (WinXP Only) Get the handle of g_szSysPager in TrayNotifyWnd
    push eax
    invoke FindWindowEx, eax, NULL,  addr  g_szSysPagerCls, NULL
    .if    (eax==NULL)
        pop eax
    .else
        pop edi
    .endif

    ;--- Get the handle of ToolbarWindow32 in TrayNotifyWnd
    invoke FindWindowEx, eax, NULL,  addr  g_szToolbarWindow32Cls,   NULL

@GetSysTrayToolBarHandleRet:
    ret
GetSysTrayToolBarHandle endp


;/////////////////////////////////////////////////////////////////////////////////
; Function: Enum the Child window in task bar
;/////////////////////////////////////////////////////////////////////////////////
EnumSubCtl proc proc  hWnd: HWND, lParam: LPARAM
    invoke GetClassName, hWnd, addr g_szIconText, sizeof g_szIconText
    invoke MessageBox, NULL, addr g_szIconText, addr g_szIconText, MB_OK

    mov     eax, TRUE
    ret
EnumSubCtl endp


;/////////////////////////////////////////////////////////////////////////////////
; Function: Get the count of icon in system tray
;/////////////////////////////////////////////////////////////////////////////////
GetSysTrayIconCount proc
    invoke SendMessage,g_hSysTray, TB_BUTTONCOUNT, 0, 0
    mov     g_dwTrayIconCount, eax   
    ret
GetSysTrayIconCount endp

;///////////////////////////////////////////////////////////////////////
; Function: Enum the icon in system tray
;///////////////////////////////////////////////////////////////////////
EnumSysTrayIcon proc
    local dwProcID, dwReaded: dword
    local hProcess: HANDLE
    local pMem: dword

    invoke GetSysTrayIconCount

    invoke GetWindowThreadProcessId, g_hSysTray, addr dwProcID
    invoke OpenProcess, PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE, FALSE, dwProcID
    mov    hProcess, eax
    invoke VirtualAllocEx, hProcess,  NULL, 1024, MEM_RESERVE or MEM_COMMIT,  PAGE_READWRITE
    mov    pMem, eax

    xor      eax, eax
    .while (eax < g_dwTrayIconCount)
        push   eax

        invoke SendMessage, g_hSysTray, TB_GETBUTTON, eax,  pMem
        invoke ReadProcessMemory, hProcess, pMem, addr g_stTbButton, sizeof g_stTbButton,  addr dwReaded

        invoke SendMessage, g_hSysTray, TB_GETBUTTONTEXT, g_stTbButton.idCommand,  pMem

        inc       eax  ; If fail, the return value is  -1
        jz         @F   ; Fail, skip

        invoke ReadProcessMemory, hProcess,  pMem,   addr g_szIconText, sizeof g_szIconText, addr dwReaded
        invoke MessageBox, NULL, addr g_szIconText, addr g_szAppName, NULL
@@:
        pop      eax
        inc       eax
    .endw

    invoke VirtualFreeEx, hProcess, pMem,  0,  MEM_RELEASE
    invoke CloseHandle, hProcess

    ret
EnumSysTrayIcon endp

end start
Title: Re: TB_GETRECT
Post by: bomz on May 06, 2011, 02:40:18 PM
Thanks, the example or code much effectively for understanding, than Microsoft English
Title: Re: TB_GETRECT
Post by: ragdog on May 06, 2011, 03:26:03 PM
I have this found by search Toolbar examples for my project :8)

I have not read all your post of this Thread, i hope you want an example to get the tray icon text
Need you an other example for manipulate the icons tell me i have found a good c++ tutorial

Greets,
Title: Re: TB_GETRECT
Post by: bomz on May 08, 2011, 03:22:37 AM
(http://s60.radikal.ru/i167/1105/e7/746ca23b1c9e.gif)
Title: Re: TB_GETRECT
Post by: baltoro on May 09, 2011, 04:11:06 PM
...I've got to learn Russian,..
Title: Re: TB_GETRECT
Post by: bomz on June 16, 2011, 06:34:02 PM
May be somebody know - ToolBar, Tray, TrayIcon handles  may changes only if explorer reboot? or something else?