HWND hWnd = ::FindWindow(NULL, L"XXXXXXX"); if (hWnd != NULL) { DWORD dwReadBytes; unsigned char *lpbuffer = (unsigned char *)malloc(10 * 1024 * 1024);; USES_CONVERSION; LPCSTR path = (LPCSTR)T2A(m_strDescPath); //m_strDescPath为一edit组件的成员变量 HFILE splhandle = _lopen(path, 0); dwReadBytes = _lread(splhandle, lpbuffer, 10 * 1024 * 1024); COPYDATASTRUCT cpd; /*给COPYDATASTRUCT结构赋值*/ //cpd.dwData = 1; //标志发送字符串 //cpd.cbData = strlen("字符串")+1; //cpd.lpData = "字符串"; //::SendMessage(hWnd,WM_COPYDATA,NULL,(LPARAM)&cpd);//发送! cpd.dwData = 1; //标志发送CString类型 cpd.cbData = dwReadBytes; cpd.lpData = lpbuffer; ::SendMessage(hWnd, WM_COPYDATA, NULL, (LPARAM)&cpd); //发送! }
时间: 2024-10-08 02:51:07