Click here to Skip to main content
15,910,661 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
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 
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 
um.. really i didn't test the code. but now i have did, right. it doesn't work.
so i have fixed several line like below, and now it have worked well with WMP 10.
Enjoy Wink | ;)

BOOL CALLBACK EnumMPChildProc(HWND hWnd, LPARAM lParam);
BOOL CALLBACK EnumLVChildProc(HWND hWnd, LPARAM lParam);
CString GetItemText(HWND m_hWnd, int nItem, int nSubItem);

int test(void)
{
HWND hWMP = 0;
EnumChildWindows(0, EnumMPChildProc, (LPARAM) &hWMP);

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

HWND hList = 0;
EnumChildWindows(hWMP, EnumLVChildProc, (LPARAM) &hList);

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

CListCtrl v;
CString txt;

v.Attach(hList);

int nCount = v.GetItemCount();

for(int i=0; i < nCount; i++)
{
txt = GetItemText(hList, i, 0);

AfxMessageBox(txt);
}

v.Detach();

return 0;
}

BOOL CALLBACK EnumMPChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
TCHAR szTitle[MAX_PATH+1];

::GetClassName(hWnd, szClass, MAX_PATH);
::GetWindowText(hWnd, szTitle, MAX_PATH);

if(CString(_T("Windows Media Player")) == szTitle &&
CString(_T("WMPlayerApp")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;

return FALSE;
}

return TRUE;
}

BOOL CALLBACK EnumLVChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
TCHAR szTitle[MAX_PATH+1];

::GetClassName(hWnd, szClass, MAX_PATH);
::GetWindowText(hWnd, szTitle, MAX_PATH);

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

return FALSE;
}

return TRUE;
}

#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 (<a href="mailto:exteide@gmail.com">exteide@gmail.com</a>)
The Extension IDE: <a href="http://www.exteide.com">http://www.exteide.com</a>


-- modified at 1:07 Saturday 4th February, 2006
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 
AnswerRe: simulate a button press or click Pin
Igor Medvedev3-Feb-06 8:42
Igor Medvedev3-Feb-06 8:42 
QuestionSending Asynchronous messages from VC++(dll) to VB(client) Pin
techratna3-Feb-06 6:13
techratna3-Feb-06 6:13 

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.