CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: GetScrollInfo

  1. #1
    Join Date
    Jun 2009
    Posts
    1

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

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    894

    Re: GetScrollInfo

    You need to inject your code into a process whose scrollbar you want to get info from and then SendMessage with SBM_GETSCROLLINFO from there.

    More here:
    http://www.codeproject.com/KB/threads/winspy.aspx

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
  •  





Click Here to Expand Forum to Full Width

Featured