diff options
author | Jean-Francois Mauguit <jfmauguit@mac.com> | 2024-09-24 09:03:25 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-24 09:03:25 -0400 |
commit | bab614c421ed7ae329d26bf028c4a3b1d2450f5a (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/SDK/irctell/dde.cpp | |
parent | 4bde6044fddf053f31795b9eaccdd2a5a527d21f (diff) | |
parent | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (diff) | |
download | winamp-bab614c421ed7ae329d26bf028c4a3b1d2450f5a.tar.gz |
Merge pull request #5 from WinampDesktop/community
Merge to main
Diffstat (limited to 'Src/Plugins/SDK/irctell/dde.cpp')
-rw-r--r-- | Src/Plugins/SDK/irctell/dde.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
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 <windows.h> +#include "dde.h" +#include <strsafe.h> + +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); +} |