+ realSize = conv->ToWChar((wchar_t *)realData, realSize, text, len);
+ if ( realSize == wxCONV_FAILED )
+ return false;
+
+ // We need to pass the size of the buffer to DdeClientTransaction() and
+ // not the length of the string.
+ realSize *= sizeof(wchar_t);
+ }
+#else // !wxUSE_UNICODE
+ if ( format == wxIPC_UNICODETEXT )
+ {
+ conv = &wxConvLibc;
+ }
+ else if ( format == wxIPC_UTF8TEXT )
+ {
+ // we could implement this in theory but it's not obvious how to pass
+ // the format information and, basically, why bother -- just use
+ // Unicode build
+ wxFAIL_MSG( wxT("UTF-8 text not supported in ANSI build") );
+
+ return false;
+ }
+ else // don't convert wxIPC_TEXT
+ {
+ realData = (LPBYTE)data;
+ realSize = size;
+ }
+
+ if ( conv )
+ {
+ const wchar_t * const wtext = (const wchar_t *)data;
+ const size_t len = size/sizeof(wchar_t);
+
+ realSize = conv->FromWChar(NULL, 0, wtext, len);
+ if ( realSize == wxCONV_FAILED )
+ return false;
+
+ realData = (LPBYTE)buffer.GetWriteBuf(realSize);
+ if ( !realData )
+ return false;
+
+ realSize = conv->FromWChar((char*)realData, realSize, wtext, len);
+ if ( realSize == wxCONV_FAILED )
+ return false;
+ }
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
+
+ DWORD result;
+ bool ok = DdeClientTransaction(realData,
+ realSize,
+ GetHConv(),
+ NULL,
+ // MSDN: if the transaction specified by
+ // the wType parameter does not pass data
+ // or is XTYP_EXECUTE, wFmt should be zero.
+ 0,
+ XTYP_EXECUTE,
+ DDE_TIMEOUT,
+ &result) != 0;