DDE-Server antwortet auf DDE Requests nur, wenn er in der IDE gestartet wird
-
Hallo zusammen,
ich habe hier ein kleines Problem mit meinem DDE-Server. Dieser beantwortet anliegende DDE-Requests nur, wenn er in der IDE gestartet wird (Visual C++ 2008). Hat jmd. eine Idee woran das liegen könnte? Ich kopier mal den Code hier rein:
LRESULT CMain::OnDDERequest(WPARAM wParam, LPARAM lParam) { ATOM atomApplication = NULL; ATOM atomItem = NULL; VERIFY( UnpackDDElParam(WM_DDE_REQUEST, lParam, (PUINT)&atomApplication, (PUINT)&atomItem) ); VERIFY( FreeDDElParam(WM_DDE_REQUEST, lParam) ); CString strApplication, strTopic; ::GlobalGetAtomName(atomApplication, strApplication.GetBufferSetLength(100), 100); ::GlobalGetAtomName(atomItem, strTopic.GetBufferSetLength(100), 100); strApplication.ReleaseBuffer(); strTopic.ReleaseBuffer(); m_strApplication = strApplication; m_strTopic = strTopic; if (m_strTopic == _T("Get Acquisition Status")) { CString strResult; strResult = "Antwort"; // Allocate the size of the DDE data header, plus the data: a // string,<CR><LF><NULL>. The byte for the string's terminating // null character is counted by DDEDATA.Value[1]. HGLOBAL hData = ::GlobalAlloc(GMEM_MOVEABLE, strResult.GetLength()+2 + (LONG)sizeof(DDEDATA)); if (!hData) { return 0L; } DDEDATA FAR* lpData = (DDEDATA FAR*) ::GlobalLock(hData); if (!lpData) { ::GlobalFree(hData); return 0L; } lpData->cfFormat = CF_TEXT; //lpData->fAckReq = 0; //lpData->fRelease = 0; HRESULT hResult = ::StringCchCopy((LPSTR) lpData->Value, strResult.GetLength()+1, strResult); // copies value to be sent if (FAILED(hResult)) { ::GlobalFree(hData); return 0L; } // Each line of CF_TEXT data is terminated by CR/LF. hResult = ::StringCchCat((LPSTR) lpData->Value, strResult.GetLength()+3, (LPCSTR) _T("\r\n\0")); if (FAILED(hResult)) { ::GlobalFree(hData); return 0L; } ::GlobalUnlock(hData); ATOM atomSendItem = ::GlobalAddAtom(m_strTopic); if (atomSendItem != 0) { lParam = PackDDElParam(WM_DDE_DATA, (UINT) hData, atomSendItem); if (!::PostMessage( (HWND)wParam, WM_DDE_DATA, (WPARAM) m_hWnd, lParam)) { ::GlobalFree(hData); ::GlobalDeleteAtom(atomSendItem); ::FreeDDElParam(WM_DDE_DATA, lParam); } } else { ::GlobalFree(hData); ::GlobalDeleteAtom(atomSendItem); } } else { // sende negative ACK message ::PostMessage((HWND)wParam, WM_DDE_ACK, (WPARAM) m_hWnd, PackDDElParam(WM_DDE_ACK, 0, atomItem)); } return 0L; }Vielen Dank und Gruß,
Marlin