From 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d Mon Sep 17 00:00:00 2001 From: Jef Date: Tue, 24 Sep 2024 14:54:57 +0200 Subject: Initial community commit --- Src/Plugins/SDK/irctell/dde.cpp | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Src/Plugins/SDK/irctell/dde.cpp (limited to 'Src/Plugins/SDK/irctell/dde.cpp') diff --git a/Src/Plugins/SDK/irctell/dde.cpp b/Src/Plugins/SDK/irctell/dde.cpp new file mode 100644 index 00000000..790ffa09 --- /dev/null +++ b/Src/Plugins/SDK/irctell/dde.cpp @@ -0,0 +1,50 @@ +#include +#include "dde.h" +#include + +HDDEDATA CALLBACK DdeGenericCallback(UINT uType, UINT uFmt,HCONV hconv, HSZ hsz1, + HSZ hsz2, HDDEDATA hdata, DWORD dwData1, + DWORD dwData2) +{ + return ((HDDEDATA)0); +} + +void DdeCom::sendCommand(wchar_t *application, wchar_t *command, DWORD minInterval) +{ + static DWORD lastCmd=0, now; + HSZ string1,string2,string3; + wchar_t line[512]; + HCONV ddeConv; + DWORD result; + + now = GetTickCount(); + if (now < lastCmd + minInterval) + return; + + StringCchCopy(line, 512, command); + + DWORD DDE=0; + + if (DdeInitialize(&DDE, DdeGenericCallback, CBF_SKIP_ALLNOTIFICATIONS+ST_CLIENT,0) != DMLERR_NO_ERROR) + { + MessageBox(NULL,L"DDE INITIALIZE", L"Error", MB_OK); + + return; + } + + string1 = DdeCreateStringHandle(DDE, application, CP_WINANSI); + string2 = DdeCreateStringHandle(DDE, L"COMMAND", CP_WINANSI); + + if ((ddeConv = DdeConnect(DDE, string1, string2, 0)) != 0) + { + string3 = DdeCreateStringHandle(DDE, L"None", CP_WINANSI); + DdeClientTransaction((LPBYTE)line, (wcslen(line)+1)*sizeof(line[0]), ddeConv, string3, CF_UNICODETEXT, XTYP_POKE, 1000, &result); + DdeFreeStringHandle(DDE, string3); + DdeDisconnect(ddeConv); + lastCmd = now; + } + + DdeFreeStringHandle(DDE, string1); + DdeFreeStringHandle(DDE, string2); + DdeUninitialize(DDE); +} -- cgit