4 * Copyright 2004 Robert Shearman
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/debug.h"
31 WINE_DEFAULT_DEBUG_CHANNEL(shell);
34 static HSZ hszProgmanTopic;
35 static HSZ hszProgmanService;
36 static HSZ hszAsterisk;
38 static HSZ hszAppProperties;
39 static HSZ hszFolders;
42 static DWORD dwDDEInst;
44 static const char *debugstr_hsz( HSZ hsz )
47 if (!DdeQueryStringW( dwDDEInst, hsz, buffer, sizeof(buffer)/sizeof(WCHAR), CP_WINUNICODE ))
49 return debugstr_w( buffer );
52 static inline BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService)
54 if ((hszTopic == hszProgmanTopic) && (hszService == hszProgmanService))
56 if ((hszTopic == hszProgmanTopic) && (hszService == hszAppProperties))
58 if ((hszTopic == hszShell) && (hszService == hszFolders))
60 if ((hszTopic == hszShell) && (hszService == hszAppProperties))
65 static inline void Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService)
67 TRACE( "%p %s %s\n", hconv, debugstr_hsz(hszTopic), debugstr_hsz(hszService) );
70 static inline BOOL Dde_OnWildConnect(HSZ hszTopic, HSZ hszService)
76 static inline HDDEDATA Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic,
79 if (hszTopic == hszProgmanTopic && hszItem == hszGroups && uFmt == CF_TEXT)
81 static BYTE groups_data[] = "Accessories\r\nStartup\r\n";
82 FIXME( "returning fake program groups list\n" );
83 return DdeCreateDataHandle( dwDDEInst, groups_data, sizeof(groups_data), 0, hszGroups, uFmt, 0 );
85 else if (hszTopic == hszProgmanTopic && hszItem == hszProgmanService && uFmt == CF_TEXT)
87 static BYTE groups_data[] = "\r\n";
88 FIXME( "returning empty groups list\n" );
89 /* This is a workaround for an application which expects some data
90 * and cannot handle NULL. */
91 return DdeCreateDataHandle( dwDDEInst, groups_data, sizeof(groups_data), 0, hszProgmanService, uFmt, 0 );
93 FIXME( "%u %p %s %s: stub\n", uFmt, hconv, debugstr_hsz(hszTopic), debugstr_hsz(hszItem) );
97 static inline DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
101 pszCommand = (WCHAR *)DdeAccessData(hdata, NULL);
103 return DDE_FNOTPROCESSED;
105 FIXME("stub: %s %s\n", debugstr_hsz(hszTopic), debugstr_w(pszCommand));
107 DdeUnaccessData(hdata);
109 return DDE_FNOTPROCESSED;
112 static inline void Dde_OnDisconnect(HCONV hconv)
114 TRACE( "%p\n", hconv );
117 static HDDEDATA CALLBACK DdeCallback(
130 return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2);
131 case XTYP_CONNECT_CONFIRM:
132 Dde_OnConnectConfirm(hconv, hsz1, hsz2);
134 case XTYP_WILDCONNECT:
135 return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2);
137 return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
139 return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata);
140 case XTYP_DISCONNECT:
141 Dde_OnDisconnect(hconv);
148 /*************************************************************************
149 * ShellDDEInit (SHELL32.@)
151 * Registers the Shell DDE services with the system so that applications
155 * bInit [I] TRUE to initialize the services, FALSE to uninitialize.
160 void WINAPI ShellDDEInit(BOOL bInit)
162 TRACE("bInit = %s\n", bInit ? "TRUE" : "FALSE");
166 static const WCHAR wszProgman[] = {'P','r','o','g','m','a','n',0};
167 static const WCHAR wszAsterisk[] = {'*',0};
168 static const WCHAR wszShell[] = {'S','h','e','l','l',0};
169 static const WCHAR wszAppProperties[] =
170 {'A','p','p','P','r','o','p','e','r','t','i','e','s',0};
171 static const WCHAR wszFolders[] = {'F','o','l','d','e','r','s',0};
172 static const WCHAR wszGroups[] = {'G','r','o','u','p','s',0};
174 DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
176 hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE);
177 hszProgmanService = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE);
178 hszAsterisk = DdeCreateStringHandleW(dwDDEInst, wszAsterisk, CP_WINUNICODE);
179 hszShell = DdeCreateStringHandleW(dwDDEInst, wszShell, CP_WINUNICODE);
180 hszAppProperties = DdeCreateStringHandleW(dwDDEInst, wszAppProperties, CP_WINUNICODE);
181 hszFolders = DdeCreateStringHandleW(dwDDEInst, wszFolders, CP_WINUNICODE);
182 hszGroups = DdeCreateStringHandleW(dwDDEInst, wszGroups, CP_WINUNICODE);
184 DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER);
185 DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER);
186 DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER);
190 /* unregister all services */
191 DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
193 DdeFreeStringHandle(dwDDEInst, hszFolders);
194 DdeFreeStringHandle(dwDDEInst, hszAppProperties);
195 DdeFreeStringHandle(dwDDEInst, hszShell);
196 DdeFreeStringHandle(dwDDEInst, hszAsterisk);
197 DdeFreeStringHandle(dwDDEInst, hszProgmanService);
198 DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
200 DdeUninitialize(dwDDEInst);