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 FIXME( "%u %p %s %s: stub\n", uFmt
, hconv
, debugstr_hsz(hszTopic
), debugstr_hsz(hszItem
) );
89 static inline DWORD
Dde_OnExecute(HCONV hconv
, HSZ hszTopic
, HDDEDATA hdata
)
93 pszCommand
= DdeAccessData(hdata
, NULL
);
95 return DDE_FNOTPROCESSED
;
97 FIXME("stub: %s %s\n", debugstr_hsz(hszTopic
), pszCommand
);
99 DdeUnaccessData(hdata
);
101 return DDE_FNOTPROCESSED
;
104 static inline void Dde_OnDisconnect(HCONV hconv
)
106 TRACE( "%p\n", hconv
);
109 static HDDEDATA CALLBACK
DdeCallback(
122 return (HDDEDATA
)(DWORD_PTR
)Dde_OnConnect(hsz1
, hsz2
);
123 case XTYP_CONNECT_CONFIRM
:
124 Dde_OnConnectConfirm(hconv
, hsz1
, hsz2
);
126 case XTYP_WILDCONNECT
:
127 return (HDDEDATA
)(DWORD_PTR
)Dde_OnWildConnect(hsz1
, hsz2
);
129 return Dde_OnRequest(uFmt
, hconv
, hsz1
, hsz2
);
131 return (HDDEDATA
)(DWORD_PTR
)Dde_OnExecute(hconv
, hsz1
, hdata
);
132 case XTYP_DISCONNECT
:
133 Dde_OnDisconnect(hconv
);
140 /*************************************************************************
141 * ShellDDEInit (SHELL32.@)
143 * Registers the Shell DDE services with the system so that applications
147 * bInit [I] TRUE to initialize the services, FALSE to uninitalize.
152 void WINAPI
ShellDDEInit(BOOL bInit
)
154 TRACE("bInit = %s\n", bInit
? "TRUE" : "FALSE");
158 static const WCHAR wszProgman
[] = {'P','r','o','g','m','a','n',0};
159 static const WCHAR wszAsterisk
[] = {'*',0};
160 static const WCHAR wszShell
[] = {'S','h','e','l','l',0};
161 static const WCHAR wszAppProperties
[] =
162 {'A','p','p','P','r','o','p','e','r','t','i','e','s',0};
163 static const WCHAR wszFolders
[] = {'F','o','l','d','e','r','s',0};
164 static const WCHAR wszGroups
[] = {'G','r','o','u','p','s',0};
166 DdeInitializeW(&dwDDEInst
, DdeCallback
, CBF_FAIL_ADVISES
| CBF_FAIL_POKES
, 0);
168 hszProgmanTopic
= DdeCreateStringHandleW(dwDDEInst
, wszProgman
, CP_WINUNICODE
);
169 hszProgmanService
= DdeCreateStringHandleW(dwDDEInst
, wszProgman
, CP_WINUNICODE
);
170 hszAsterisk
= DdeCreateStringHandleW(dwDDEInst
, wszAsterisk
, CP_WINUNICODE
);
171 hszShell
= DdeCreateStringHandleW(dwDDEInst
, wszShell
, CP_WINUNICODE
);
172 hszAppProperties
= DdeCreateStringHandleW(dwDDEInst
, wszAppProperties
, CP_WINUNICODE
);
173 hszFolders
= DdeCreateStringHandleW(dwDDEInst
, wszFolders
, CP_WINUNICODE
);
174 hszGroups
= DdeCreateStringHandleW(dwDDEInst
, wszGroups
, CP_WINUNICODE
);
176 DdeNameService(dwDDEInst
, hszFolders
, 0, DNS_REGISTER
);
177 DdeNameService(dwDDEInst
, hszProgmanService
, 0, DNS_REGISTER
);
178 DdeNameService(dwDDEInst
, hszShell
, 0, DNS_REGISTER
);
182 /* unregister all services */
183 DdeNameService(dwDDEInst
, 0, 0, DNS_UNREGISTER
);
185 DdeFreeStringHandle(dwDDEInst
, hszFolders
);
186 DdeFreeStringHandle(dwDDEInst
, hszAppProperties
);
187 DdeFreeStringHandle(dwDDEInst
, hszShell
);
188 DdeFreeStringHandle(dwDDEInst
, hszAsterisk
);
189 DdeFreeStringHandle(dwDDEInst
, hszProgmanService
);
190 DdeFreeStringHandle(dwDDEInst
, hszProgmanTopic
);
192 DdeUninitialize(dwDDEInst
);