Click here to Skip to main content
15,901,122 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Converting VS 6.0 to VS 7.1 Pin
Michael Dunn3-Feb-06 12:52
sitebuilderMichael Dunn3-Feb-06 12:52 
AnswerRe: Converting VS 6.0 to VS 7.1 Pin
Gary R. Wheeler5-Feb-06 2:59
Gary R. Wheeler5-Feb-06 2:59 
Questiondebug visual c++ 2003 application in windows 98 Pin
Hesham Desouky3-Feb-06 10:33
Hesham Desouky3-Feb-06 10:33 
AnswerRe: debug visual c++ 2003 application in windows 98 Pin
Michael Dunn3-Feb-06 12:53
sitebuilderMichael Dunn3-Feb-06 12:53 
QuestionRetrieving now playing song in Windows Media Player Pin
Allad3-Feb-06 9:24
Allad3-Feb-06 9:24 
AnswerRe: Retrieving now playing song in Windows Media Player Pin
EXTEIDE3-Feb-06 9:30
EXTEIDE3-Feb-06 9:30 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Allad3-Feb-06 10:02
Allad3-Feb-06 10:02 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
EXTEIDE3-Feb-06 10:35
EXTEIDE3-Feb-06 10:35 
You can apply following code. it's a little complex:


BOOL CALLBACK EnumChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
::GetClassName(hWnd, szClass, MAX_PATH);

if(CString(_T("SysListView32")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;

return FALSE;
}
return TRUE;
}

void CMyApp::OnButton1()
{
HWND hWndMP = ::FindWindow("", "Windows Media Player");

if(!hWndMP)
{
AfxMessageBox("There's no media player");
return;
}

HWND hList = 0;
EnumChildWindows(hWndMP, EnumChildProc, (LPARAM) &hList);

if(!hList)
{
AfxMessageBox("failed..");
return ;
}

Search(hList); // this function is following..
}

///////////////////////////////////////////////////////

void CMyApp::Search(HWND hWnd)
{
CListCtrl v;

v.Attach(hWnd);

int nCount = v.GetItemCount();
CStringArray ar;

for(int i=0; i < nCount; i++)
{
CString sText = GetItemText(v.m_hWnd, i, 0); // this function is following..
}

v.Detach();
}

///////////////////////////////////////////////////////

#define _SIZE 10240

CString GetItemText(HWND m_hWnd, int nItem, int nSubItem)
{
ASSERT(::IsWindow(m_hWnd));
LVITEM lvi;

DWORD TID,PID;
TID = GetWindowThreadProcessId(m_hWnd, &PID);

HANDLE hRemoteProcessHandle = OpenProcess(PROCESS_ALL_ACCESS,false,PID);

if(hRemoteProcessHandle == NULL)
return "";

//
// get enough memory
//
PSTR pszRemoteProcessMemory = (PSTR)VirtualAllocEx( hRemoteProcessHandle, 0, _SIZE, MEM_COMMIT, PAGE_EXECUTE_READWRITE );

if(NULL == pszRemoteProcessMemory)
return "";

memset(&lvi, 0, sizeof(LVITEM));

lvi.iSubItem = nSubItem;

CString str;
int nLen = 128;
int nRes;

char* p3 = (char*) pszRemoteProcessMemory + sizeof(LVITEM);
do
{
nLen *= 2;
lvi.cchTextMax = _SIZE - sizeof(LVITEM);
lvi.pszText = p3;

//copy LVITEM
WriteProcessMemory(hRemoteProcessHandle, pszRemoteProcessMemory, &lvi, sizeof(lvi), NULL);

nRes = (int)::SendMessage(m_hWnd, LVM_GETITEMTEXT, (WPARAM)nItem, (LPARAM)pszRemoteProcessMemory);
} while (nRes == nLen-1);


DWORD dwRead;
TCHAR szBuffer[1024]={0,};
ReadProcessMemory(hRemoteProcessHandle, (PVOID)p3, szBuffer, 1024, &dwRead);

if(hRemoteProcessHandle)
{
if(pszRemoteProcessMemory )
VirtualFreeEx( hRemoteProcessHandle,(void*)pszRemoteProcessMemory, 0, MEM_RELEASE );
CloseHandle(hRemoteProcessHandle);
}

return szBuffer;
}


Anderson Sheen (exteide@gmail.com)
The Extension IDE: http://www.exteide.com


-- modified at 16:37 Friday 3rd February, 2006
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Allad3-Feb-06 15:30
Allad3-Feb-06 15:30 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
EXTEIDE3-Feb-06 19:06
EXTEIDE3-Feb-06 19:06 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Allad4-Feb-06 6:23
Allad4-Feb-06 6:23 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
EXTEIDE4-Feb-06 6:57
EXTEIDE4-Feb-06 6:57 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Allad4-Feb-06 8:09
Allad4-Feb-06 8:09 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
EXTEIDE4-Feb-06 8:41
EXTEIDE4-Feb-06 8:41 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
EXTEIDE4-Feb-06 7:04
EXTEIDE4-Feb-06 7:04 
AnswerRe: Retrieving now playing song in Windows Media Player Pin
Michael Dunn3-Feb-06 18:48
sitebuilderMichael Dunn3-Feb-06 18:48 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Allad4-Feb-06 6:28
Allad4-Feb-06 6:28 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Michael Dunn4-Feb-06 6:41
sitebuilderMichael Dunn4-Feb-06 6:41 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Allad4-Feb-06 6:47
Allad4-Feb-06 6:47 
GeneralRe: Retrieving now playing song in Windows Media Player Pin
Michael Dunn4-Feb-06 8:52
sitebuilderMichael Dunn4-Feb-06 8:52 
QuestionMasking bits Pin
LCI3-Feb-06 8:47
LCI3-Feb-06 8:47 
AnswerRe: Masking bits Pin
PJ Arends3-Feb-06 9:44
professionalPJ Arends3-Feb-06 9:44 
AnswerRe: Masking bits Pin
Stephen Hewitt3-Feb-06 18:08
Stephen Hewitt3-Feb-06 18:08 
Questionsimulate a button press or click Pin
bartonlp3-Feb-06 7:09
bartonlp3-Feb-06 7:09 
AnswerRe: simulate a button press or click Pin
Rob Caldecott3-Feb-06 7:19
Rob Caldecott3-Feb-06 7:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.