News:

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

TB_GETRECT

Started by bomz, May 04, 2011, 08:21:43 PM

Previous topic - Next topic

baltoro

...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.
Baltoro

bomz

invokeĀ  GetWindowThreadProcessId,extra.Wnd,IEID


Yes it work OK.

baltoro

Ok,...well, then, I must be confusing you at this point.
You run this app with Administrative Privileges ???
Baltoro

bomz

yes administrator - my computer


invoke  RtlAdjustPrivilege,13h,1h,0h,esp - ??????????????? need

bomz

first create USER - not administrator on my PC. my application absolutly not working.

as for determine tray icon position - this work OK

PS problem was with access to file from old adminidtrator USER directory . all work OK.

Tedd

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.
No snowflake in an avalanche feels responsible.

bomz

Tray Icon - this is button of explorer, other application

ragdog

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

bomz

Thanks, the example or code much effectively for understanding, than Microsoft English

ragdog

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,

bomz


baltoro

...I've got to learn Russian,..
Baltoro

bomz

May be somebody know - ToolBar, Tray, TrayIcon handles  may changes only if explorer reboot? or something else?