2005-06-30 22:45:57 +02:00
|
|
|
/*
|
|
|
|
* Shell DDE Handling
|
|
|
|
*
|
|
|
|
* Copyright 2004 Robert Shearman
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2005-06-30 22:45:57 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
2017-12-01 17:08:12 +01:00
|
|
|
#define COBJMACROS
|
2005-06-30 22:45:57 +02:00
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
2010-06-17 16:08:06 +02:00
|
|
|
#include "winuser.h"
|
2005-06-30 22:45:57 +02:00
|
|
|
#include "ddeml.h"
|
|
|
|
#include "shellapi.h"
|
2017-12-01 17:08:12 +01:00
|
|
|
#include "shobjidl.h"
|
|
|
|
#include "shlwapi.h"
|
2005-06-30 22:45:57 +02:00
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
#include "shell32_main.h"
|
|
|
|
|
2005-06-30 22:45:57 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
/* String handles */
|
|
|
|
static HSZ hszProgmanTopic;
|
|
|
|
static HSZ hszProgmanService;
|
|
|
|
static HSZ hszAsterisk;
|
|
|
|
static HSZ hszShell;
|
|
|
|
static HSZ hszAppProperties;
|
|
|
|
static HSZ hszFolders;
|
2010-06-17 16:08:06 +02:00
|
|
|
static HSZ hszGroups;
|
2005-06-30 22:45:57 +02:00
|
|
|
/* DDE Instance ID */
|
|
|
|
static DWORD dwDDEInst;
|
|
|
|
|
2010-06-17 16:08:06 +02:00
|
|
|
static const char *debugstr_hsz( HSZ hsz )
|
|
|
|
{
|
|
|
|
WCHAR buffer[256];
|
2018-03-19 08:11:27 +01:00
|
|
|
if (!DdeQueryStringW( dwDDEInst, hsz, buffer, ARRAY_SIZE(buffer), CP_WINUNICODE ))
|
2010-06-17 16:08:06 +02:00
|
|
|
return "<unknown>";
|
|
|
|
return debugstr_w( buffer );
|
|
|
|
}
|
2005-06-30 22:45:57 +02:00
|
|
|
|
|
|
|
static inline BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService)
|
|
|
|
{
|
|
|
|
if ((hszTopic == hszProgmanTopic) && (hszService == hszProgmanService))
|
|
|
|
return TRUE;
|
|
|
|
if ((hszTopic == hszProgmanTopic) && (hszService == hszAppProperties))
|
|
|
|
return TRUE;
|
|
|
|
if ((hszTopic == hszShell) && (hszService == hszFolders))
|
|
|
|
return TRUE;
|
|
|
|
if ((hszTopic == hszShell) && (hszService == hszAppProperties))
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService)
|
|
|
|
{
|
2010-06-17 16:08:06 +02:00
|
|
|
TRACE( "%p %s %s\n", hconv, debugstr_hsz(hszTopic), debugstr_hsz(hszService) );
|
2005-06-30 22:45:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL Dde_OnWildConnect(HSZ hszTopic, HSZ hszService)
|
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-11-30 00:00:46 +01:00
|
|
|
/* Returned string must be freed by caller */
|
2017-12-02 03:52:51 +01:00
|
|
|
static WCHAR *get_programs_path(const WCHAR *name)
|
2017-11-30 00:00:46 +01:00
|
|
|
{
|
|
|
|
WCHAR *programs, *path;
|
|
|
|
int len;
|
|
|
|
|
|
|
|
SHGetKnownFolderPath(&FOLDERID_Programs, 0, NULL, &programs);
|
|
|
|
|
|
|
|
len = lstrlenW(programs) + 1 + lstrlenW(name);
|
2018-02-22 08:43:28 +01:00
|
|
|
path = heap_alloc((len + 1) * sizeof(*path));
|
2017-11-30 00:00:46 +01:00
|
|
|
lstrcpyW(path, programs);
|
2021-09-20 12:58:52 +02:00
|
|
|
lstrcatW(path, L"/");
|
2017-11-30 00:00:46 +01:00
|
|
|
lstrcatW(path, name);
|
|
|
|
|
|
|
|
CoTaskMemFree(programs);
|
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2017-12-02 03:52:51 +01:00
|
|
|
static inline HDDEDATA Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic,
|
|
|
|
HSZ hszItem)
|
|
|
|
{
|
|
|
|
if (hszTopic == hszProgmanTopic && hszItem == hszGroups && uFmt == CF_TEXT)
|
|
|
|
{
|
|
|
|
WCHAR *programs;
|
|
|
|
WIN32_FIND_DATAW finddata;
|
|
|
|
HANDLE hfind;
|
|
|
|
int len = 1;
|
2018-02-22 08:43:28 +01:00
|
|
|
WCHAR *groups_data = heap_alloc(sizeof(WCHAR));
|
2017-12-02 03:52:51 +01:00
|
|
|
char *groups_dataA;
|
|
|
|
HDDEDATA ret;
|
|
|
|
|
|
|
|
groups_data[0] = 0;
|
2021-09-20 12:58:52 +02:00
|
|
|
programs = get_programs_path(L"*");
|
2017-12-02 03:52:51 +01:00
|
|
|
hfind = FindFirstFileW(programs, &finddata);
|
|
|
|
if (hfind)
|
|
|
|
{
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
|
2021-09-20 12:58:52 +02:00
|
|
|
wcscmp(finddata.cFileName, L".") && wcscmp(finddata.cFileName, L".."))
|
2017-12-02 03:52:51 +01:00
|
|
|
{
|
|
|
|
len += lstrlenW(finddata.cFileName) + 2;
|
2018-02-22 08:43:28 +01:00
|
|
|
groups_data = heap_realloc(groups_data, len * sizeof(WCHAR));
|
2017-12-02 03:52:51 +01:00
|
|
|
lstrcatW(groups_data, finddata.cFileName);
|
2021-09-20 12:58:52 +02:00
|
|
|
lstrcatW(groups_data, L"\r\n");
|
2017-12-02 03:52:51 +01:00
|
|
|
}
|
|
|
|
} while (FindNextFileW(hfind, &finddata));
|
|
|
|
FindClose(hfind);
|
|
|
|
}
|
|
|
|
|
|
|
|
len = WideCharToMultiByte(CP_ACP, 0, groups_data, -1, NULL, 0, NULL, NULL);
|
2018-02-22 08:43:28 +01:00
|
|
|
groups_dataA = heap_alloc(len * sizeof(WCHAR));
|
2017-12-02 03:52:51 +01:00
|
|
|
WideCharToMultiByte(CP_ACP, 0, groups_data, -1, groups_dataA, len, NULL, NULL);
|
|
|
|
ret = DdeCreateDataHandle(dwDDEInst, (BYTE *)groups_dataA, len, 0, hszGroups, uFmt, 0);
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(groups_dataA);
|
|
|
|
heap_free(groups_data);
|
|
|
|
heap_free(programs);
|
2017-12-02 03:52:51 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
else if (hszTopic == hszProgmanTopic && hszItem == hszProgmanService && uFmt == CF_TEXT)
|
|
|
|
{
|
|
|
|
static BYTE groups_data[] = "\r\n";
|
|
|
|
FIXME( "returning empty groups list\n" );
|
|
|
|
/* This is a workaround for an application which expects some data
|
|
|
|
* and cannot handle NULL. */
|
|
|
|
return DdeCreateDataHandle( dwDDEInst, groups_data, sizeof(groups_data), 0, hszProgmanService, uFmt, 0 );
|
|
|
|
}
|
|
|
|
FIXME( "%u %p %s %s: stub\n", uFmt, hconv, debugstr_hsz(hszTopic), debugstr_hsz(hszItem) );
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
static DWORD PROGMAN_OnExecute(WCHAR *command, int argc, WCHAR **argv)
|
|
|
|
{
|
2017-12-01 17:08:12 +01:00
|
|
|
static WCHAR *last_group;
|
2021-09-20 12:58:52 +02:00
|
|
|
DWORD len;
|
2017-11-30 00:00:46 +01:00
|
|
|
|
2021-09-20 12:58:52 +02:00
|
|
|
if (!wcsicmp(command, L"CreateGroup"))
|
2017-11-30 00:00:46 +01:00
|
|
|
{
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
if (argc < 1) return DDE_FNOTPROCESSED;
|
|
|
|
|
|
|
|
path = get_programs_path(argv[0]);
|
|
|
|
|
|
|
|
CreateDirectoryW(path, NULL);
|
|
|
|
ShellExecuteW(NULL, NULL, path, NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
2018-04-01 22:20:45 +02:00
|
|
|
heap_free(last_group);
|
2017-12-01 17:08:12 +01:00
|
|
|
last_group = path;
|
2017-11-30 00:00:46 +01:00
|
|
|
}
|
2021-09-20 12:58:52 +02:00
|
|
|
else if (!wcsicmp(command, L"DeleteGroup"))
|
2017-11-30 00:00:47 +01:00
|
|
|
{
|
|
|
|
WCHAR *path, *path2;
|
|
|
|
SHFILEOPSTRUCTW shfos = {0};
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (argc < 1) return DDE_FNOTPROCESSED;
|
|
|
|
|
|
|
|
path = get_programs_path(argv[0]);
|
|
|
|
|
2021-09-17 17:16:11 +02:00
|
|
|
path2 = heap_alloc((lstrlenW(path) + 2) * sizeof(*path));
|
|
|
|
lstrcpyW(path2, path);
|
|
|
|
path2[lstrlenW(path) + 1] = 0;
|
2017-11-30 00:00:47 +01:00
|
|
|
|
|
|
|
shfos.wFunc = FO_DELETE;
|
|
|
|
shfos.pFrom = path2;
|
|
|
|
shfos.fFlags = FOF_NOCONFIRMATION;
|
|
|
|
|
|
|
|
ret = SHFileOperationW(&shfos);
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(path2);
|
|
|
|
heap_free(path);
|
2017-11-30 00:00:47 +01:00
|
|
|
|
|
|
|
if (ret || shfos.fAnyOperationsAborted) return DDE_FNOTPROCESSED;
|
|
|
|
}
|
2021-09-20 12:58:52 +02:00
|
|
|
else if (!wcsicmp(command, L"ShowGroup"))
|
2017-11-30 00:00:48 +01:00
|
|
|
{
|
|
|
|
WCHAR *path;
|
|
|
|
|
|
|
|
/* Win32 requires the second parameter to be present but seems to
|
|
|
|
* ignore its actual value. */
|
|
|
|
if (argc < 2) return DDE_FNOTPROCESSED;
|
|
|
|
|
|
|
|
path = get_programs_path(argv[0]);
|
|
|
|
|
|
|
|
ShellExecuteW(NULL, NULL, path, NULL, NULL, SW_SHOWNORMAL);
|
|
|
|
|
2018-04-01 22:20:45 +02:00
|
|
|
heap_free(last_group);
|
2017-12-01 17:08:12 +01:00
|
|
|
last_group = path;
|
|
|
|
}
|
2021-09-20 12:58:52 +02:00
|
|
|
else if (!wcsicmp(command, L"AddItem"))
|
2017-12-01 17:08:12 +01:00
|
|
|
{
|
|
|
|
WCHAR *path, *name;
|
|
|
|
IShellLinkW *link;
|
|
|
|
IPersistFile *file;
|
|
|
|
HRESULT hres;
|
|
|
|
|
|
|
|
if (argc < 1) return DDE_FNOTPROCESSED;
|
|
|
|
|
|
|
|
hres = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
|
|
|
|
&IID_IShellLinkW, (void **)&link);
|
|
|
|
if (FAILED(hres)) return DDE_FNOTPROCESSED;
|
|
|
|
|
2021-09-20 12:58:52 +02:00
|
|
|
len = SearchPathW(NULL, argv[0], L".exe", 0, NULL, NULL);
|
2017-12-01 17:08:12 +01:00
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
IShellLinkW_Release(link);
|
|
|
|
return DDE_FNOTPROCESSED;
|
|
|
|
}
|
2018-02-22 08:43:28 +01:00
|
|
|
path = heap_alloc(len * sizeof(WCHAR));
|
2021-09-20 12:58:52 +02:00
|
|
|
SearchPathW(NULL, argv[0], L".exe", len, path, NULL);
|
2017-12-01 17:08:12 +01:00
|
|
|
IShellLinkW_SetPath(link, path);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(path);
|
2017-12-01 17:08:12 +01:00
|
|
|
|
|
|
|
if (argc >= 2) IShellLinkW_SetDescription(link, argv[1]);
|
2021-09-17 17:16:11 +02:00
|
|
|
if (argc >= 4) IShellLinkW_SetIconLocation(link, argv[2], wcstol(argv[3], NULL, 10));
|
2017-12-01 17:08:12 +01:00
|
|
|
if (argc >= 7) IShellLinkW_SetWorkingDirectory(link, argv[6]);
|
2021-09-17 17:16:11 +02:00
|
|
|
if (argc >= 8) IShellLinkW_SetHotkey(link, wcstol(argv[7], NULL, 10));
|
2017-12-01 17:08:12 +01:00
|
|
|
if (argc >= 9)
|
|
|
|
{
|
2021-09-17 17:16:11 +02:00
|
|
|
if (wcstol(argv[8], NULL, 10) == 0) IShellLinkW_SetShowCmd(link, SW_SHOWMINNOACTIVE);
|
|
|
|
else if (wcstol(argv[8], NULL, 10) == 1) IShellLinkW_SetShowCmd(link, SW_SHOWNORMAL);
|
2017-12-01 17:08:12 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hres = IShellLinkW_QueryInterface(link, &IID_IPersistFile, (void **)&file);
|
|
|
|
if (FAILED(hres))
|
|
|
|
{
|
|
|
|
IShellLinkW_Release(link);
|
|
|
|
return DDE_FNOTPROCESSED;
|
|
|
|
}
|
|
|
|
if (argc >= 2)
|
|
|
|
{
|
2021-09-20 12:58:52 +02:00
|
|
|
len = lstrlenW(last_group) + 1 + lstrlenW(argv[1]) + 5;
|
|
|
|
name = heap_alloc(len * sizeof(*name));
|
|
|
|
swprintf( name, len, L"%s/%s.lnk", last_group, argv[1] );
|
2017-12-01 17:08:12 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const WCHAR *filename = PathFindFileNameW(argv[0]);
|
2021-09-20 12:58:52 +02:00
|
|
|
len = PathFindExtensionW(filename) - filename;
|
2021-09-17 17:16:11 +02:00
|
|
|
name = heap_alloc((lstrlenW(last_group) + 1 + len + 5) * sizeof(*name));
|
2021-09-20 12:58:52 +02:00
|
|
|
swprintf( name, lstrlenW(last_group) + 1 + len + 5, L"%s/%.*s.lnk", last_group, len, filename );
|
2017-12-01 17:08:12 +01:00
|
|
|
}
|
|
|
|
hres = IPersistFile_Save(file, name, TRUE);
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(name);
|
2017-12-01 17:08:12 +01:00
|
|
|
IPersistFile_Release(file);
|
|
|
|
IShellLinkW_Release(link);
|
|
|
|
|
|
|
|
if (FAILED(hres)) return DDE_FNOTPROCESSED;
|
2017-11-30 00:00:48 +01:00
|
|
|
}
|
2021-09-20 12:58:52 +02:00
|
|
|
else if (!wcsicmp(command, L"DeleteItem") || !wcsicmp(command, L"ReplaceItem"))
|
2017-12-01 17:08:13 +01:00
|
|
|
{
|
|
|
|
WCHAR *name;
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (argc < 1) return DDE_FNOTPROCESSED;
|
|
|
|
|
2021-09-20 12:58:52 +02:00
|
|
|
len = lstrlenW(last_group) + 1 + lstrlenW(argv[0]) + 5;
|
|
|
|
name = heap_alloc(len * sizeof(*name));
|
|
|
|
swprintf( name, len, L"%s/%s.lnk", last_group, argv[0]);
|
2017-12-01 17:08:13 +01:00
|
|
|
|
|
|
|
ret = DeleteFileW(name);
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(name);
|
2017-12-01 17:08:13 +01:00
|
|
|
|
|
|
|
if (!ret) return DDE_FNOTPROCESSED;
|
|
|
|
}
|
2021-09-20 12:58:52 +02:00
|
|
|
else if (!wcsicmp(command, L"ExitProgman"))
|
2017-12-02 03:52:50 +01:00
|
|
|
{
|
|
|
|
/* do nothing */
|
|
|
|
}
|
2017-11-30 00:00:46 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("unhandled command %s\n", debugstr_w(command));
|
|
|
|
return DDE_FNOTPROCESSED;
|
|
|
|
}
|
|
|
|
return DDE_FACK;
|
2017-11-30 00:00:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static DWORD parse_dde_command(HSZ hszTopic, WCHAR *command)
|
2005-06-30 22:45:57 +02:00
|
|
|
{
|
2017-11-30 00:00:45 +01:00
|
|
|
WCHAR *original = command;
|
|
|
|
WCHAR *opcode = NULL, **argv = NULL, *p;
|
|
|
|
int argc = 0, i;
|
|
|
|
DWORD ret = DDE_FACK;
|
2005-06-30 22:45:57 +02:00
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
while (*command == ' ') command++;
|
2005-06-30 22:45:57 +02:00
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
if (*command != '[') goto error;
|
|
|
|
while (*command == '[')
|
|
|
|
{
|
|
|
|
argc = 0;
|
2018-02-22 08:43:28 +01:00
|
|
|
argv = heap_alloc(sizeof(*argv));
|
2017-11-30 00:00:45 +01:00
|
|
|
|
|
|
|
command++;
|
|
|
|
while (*command == ' ') command++;
|
2021-09-20 12:58:52 +02:00
|
|
|
if (!(p = wcspbrk(command, L" ,()[]\""))) goto error;
|
2017-11-30 00:00:45 +01:00
|
|
|
|
|
|
|
opcode = strndupW(command, p - command);
|
|
|
|
|
|
|
|
command = p;
|
|
|
|
while (*command == ' ') command++;
|
|
|
|
if (*command == '(')
|
|
|
|
{
|
|
|
|
command++;
|
|
|
|
|
|
|
|
while (*command != ')')
|
|
|
|
{
|
|
|
|
while (*command == ' ') command++;
|
|
|
|
if (*command == '"')
|
|
|
|
{
|
|
|
|
command++;
|
2021-09-17 17:16:11 +02:00
|
|
|
if (!(p = wcschr(command, '"'))) goto error;
|
2017-11-30 00:00:45 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-20 12:58:52 +02:00
|
|
|
if (!(p = wcspbrk(command, L",()[]"))) goto error;
|
2017-11-30 00:00:45 +01:00
|
|
|
while (p[-1] == ' ') p--;
|
|
|
|
}
|
|
|
|
|
|
|
|
argc++;
|
2018-02-22 08:43:28 +01:00
|
|
|
argv = heap_realloc(argv, argc * sizeof(*argv));
|
2017-11-30 00:00:45 +01:00
|
|
|
argv[argc-1] = strndupW(command, p - command);
|
|
|
|
|
|
|
|
command = p;
|
|
|
|
if (*command == '"') command++;
|
|
|
|
while (*command == ' ') command++;
|
|
|
|
if (*command == ',') command++;
|
|
|
|
else if (*command != ')') goto error;
|
|
|
|
}
|
|
|
|
command++;
|
|
|
|
|
|
|
|
while (*command == ' ') command++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*command != ']') goto error;
|
|
|
|
command++;
|
|
|
|
while (*command == ' ') command++;
|
|
|
|
|
|
|
|
if (hszTopic == hszProgmanTopic)
|
|
|
|
ret = PROGMAN_OnExecute(opcode, argc, argv);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("unhandled topic %s, command %s\n", debugstr_hsz(hszTopic), debugstr_w(opcode));
|
|
|
|
ret = DDE_FNOTPROCESSED;
|
|
|
|
}
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(opcode);
|
|
|
|
for (i = 0; i < argc; i++) heap_free(argv[i]);
|
|
|
|
heap_free(argv);
|
2017-11-30 00:00:45 +01:00
|
|
|
|
|
|
|
if (ret == DDE_FNOTPROCESSED) break;
|
|
|
|
}
|
2005-06-30 22:45:57 +02:00
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
return ret;
|
2005-06-30 22:45:57 +02:00
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
error:
|
|
|
|
ERR("failed to parse command %s\n", debugstr_w(original));
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(opcode);
|
|
|
|
for (i = 0; i < argc; i++) heap_free(argv[i]);
|
|
|
|
heap_free(argv);
|
2005-06-30 22:45:57 +02:00
|
|
|
return DDE_FNOTPROCESSED;
|
|
|
|
}
|
|
|
|
|
2017-11-30 00:00:45 +01:00
|
|
|
static DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
|
|
|
|
{
|
|
|
|
WCHAR *command;
|
|
|
|
DWORD len;
|
|
|
|
DWORD ret;
|
|
|
|
|
|
|
|
len = DdeGetData(hdata, NULL, 0, 0);
|
|
|
|
if (!len) return DDE_FNOTPROCESSED;
|
2018-02-22 08:43:28 +01:00
|
|
|
command = heap_alloc(len);
|
2017-11-30 00:00:45 +01:00
|
|
|
DdeGetData(hdata, (BYTE *)command, len, 0);
|
|
|
|
|
|
|
|
TRACE("conv=%p topic=%s data=%s\n", hconv, debugstr_hsz(hszTopic), debugstr_w(command));
|
|
|
|
|
|
|
|
ret = parse_dde_command(hszTopic, command);
|
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(command);
|
2017-11-30 00:00:45 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2005-06-30 22:45:57 +02:00
|
|
|
static inline void Dde_OnDisconnect(HCONV hconv)
|
|
|
|
{
|
2010-06-17 16:08:06 +02:00
|
|
|
TRACE( "%p\n", hconv );
|
2005-06-30 22:45:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HDDEDATA CALLBACK DdeCallback(
|
|
|
|
UINT uType,
|
|
|
|
UINT uFmt,
|
|
|
|
HCONV hconv,
|
|
|
|
HSZ hsz1,
|
|
|
|
HSZ hsz2,
|
|
|
|
HDDEDATA hdata,
|
|
|
|
ULONG_PTR dwData1,
|
|
|
|
ULONG_PTR dwData2)
|
|
|
|
{
|
|
|
|
switch (uType)
|
|
|
|
{
|
|
|
|
case XTYP_CONNECT:
|
2005-09-02 13:32:17 +02:00
|
|
|
return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2);
|
2005-06-30 22:45:57 +02:00
|
|
|
case XTYP_CONNECT_CONFIRM:
|
|
|
|
Dde_OnConnectConfirm(hconv, hsz1, hsz2);
|
|
|
|
return NULL;
|
|
|
|
case XTYP_WILDCONNECT:
|
2005-09-02 13:32:17 +02:00
|
|
|
return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2);
|
2005-06-30 22:45:57 +02:00
|
|
|
case XTYP_REQUEST:
|
2008-01-19 17:54:24 +01:00
|
|
|
return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
|
2005-06-30 22:45:57 +02:00
|
|
|
case XTYP_EXECUTE:
|
2005-09-02 13:32:17 +02:00
|
|
|
return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata);
|
2005-06-30 22:45:57 +02:00
|
|
|
case XTYP_DISCONNECT:
|
|
|
|
Dde_OnDisconnect(hconv);
|
|
|
|
return NULL;
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ShellDDEInit (SHELL32.@)
|
|
|
|
*
|
|
|
|
* Registers the Shell DDE services with the system so that applications
|
|
|
|
* can use them.
|
|
|
|
*
|
|
|
|
* PARAMS
|
2011-08-24 15:28:14 +02:00
|
|
|
* bInit [I] TRUE to initialize the services, FALSE to uninitialize.
|
2005-06-30 22:45:57 +02:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Nothing.
|
|
|
|
*/
|
|
|
|
void WINAPI ShellDDEInit(BOOL bInit)
|
|
|
|
{
|
|
|
|
TRACE("bInit = %s\n", bInit ? "TRUE" : "FALSE");
|
|
|
|
|
|
|
|
if (bInit)
|
|
|
|
{
|
|
|
|
DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
|
|
|
|
|
2021-09-20 12:58:52 +02:00
|
|
|
hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, L"Progman", CP_WINUNICODE);
|
|
|
|
hszProgmanService = DdeCreateStringHandleW(dwDDEInst, L"Progman", CP_WINUNICODE);
|
|
|
|
hszAsterisk = DdeCreateStringHandleW(dwDDEInst, L"*", CP_WINUNICODE);
|
|
|
|
hszShell = DdeCreateStringHandleW(dwDDEInst, L"Shell", CP_WINUNICODE);
|
|
|
|
hszAppProperties = DdeCreateStringHandleW(dwDDEInst, L"AppProperties", CP_WINUNICODE);
|
|
|
|
hszFolders = DdeCreateStringHandleW(dwDDEInst, L"Folders", CP_WINUNICODE);
|
|
|
|
hszGroups = DdeCreateStringHandleW(dwDDEInst, L"Groups", CP_WINUNICODE);
|
2005-06-30 22:45:57 +02:00
|
|
|
|
|
|
|
DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER);
|
|
|
|
DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER);
|
|
|
|
DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* unregister all services */
|
|
|
|
DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
|
|
|
|
|
|
|
|
DdeFreeStringHandle(dwDDEInst, hszFolders);
|
|
|
|
DdeFreeStringHandle(dwDDEInst, hszAppProperties);
|
|
|
|
DdeFreeStringHandle(dwDDEInst, hszShell);
|
|
|
|
DdeFreeStringHandle(dwDDEInst, hszAsterisk);
|
|
|
|
DdeFreeStringHandle(dwDDEInst, hszProgmanService);
|
|
|
|
DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
|
|
|
|
|
|
|
|
DdeUninitialize(dwDDEInst);
|
|
|
|
}
|
|
|
|
}
|