Question

I want to get quick launch bar size, but my code returns false, where is the problem?

REBARBANDINFOW prbi;
memset(&prbi, 0, sizeof(REBARBANDINFOW));

prbi.cbSize = sizeof(REBARBANDINFOW);
prbi.fMask = 892;

HWND hWndTray = ::FindWindow(L"Shell_TrayWnd", 0);
HWND hRebar = ::FindWindowEx(hWndTray, NULL, L"ReBarWindow32", 0);
int i = ::SendMessage(hRebar, RB_GETBANDINFOW, 0, (LPARAM)(LPREBARBANDINFOW)&prbi);
Was it helpful?

Solution

The problem is with the LPARAM of RB_GETBANDINFOW. The address of the structure you are sending is only valid in your own address space, not that of Explorer. Luckily, Explorer detects this and fails gracefully instead of blowing up.

One way to solve this is to use VirtualAllocEx to allocate the REBARBANDINFOW in Explorer's memory, use WriteProcessMemory to initialize it, send the message, and finally call ReadProcessMemory to read the result.

I've successfully used this technique in a Python script to automatically set the Quick Launch's size.

OTHER TIPS

You are trying to get too much info. Place prbi.fMask = 32; or prbi.fMask = 64;.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top