|
-
June 16th, 2009, 04:29 PM
#1
GetScrollInfo
I am trying to get scrollbar information like position, range.
The code is as follows
GetWindowThreadProcessId(hwnd,&pid);
HANDLE handle=OpenProcess(PROCESS_ALL_ACCESS,0,pid);
if(handle!=NULL)
{
SCROLLINFO info,*nfo;
ZeroMemory(&info,sizeof(SCROLLINFO));
nfo=(SCROLLINFO*)VirtualAllocEx(handle,NULL,sizeof(SCROLLINFO),MEM_COMMIT,PAGE_READWRITE);
if(nfo!=NULL)
{
info.cbSize=sizeof(info);
info.fMask=SIF_ALL;
if(!WriteProcessMemory(handle,nfo,&info,sizeof(SCROLLINFO),NULL))
ShowError(GetLastError());
SendMessage(hwnd,SBM_GETSCROLLINFO,SB_VERT,(LPARAM)nfo);
ShowError(GetLastError());
if(!ReadProcessMemory(handle,nfo,&info,sizeof(info),NULL))
ShowError(GetLastError());
sprintf(m,"%d,%d,%d",info.nMax,info.nPage,info.nPos);
MessageBox(hwnd,m,"",0);
if(!VirtualFreeEx(handle,nfo,0,MEM_RELEASE))
ShowError(GetLastError());
CloseHandle(handle);
}
else
{
MessageBox(hwnd,"VirtualAllocEx Failed","",0);
CloseHandle(handle);
}
}
else
{
MessageBox(hwnd,"OpenProcess Failed","",0);
}
code runs with no errors but values in info structure remains 0.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|