winemenubuilder: Generate .png even for paletted icons.
[wine/multimedia.git] / dlls / shell32 / dde.c
blob129f753935fc020700bc13a0ec7990a28253068b
1 /*
2 * Shell DDE Handling
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
21 #include <stdarg.h>
23 #include "windef.h"
24 #include "winbase.h"
25 #include "ddeml.h"
26 #include "shellapi.h"
28 #include "wine/debug.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(shell);
32 /* String handles */
33 static HSZ hszProgmanTopic;
34 static HSZ hszProgmanService;
35 static HSZ hszAsterisk;
36 static HSZ hszShell;
37 static HSZ hszAppProperties;
38 static HSZ hszFolders;
39 /* DDE Instance ID */
40 static DWORD dwDDEInst;
43 static inline BOOL Dde_OnConnect(HSZ hszTopic, HSZ hszService)
45 if ((hszTopic == hszProgmanTopic) && (hszService == hszProgmanService))
46 return TRUE;
47 if ((hszTopic == hszProgmanTopic) && (hszService == hszAppProperties))
48 return TRUE;
49 if ((hszTopic == hszShell) && (hszService == hszFolders))
50 return TRUE;
51 if ((hszTopic == hszShell) && (hszService == hszAppProperties))
52 return TRUE;
53 return FALSE;
56 static inline void Dde_OnConnectConfirm(HCONV hconv, HSZ hszTopic, HSZ hszService)
58 FIXME("stub\n");
61 static inline BOOL Dde_OnWildConnect(HSZ hszTopic, HSZ hszService)
63 FIXME("stub\n");
64 return FALSE;
67 static inline HDDEDATA Dde_OnRequest(UINT uFmt, HCONV hconv, HSZ hszTopic,
68 HSZ hszItem)
70 FIXME("stub\n");
71 return NULL;
74 static inline DWORD Dde_OnExecute(HCONV hconv, HSZ hszTopic, HDDEDATA hdata)
76 BYTE * pszCommand;
78 pszCommand = DdeAccessData(hdata, NULL);
79 if (!pszCommand)
80 return DDE_FNOTPROCESSED;
82 FIXME("stub: %s\n", pszCommand);
84 DdeUnaccessData(hdata);
86 return DDE_FNOTPROCESSED;
89 static inline void Dde_OnDisconnect(HCONV hconv)
91 FIXME("stub\n");
94 static HDDEDATA CALLBACK DdeCallback(
95 UINT uType,
96 UINT uFmt,
97 HCONV hconv,
98 HSZ hsz1,
99 HSZ hsz2,
100 HDDEDATA hdata,
101 ULONG_PTR dwData1,
102 ULONG_PTR dwData2)
104 switch (uType)
106 case XTYP_CONNECT:
107 return (HDDEDATA)(DWORD_PTR)Dde_OnConnect(hsz1, hsz2);
108 case XTYP_CONNECT_CONFIRM:
109 Dde_OnConnectConfirm(hconv, hsz1, hsz2);
110 return NULL;
111 case XTYP_WILDCONNECT:
112 return (HDDEDATA)(DWORD_PTR)Dde_OnWildConnect(hsz1, hsz2);
113 case XTYP_REQUEST:
114 return Dde_OnRequest(uFmt, hconv, hsz1, hsz2);
115 case XTYP_EXECUTE:
116 return (HDDEDATA)(DWORD_PTR)Dde_OnExecute(hconv, hsz1, hdata);
117 case XTYP_DISCONNECT:
118 Dde_OnDisconnect(hconv);
119 return NULL;
120 default:
121 return NULL;
125 /*************************************************************************
126 * ShellDDEInit (SHELL32.@)
128 * Registers the Shell DDE services with the system so that applications
129 * can use them.
131 * PARAMS
132 * bInit [I] TRUE to initialize the services, FALSE to uninitalize.
134 * RETURNS
135 * Nothing.
137 void WINAPI ShellDDEInit(BOOL bInit)
139 TRACE("bInit = %s\n", bInit ? "TRUE" : "FALSE");
141 if (bInit)
143 static const WCHAR wszProgman[] = {'P','r','o','g','m','a','n',0};
144 static const WCHAR wszAsterisk[] = {'*',0};
145 static const WCHAR wszShell[] = {'S','h','e','l','l',0};
146 static const WCHAR wszAppProperties[] =
147 {'A','p','p','P','r','o','p','e','r','t','i','e','s',0};
148 static const WCHAR wszFolders[] = {'F','o','l','d','e','r','s',0};
150 DdeInitializeW(&dwDDEInst, DdeCallback, CBF_FAIL_ADVISES | CBF_FAIL_POKES, 0);
152 hszProgmanTopic = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE);
153 hszProgmanService = DdeCreateStringHandleW(dwDDEInst, wszProgman, CP_WINUNICODE);
154 hszAsterisk = DdeCreateStringHandleW(dwDDEInst, wszAsterisk, CP_WINUNICODE);
155 hszShell = DdeCreateStringHandleW(dwDDEInst, wszShell, CP_WINUNICODE);
156 hszAppProperties = DdeCreateStringHandleW(dwDDEInst, wszAppProperties, CP_WINUNICODE);
157 hszFolders = DdeCreateStringHandleW(dwDDEInst, wszFolders, CP_WINUNICODE);
159 DdeNameService(dwDDEInst, hszFolders, 0, DNS_REGISTER);
160 DdeNameService(dwDDEInst, hszProgmanService, 0, DNS_REGISTER);
161 DdeNameService(dwDDEInst, hszShell, 0, DNS_REGISTER);
163 else
165 /* unregister all services */
166 DdeNameService(dwDDEInst, 0, 0, DNS_UNREGISTER);
168 DdeFreeStringHandle(dwDDEInst, hszFolders);
169 DdeFreeStringHandle(dwDDEInst, hszAppProperties);
170 DdeFreeStringHandle(dwDDEInst, hszShell);
171 DdeFreeStringHandle(dwDDEInst, hszAsterisk);
172 DdeFreeStringHandle(dwDDEInst, hszProgmanService);
173 DdeFreeStringHandle(dwDDEInst, hszProgmanTopic);
175 DdeUninitialize(dwDDEInst);