2009-11-03 04:23:16 +01:00
|
|
|
/*
|
|
|
|
* Unit test of the Program Manager DDE Interfaces
|
|
|
|
*
|
|
|
|
* Copyright 2009 Mikey Alexander
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* DDE Program Manager Tests
|
|
|
|
* - Covers basic CreateGroup, ShowGroup, DeleteGroup, AddItem, and DeleteItem
|
|
|
|
* functionality
|
|
|
|
* - Todo: Handle CommonGroupFlag
|
|
|
|
* Better AddItem Tests (Lots of parameters to test)
|
|
|
|
* Tests for Invalid Characters in Names / Invalid Parameters
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <wine/test.h>
|
|
|
|
#include <winbase.h>
|
|
|
|
#include "dde.h"
|
|
|
|
#include "ddeml.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
|
2009-12-08 14:54:53 +01:00
|
|
|
static HRESULT (WINAPI *pSHGetLocalizedName)(LPCWSTR, LPWSTR, UINT, int *);
|
2009-11-11 09:09:29 +01:00
|
|
|
|
|
|
|
static void init_function_pointers(void)
|
|
|
|
{
|
|
|
|
HMODULE hmod;
|
|
|
|
|
|
|
|
hmod = GetModuleHandleA("shell32.dll");
|
2009-12-08 14:54:53 +01:00
|
|
|
pSHGetLocalizedName = (void*)GetProcAddress(hmod, "SHGetLocalizedName");
|
2009-11-11 09:09:29 +01:00
|
|
|
}
|
|
|
|
|
2009-12-08 15:15:10 +01:00
|
|
|
static BOOL use_common(void)
|
|
|
|
{
|
|
|
|
HMODULE hmod;
|
|
|
|
static BOOL (WINAPI *pIsNTAdmin)(DWORD, LPDWORD);
|
|
|
|
|
|
|
|
/* IsNTAdmin() is available on all platforms. */
|
|
|
|
hmod = LoadLibraryA("advpack.dll");
|
|
|
|
pIsNTAdmin = (void*)GetProcAddress(hmod, "IsNTAdmin");
|
|
|
|
|
|
|
|
if (!pIsNTAdmin(0, NULL))
|
|
|
|
{
|
|
|
|
/* We are definitely not an administrator */
|
|
|
|
FreeLibrary(hmod);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
FreeLibrary(hmod);
|
|
|
|
|
|
|
|
/* If we end up here we are on NT4+ as Win9x and WinMe don't have the
|
|
|
|
* notion of administrators (as we need it).
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* As of Vista we should always use the users directory. Tests with the
|
|
|
|
* real Administrator account on Windows 7 proved this.
|
|
|
|
*
|
|
|
|
* FIXME: We need a better way of identifying Vista+ as currently this check
|
|
|
|
* also covers Wine and we don't know yet which behavior we want to follow.
|
|
|
|
*/
|
|
|
|
if (pSHGetLocalizedName)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-01-19 16:02:26 +01:00
|
|
|
static BOOL full_title(void)
|
|
|
|
{
|
|
|
|
CABINETSTATE cs;
|
|
|
|
|
|
|
|
memset(&cs, 0, sizeof(cs));
|
2018-01-09 05:48:52 +01:00
|
|
|
ReadCabinetState(&cs, sizeof(cs));
|
2010-01-19 16:02:26 +01:00
|
|
|
|
|
|
|
return (cs.fFullPathTitle == -1);
|
|
|
|
}
|
|
|
|
|
2009-12-08 15:15:10 +01:00
|
|
|
static char ProgramsDir[MAX_PATH];
|
2009-11-26 19:17:25 +01:00
|
|
|
|
2009-11-24 17:06:45 +01:00
|
|
|
static void init_strings(void)
|
|
|
|
{
|
2009-12-08 15:15:10 +01:00
|
|
|
char commonprograms[MAX_PATH];
|
|
|
|
char programs[MAX_PATH];
|
|
|
|
|
2018-01-09 05:48:52 +01:00
|
|
|
SHGetSpecialFolderPathA(NULL, programs, CSIDL_PROGRAMS, FALSE);
|
|
|
|
SHGetSpecialFolderPathA(NULL, commonprograms, CSIDL_COMMON_PROGRAMS, FALSE);
|
2009-11-26 19:17:25 +01:00
|
|
|
|
2009-12-08 15:15:10 +01:00
|
|
|
/* ProgramsDir on Vista+ is always the users one (CSIDL_PROGRAMS). Before Vista
|
|
|
|
* it depends on whether the user is an administrator (CSIDL_COMMON_PROGRAMS) or
|
|
|
|
* not (CSIDL_PROGRAMS).
|
|
|
|
*/
|
|
|
|
if (use_common())
|
|
|
|
lstrcpyA(ProgramsDir, commonprograms);
|
|
|
|
else
|
|
|
|
lstrcpyA(ProgramsDir, programs);
|
2009-11-24 17:06:45 +01:00
|
|
|
}
|
|
|
|
|
2009-11-03 04:23:16 +01:00
|
|
|
static HDDEDATA CALLBACK DdeCallback(UINT type, UINT format, HCONV hConv, HSZ hsz1, HSZ hsz2,
|
|
|
|
HDDEDATA hDDEData, ULONG_PTR data1, ULONG_PTR data2)
|
|
|
|
{
|
|
|
|
trace("Callback: type=%i, format=%i\n", type, format);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
static UINT dde_execute(DWORD instance, HCONV hconv, const char *command_str)
|
2009-11-03 04:23:16 +01:00
|
|
|
{
|
2017-11-29 06:52:04 +01:00
|
|
|
HDDEDATA command, hdata;
|
|
|
|
DWORD result;
|
|
|
|
UINT ret;
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
command = DdeCreateDataHandle(instance, (BYTE *)command_str, strlen(command_str)+1, 0, 0, 0, 0);
|
|
|
|
ok(command != NULL, "DdeCreateDataHandle() failed: %u\n", DdeGetLastError(instance));
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
hdata = DdeClientTransaction((BYTE *)command, -1, hconv, 0, 0, XTYP_EXECUTE, 2000, &result);
|
|
|
|
ret = DdeGetLastError(instance);
|
|
|
|
/* PROGMAN always returns 1 on success */
|
|
|
|
ok((UINT_PTR)hdata == !ret, "expected %u, got %p\n", !ret, hdata);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
return ret;
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|
|
|
|
|
2017-12-02 03:52:51 +01:00
|
|
|
static char *dde_request(DWORD instance, HCONV hconv, const char *request_str)
|
|
|
|
{
|
|
|
|
static char data[2000];
|
|
|
|
HDDEDATA hdata;
|
|
|
|
HSZ item;
|
|
|
|
DWORD result;
|
|
|
|
|
|
|
|
item = DdeCreateStringHandleA(instance, request_str, CP_WINANSI);
|
|
|
|
ok(item != NULL, "DdeCreateStringHandle() failed: %u\n", DdeGetLastError(instance));
|
|
|
|
|
|
|
|
hdata = DdeClientTransaction(NULL, -1, hconv, item, CF_TEXT, XTYP_REQUEST, 2000, &result);
|
|
|
|
if (hdata == NULL) return NULL;
|
|
|
|
|
|
|
|
DdeGetData(hdata, (BYTE *)data, 2000, 0);
|
|
|
|
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
static BOOL check_window_exists(const char *name)
|
2009-11-03 04:23:16 +01:00
|
|
|
{
|
2017-12-01 17:08:14 +01:00
|
|
|
char title[MAX_PATH];
|
2009-11-03 04:23:16 +01:00
|
|
|
HWND window = NULL;
|
|
|
|
int i;
|
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
if (full_title())
|
|
|
|
{
|
|
|
|
strcpy(title, ProgramsDir);
|
|
|
|
strcat(title, "\\");
|
|
|
|
strcat(title, name);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
strcpy(title, name);
|
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
for (i = 0; i < 20; i++)
|
2009-11-03 04:23:16 +01:00
|
|
|
{
|
2019-01-10 19:58:48 +01:00
|
|
|
Sleep(100 * i);
|
2017-12-01 17:08:14 +01:00
|
|
|
if ((window = FindWindowA("ExplorerWClass", title)) ||
|
|
|
|
(window = FindWindowA("CabinetWClass", title)))
|
2017-11-29 06:52:04 +01:00
|
|
|
{
|
|
|
|
SendMessageA(window, WM_SYSCOMMAND, SC_CLOSE, 0);
|
|
|
|
break;
|
|
|
|
}
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
return (window != NULL);
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
static BOOL check_exists(const char *name)
|
2009-11-03 04:23:16 +01:00
|
|
|
{
|
2009-11-27 16:28:57 +01:00
|
|
|
char path[MAX_PATH];
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
strcpy(path, ProgramsDir);
|
|
|
|
strcat(path, "\\");
|
|
|
|
strcat(path, name);
|
|
|
|
return GetFileAttributesA(path) != INVALID_FILE_ATTRIBUTES;
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
static void test_parser(DWORD instance, HCONV hConv)
|
2009-11-03 04:23:16 +01:00
|
|
|
{
|
|
|
|
UINT error;
|
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
/* Invalid Command */
|
|
|
|
error = dde_execute(instance, hConv, "[InvalidCommand()]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
/* test parsing */
|
|
|
|
error = dde_execute(instance, hConv, "");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "CreateGroup");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[CreateGroup");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[CreateGroup]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[CreateGroup()]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[cREATEgROUP(test)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("test"), "directory not created\n");
|
|
|
|
ok(check_window_exists("test"), "window not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,foobar)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("test/foobar.lnk"), "link not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,foo bar)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("test/foo bar.lnk"), "link not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,a[b,c]d)]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,\"a[b,c]d\")]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("test/a[b,c]d.lnk"), "link not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, " [ AddItem ( notepad , test ) ] ");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("test/test.lnk"), "link not created\n");
|
2017-11-29 06:52:04 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,one)][AddItem(notepad,two)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("test/one.lnk"), "link not created\n");
|
|
|
|
ok(check_exists("test/two.lnk"), "link not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[FakeCommand(test)][DeleteGroup(test)]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
ok(check_exists("test"), "directory should exist\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[DeleteGroup(test)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(!check_exists("test"), "directory should not exist\n");
|
2017-12-02 03:52:50 +01:00
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[ExitProgman()]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[ExitProgman]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
}
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
/* 1st set of tests */
|
|
|
|
static void test_progman_dde(DWORD instance, HCONV hConv)
|
|
|
|
{
|
|
|
|
UINT error;
|
|
|
|
|
|
|
|
/* test creating and deleting groups and items */
|
2017-11-29 06:52:04 +01:00
|
|
|
error = dde_execute(instance, hConv, "[CreateGroup(Group1)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group1"), "directory not created\n");
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_window_exists("Group1"), "window not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[AddItem]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(test)]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad.exe)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group1/notepad.lnk"), "link not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[DeleteItem(notepad.exe)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[DeleteItem(notepad)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(!check_exists("Group1/notepad.lnk"), "link should not exist\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[DeleteItem(notepad)]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group1/notepad.lnk"), "link not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
|
|
|
|
/* XP allows any valid path even if it does not exist; Vista+ requires that
|
|
|
|
* the path both exist and be a file (directories are invalid). */
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(C:\\windows\\system.ini)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group1/system.lnk"), "link not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,test1)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("Group1/test1.lnk"), "link not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[DeleteItem(test1)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(!check_exists("Group1/test1.lnk"), "link should not exist\n");
|
|
|
|
|
2017-12-02 03:52:49 +01:00
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,test1)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group1/test1.lnk"), "link not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[ReplaceItem(test1)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(!check_exists("Group1/test1.lnk"), "link should not exist\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(regedit)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group1/regedit.lnk"), "link not created\n");
|
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
/* test ShowGroup() and test which group an item gets added to */
|
|
|
|
error = dde_execute(instance, hConv, "[ShowGroup(Group1)]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
2009-11-27 16:27:10 +01:00
|
|
|
|
2017-11-29 06:52:04 +01:00
|
|
|
error = dde_execute(instance, hConv, "[ShowGroup(Group1, 0)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_window_exists("Group1"), "window not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[CreateGroup(Group2)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("Group2"), "directory not created\n");
|
|
|
|
ok(check_window_exists("Group2"), "window not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,test2)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group2/test2.lnk"), "link not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[ShowGroup(Group1, 0)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_window_exists("Group1"), "window not created\n");
|
2009-11-27 16:27:10 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,test3)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("Group1/test3.lnk"), "link not created\n");
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[DeleteGroup(Group1)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(!check_exists("Group1"), "directory should not exist\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[DeleteGroup(Group1)]");
|
|
|
|
ok(error == DMLERR_NOTPROCESSED, "expected DMLERR_NOTPROCESSED, got %u\n", error);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
error = dde_execute(instance, hConv, "[ShowGroup(Group2, 0)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_window_exists("Group2"), "window not created\n");
|
2017-12-02 03:52:50 +01:00
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[ExitProgman(1)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad,test4)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(check_exists("Group2/test4.lnk"), "link not created\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 2nd set of tests - 2nd connection */
|
2017-11-29 06:52:04 +01:00
|
|
|
static void test_progman_dde2(DWORD instance, HCONV hConv)
|
2009-11-03 04:23:16 +01:00
|
|
|
{
|
2017-11-29 06:52:04 +01:00
|
|
|
UINT error;
|
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
/* last open group is retained across connections */
|
|
|
|
error = dde_execute(instance, hConv, "[AddItem(notepad)]");
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
2017-12-01 17:08:14 +01:00
|
|
|
ok(check_exists("Group2/notepad.lnk"), "link not created\n");
|
2017-11-29 06:52:04 +01:00
|
|
|
|
|
|
|
error = dde_execute(instance, hConv, "[DeleteGroup(Group2)]");
|
|
|
|
ok(error == DMLERR_NO_ERROR, "expected DMLERR_NO_ERROR, got %u\n", error);
|
|
|
|
ok(!check_exists("Group2"), "directory should not exist\n");
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|
|
|
|
|
2017-12-02 03:52:51 +01:00
|
|
|
static BOOL check_in_programs_list(const char *list, const char *group)
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (!strncmp(list, group, strlen(group)) && list[strlen(group)] == '\r')
|
|
|
|
return TRUE;
|
|
|
|
if (!(list = strchr(list, '\r'))) break;
|
|
|
|
list += 2;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_request_groups(DWORD instance, HCONV hconv)
|
|
|
|
{
|
|
|
|
char *list;
|
|
|
|
char programs[MAX_PATH];
|
|
|
|
WIN32_FIND_DATAA finddata;
|
|
|
|
HANDLE hfind;
|
|
|
|
|
|
|
|
list = dde_request(instance, hconv, "Groups");
|
|
|
|
ok(list != NULL, "request failed: %u\n", DdeGetLastError(instance));
|
|
|
|
strcpy(programs, ProgramsDir);
|
|
|
|
strcat(programs, "/*");
|
|
|
|
hfind = FindFirstFileA(programs, &finddata);
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && finddata.cFileName[0] != '.')
|
|
|
|
{
|
|
|
|
ok(check_in_programs_list(list, finddata.cFileName),
|
|
|
|
"directory '%s' missing from group list\n", finddata.cFileName);
|
|
|
|
}
|
|
|
|
} while (FindNextFileA(hfind, &finddata));
|
2018-01-05 14:23:26 +01:00
|
|
|
FindClose(hfind);
|
2017-12-02 03:52:51 +01:00
|
|
|
}
|
|
|
|
|
2009-11-03 04:23:16 +01:00
|
|
|
START_TEST(progman_dde)
|
|
|
|
{
|
|
|
|
DWORD instance = 0;
|
|
|
|
UINT err;
|
|
|
|
HSZ hszProgman;
|
|
|
|
HCONV hConv;
|
2017-12-30 19:57:47 +01:00
|
|
|
BOOL ret;
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2009-11-11 09:09:29 +01:00
|
|
|
init_function_pointers();
|
2009-11-24 17:06:45 +01:00
|
|
|
init_strings();
|
2009-11-11 09:09:29 +01:00
|
|
|
|
2009-11-03 04:23:16 +01:00
|
|
|
/* Initialize DDE Instance */
|
2013-10-26 21:10:26 +02:00
|
|
|
err = DdeInitializeA(&instance, DdeCallback, APPCMD_CLIENTONLY, 0);
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(err == DMLERR_NO_ERROR, "DdeInitialize() failed: %u\n", err);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
|
|
|
/* Create Connection */
|
2013-10-26 21:10:26 +02:00
|
|
|
hszProgman = DdeCreateStringHandleA(instance, "PROGMAN", CP_WINANSI);
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(hszProgman != NULL, "DdeCreateStringHandle() failed: %u\n", DdeGetLastError(instance));
|
2009-11-03 04:23:16 +01:00
|
|
|
hConv = DdeConnect(instance, hszProgman, hszProgman, NULL);
|
2017-12-30 19:57:47 +01:00
|
|
|
ret = DdeFreeStringHandle(instance, hszProgman);
|
|
|
|
ok(ret, "DdeFreeStringHandle() failed: %u\n", DdeGetLastError(instance));
|
2009-11-14 17:23:14 +01:00
|
|
|
/* Seeing failures on early versions of Windows Connecting to progman, exit if connection fails */
|
|
|
|
if (hConv == NULL)
|
|
|
|
{
|
|
|
|
ok (DdeUninitialize(instance), "DdeUninitialize failed\n");
|
|
|
|
return;
|
|
|
|
}
|
2009-11-03 04:23:16 +01:00
|
|
|
|
2017-12-01 17:08:14 +01:00
|
|
|
test_parser(instance, hConv);
|
2017-11-29 06:52:04 +01:00
|
|
|
test_progman_dde(instance, hConv);
|
2017-12-02 03:52:51 +01:00
|
|
|
test_request_groups(instance, hConv);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
|
|
|
/* Cleanup & Exit */
|
2017-12-30 19:57:47 +01:00
|
|
|
ret = DdeDisconnect(hConv);
|
2019-12-09 09:45:11 +01:00
|
|
|
ok(ret, "DdeDisconnect() failed: %u\n", DdeGetLastError(instance));
|
2017-12-30 19:57:47 +01:00
|
|
|
ret = DdeUninitialize(instance);
|
|
|
|
ok(ret, "DdeUninitialize() failed: %u\n", DdeGetLastError(instance));
|
2009-11-03 04:23:16 +01:00
|
|
|
|
|
|
|
/* 2nd Instance (Followup Tests) */
|
|
|
|
/* Initialize DDE Instance */
|
|
|
|
instance = 0;
|
2013-10-26 21:10:26 +02:00
|
|
|
err = DdeInitializeA(&instance, DdeCallback, APPCMD_CLIENTONLY, 0);
|
2017-11-29 06:52:04 +01:00
|
|
|
ok (err == DMLERR_NO_ERROR, "DdeInitialize() failed: %u\n", err);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
|
|
|
/* Create Connection */
|
2013-10-26 21:10:26 +02:00
|
|
|
hszProgman = DdeCreateStringHandleA(instance, "PROGMAN", CP_WINANSI);
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(hszProgman != NULL, "DdeCreateStringHandle() failed: %u\n", DdeGetLastError(instance));
|
2009-11-03 04:23:16 +01:00
|
|
|
hConv = DdeConnect(instance, hszProgman, hszProgman, NULL);
|
2017-11-29 06:52:04 +01:00
|
|
|
ok(hConv != NULL, "DdeConnect() failed: %u\n", DdeGetLastError(instance));
|
2017-12-30 19:57:47 +01:00
|
|
|
ret = DdeFreeStringHandle(instance, hszProgman);
|
|
|
|
ok(ret, "DdeFreeStringHandle() failed: %u\n", DdeGetLastError(instance));
|
2009-11-03 04:23:16 +01:00
|
|
|
|
|
|
|
/* Run Tests */
|
2017-11-29 06:52:04 +01:00
|
|
|
test_progman_dde2(instance, hConv);
|
2009-11-03 04:23:16 +01:00
|
|
|
|
|
|
|
/* Cleanup & Exit */
|
2017-12-30 19:57:47 +01:00
|
|
|
ret = DdeDisconnect(hConv);
|
2019-12-09 09:45:11 +01:00
|
|
|
ok(ret, "DdeDisconnect() failed: %u\n", DdeGetLastError(instance));
|
2017-12-30 19:57:47 +01:00
|
|
|
ret = DdeUninitialize(instance);
|
|
|
|
ok(ret, "DdeUninitialize() failed: %u\n", DdeGetLastError(instance));
|
2009-11-03 04:23:16 +01:00
|
|
|
}
|