|
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
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
|
|
|
|
|
Once again, thank you for replying.
I've test the code and it works perfectly. I only had to change the Windows title to "Lecteur Windows Media" because I run a French version of XP.
However, the code retrieve all the songs of Windows Media Player playlist. How can I know which one is currently playing?
I'm sorry for bothering you again but I don't really know how to do that.
Cheers,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
No problem. It's my pleasure. I'm hearing old music against my will on your coattails.
You can apply just like below:
...
for(int i=0; i < nCount; i++)
{
txt = GetItemText(hList, i, 0);
int val = v.GetItemState(i, LVIS_FOCUSED);
if (val == 1)
AfxMessageBox(txt);
}
...
Enjoy
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>
|
|
|
|
|
Thank you.
It works nicely.
You have been of great help. I wish everybody in this forum was as patient as you have been.
Cheers,
Allad;)
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|
One more, you can find WMP with just class name like below:
BOOL CALLBACK EnumMPChildProc(HWND hWnd, LPARAM lParam)
{
TCHAR szClass[MAX_PATH+1];
::GetClassName(hWnd, szClass, MAX_PATH);
if(CString(_T("WMPlayerApp")) == szClass)
{
HWND* pWnd = (HWND*) lParam;
*pWnd = hWnd;
return FALSE;
}
return TRUE;
}
Enjoy
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>
|
|
|
|
|
The best way would be to write a WMP plugin which keeps the current song in shared memory. MSN IM does it this way.
Groveling through the WMP windows isn't going to work when the window structure changes.
--Mike--
|
|
|
|
|
Michael Dunn wrote: The best way would be to write a WMP plugin which keeps the current song in shared memory.
I've never written a WMP plugin before and all the more a plugin which keeps data in shared memory.
I looked at the MSDN section discussing WMP plugins but it seems particularly poor.
Can you give me a link to some tutorial or guide ?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
I haven't looked at the online WMP SDK in a while, but the downloadable version goes into good detail about plugins, and comes with a nice VC AppWizard.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Michael Dunn wrote: the downloadable version goes into good detail about plugins, and comes with a nice VC AppWizard.
I'm developing under Visual Studio 2005. Actually the WMP SDK is quite good.
However, there isn't VC AppWizard to generate WMP Plugin. Maybe there is an option to turn on.
Can you help?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|
I have a value that is a BYTE.
I would like to mask the upper 7 bits and just take the last bit as my value.
Is it on for me to && 0x01 to achieve this ? Or how would i do it?
Thanks
|
|
|
|
|
http://www.codeproject.com/cpp/bitbashing.asp[^]
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Use "&" not "&&". "&&" is a logical and, it always yield true or false.
Steve
|
|
|
|
|
I have a MFC application with a CDialog that has some fields and then a Submit button. I want to have a seperate thread monitoring an IO signal and if I see that signal I want to simulate a Submit button click. I want to be able to also click the button to have the event happen. How does one simulate a button press?
Barton
|
|
|
|
|
Make sure your thread "knows" the HWND of your dialog and then it can do the following:
::PostMessage(m_hWndDialog, WM_COMMAND, IDOK, 0L);
Dirty, but it should work.
|
|
|
|
|
|
Hi,
I want to send asynchronous messages from my VC++ DLL to VB front end. I use SendMessage, it works but since it does not return till the processing is complete, the application becomes very slow. I know that I should use SendMessageCallback instead, but somehow my WndProc, which I have written in VB app does not receive the messages sent through SendMessageCallback. The messages are being sent at a very fast rate, so I need the fastest procedure to communicate. Also, while VB is doing is processing I want my VC application to keep working, but with SendMessage it just waits for the processing on VB side to get completed.
Is there any other way I can do the communication with less overheads.
Thanks, Ratna
|
|
|
|
|
|
Try using PostMessage .
Steve
|
|
|
|
|
See PostMessage instead of SendMessage
|
|
|
|
|
i want to save a file ,which in MHTML ,as a BMP file.How can i do it ?
Thanks in advance
|
|
|
|
|
What's MHTML? Microsoft HTML?
Or are you talking about the "MHT"-format (Microsofts "Web Archive" -Format)?
Anyway, you will have to render the file and then save the resulting image as a BMP.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
MSHTML is the "guts" of IE - A COM object which does all the HTML parsing and such.
Steve
|
|
|
|
|