1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
STDMETHODIMP CclsDLLMSN::SendMessageMSN(BSTR m_strMessage, SHORT show)
{
HWND msnui = NULL;
COPYDATASTRUCT msndata;
// ASCII
char Title[256];
memset(Title,'\0',sizeof(Title));
unsigned long length = WideCharToMultiByte (CP_ACP,0, m_strMessage,SysStringLen(m_strMessage), NULL, 0,NULL, NULL);
char* strRet = new char[length];
length = WideCharToMultiByte (CP_ACP,0, m_strMessage,SysStringLen(m_strMessage), reinterpret_cast <char *>(strRet), length,NULL, NULL);
strRet[length] = '\0';
sprintf(Title,"\\0Music\\0%i\\0{0}\\0%s\\0\\0\\0\\0\0",show,strRet);
// UTF16
WCHAR wstrTitle[256];
memset(wstrTitle, 0, sizeof(CHAR)*256);
// Conversion ASCII vers UTF16
int nLen = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)Title, -1, NULL, NULL);
MultiByteToWideChar(CP_ACP, 0, (LPCSTR)Title, -1, (LPWSTR)wstrTitle, nLen);
msndata.dwData = 0x547;
msndata.lpData = (void*)wstrTitle;
msndata.cbData = (nLen*2)+2;
do
{
USES_CONVERSION;
msnui = ::FindWindowEx(NULL, msnui,A2W("MsnMsgrUIManager"), NULL);
if (msnui != NULL)
::SendMessage(msnui, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&msndata);
}while(msnui !=NULL);
delete strRet;
return S_OK;
} |
Partager