Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

721 lines
20 KiB

  1. /*
  2. * assoc.c - Type association routines.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.h"
  7. #pragma hdrstop
  8. #include <mluisupp.h>
  9. #define _INTSHCUT_ /* for intshcut.h */
  10. #include <intshcut.h>
  11. #include <intshctp.h> /* ALL_???_FLAGS */
  12. #include "assoc.h"
  13. #include "extricon.h"
  14. #include "openas.h"
  15. #pragma warning(disable:4001) /* "single line comment" warning */
  16. #include "filetype.h"
  17. #include "resource.h"
  18. #pragma warning(default:4001) /* "single line comment" warning */
  19. #include "shlstock.h"
  20. #include "shlvalid.h"
  21. /* Global Constants
  22. *******************/
  23. #pragma data_seg(DATA_SEG_READ_ONLY)
  24. PUBLIC_DATA const HKEY g_hkeyURLProtocols = HKEY_CLASSES_ROOT;
  25. PUBLIC_DATA const HKEY g_hkeyMIMESettings = HKEY_CLASSES_ROOT;
  26. PUBLIC_DATA CCHAR g_cszURLProtocol[] = "URL Protocol";
  27. PUBLIC_DATA CCHAR g_cszContentType[] = "Content Type";
  28. PUBLIC_DATA CCHAR g_cszExtension[] = "Extension";
  29. #pragma data_seg()
  30. /* Module Constants
  31. *******************/
  32. #pragma data_seg(DATA_SEG_READ_ONLY)
  33. PRIVATE_DATA CCHAR s_cszShellOpenCmdSubKeyFmt[] = "%s\\shell\\open\\command";
  34. PRIVATE_DATA CCHAR s_cszAppOpenCmdFmt[] = "%s %%1";
  35. PRIVATE_DATA CCHAR s_cszDefaultIconSubKeyFmt[] = "%s\\DefaultIcon";
  36. PRIVATE_DATA CCHAR s_cszDefaultIcon[] = "url.dll,0";
  37. #pragma data_seg()
  38. /***************************** Private Functions *****************************/
  39. /*
  40. ** RegisterAppAsURLProtocolHandler()
  41. **
  42. ** Under HKEY_CLASSES_ROOT\url-protocol\shell\open\command, add default value =
  43. ** "c:\foo\bar.exe %1".
  44. **
  45. ** Arguments:
  46. **
  47. ** Returns:
  48. **
  49. ** Side Effects: none
  50. */
  51. PRIVATE_CODE BOOL RegisterAppAsURLProtocolHandler(PCSTR pcszProtocol,
  52. PCSTR pcszApp)
  53. {
  54. BOOL bResult = FALSE;
  55. DWORD dwcbShellOpenCmdSubKeyLen;
  56. PSTR pszShellOpenCmdSubKey;
  57. ASSERT(IS_VALID_STRING_PTR(pcszProtocol, CSTR));
  58. ASSERT(IS_VALID_STRING_PTR(pcszApp, CSTR));
  59. /* (+ 1) for null terminator. */
  60. dwcbShellOpenCmdSubKeyLen = sizeof(s_cszShellOpenCmdSubKeyFmt) + 1
  61. + lstrlen(pcszProtocol);
  62. if (AllocateMemory(dwcbShellOpenCmdSubKeyLen, &pszShellOpenCmdSubKey))
  63. {
  64. DWORD dwcbAppOpenCmdLen;
  65. PSTR pszAppOpenCmd;
  66. /* FEATURE: We should quote pcszApp here only if it contains spaces. */
  67. /* (+ 1) for null terminator. */
  68. dwcbAppOpenCmdLen = sizeof(s_cszAppOpenCmdFmt) + 1 + lstrlen(pcszApp);
  69. if (AllocateMemory(dwcbAppOpenCmdLen, &pszAppOpenCmd))
  70. {
  71. EVAL((DWORD)wsprintf(pszShellOpenCmdSubKey, s_cszShellOpenCmdSubKeyFmt,
  72. pcszProtocol) < dwcbShellOpenCmdSubKeyLen);
  73. EVAL((DWORD)wsprintf(pszAppOpenCmd, s_cszAppOpenCmdFmt, pcszApp)
  74. < dwcbAppOpenCmdLen);
  75. /* (+ 1) for null terminator. */
  76. bResult = (SetRegKeyValue(g_hkeyURLProtocols, pszShellOpenCmdSubKey,
  77. NULL, REG_SZ, (PCBYTE)pszAppOpenCmd,
  78. lstrlen(pszAppOpenCmd) + 1)
  79. == ERROR_SUCCESS);
  80. FreeMemory(pszShellOpenCmdSubKey);
  81. pszShellOpenCmdSubKey = NULL;
  82. }
  83. FreeMemory(pszAppOpenCmd);
  84. pszAppOpenCmd = NULL;
  85. }
  86. return(bResult);
  87. }
  88. /*
  89. ** RegisterURLProtocolDescription()
  90. **
  91. ** Under g_hkeyURLSettings\url-protocol, add default value =
  92. ** URL:Url-protocol Protocol.
  93. **
  94. ** Arguments:
  95. **
  96. ** Returns:
  97. **
  98. ** Side Effects: none
  99. */
  100. PRIVATE_CODE BOOL RegisterURLProtocolDescription(PCSTR pcszProtocol)
  101. {
  102. BOOL bResult = FALSE;
  103. PSTR pszProtocolCopy;
  104. ASSERT(IS_VALID_STRING_PTR(pcszProtocol, CSTR));
  105. if (StringCopy(pcszProtocol, &pszProtocolCopy))
  106. {
  107. char szDescriptionFmt[MAX_PATH_LEN];
  108. /*
  109. * Convert first character of protocol to upper case for description
  110. * string.
  111. */
  112. *pszProtocolCopy = (CHAR)PtrToUlong(CharUpper((LPSTR)(DWORD_PTR)*pszProtocolCopy));
  113. if (MLLoadStringA(IDS_URL_DESC_FORMAT,
  114. szDescriptionFmt, sizeof(szDescriptionFmt)))
  115. {
  116. char szDescription[MAX_PATH_LEN];
  117. if ((UINT)lstrlen(szDescriptionFmt) + (UINT)lstrlen(pszProtocolCopy)
  118. < sizeof(szDescription))
  119. {
  120. EVAL(wsprintf(szDescription, szDescriptionFmt, pszProtocolCopy)
  121. < sizeof(szDescription));
  122. /* (+ 1) for null terminator. */
  123. bResult = (SetRegKeyValue(g_hkeyURLProtocols, pcszProtocol,
  124. NULL, REG_SZ, (PCBYTE)szDescription,
  125. lstrlen(szDescription) + 1)
  126. == ERROR_SUCCESS);
  127. }
  128. }
  129. FreeMemory(pszProtocolCopy);
  130. pszProtocolCopy = NULL;
  131. }
  132. return(bResult);
  133. }
  134. /*
  135. ** RegisterURLProtocolFlags()
  136. **
  137. ** Under g_hkeyURLSettings\url-protocol, add EditFlags = FTA_Show.
  138. **
  139. ** Arguments:
  140. **
  141. ** Returns:
  142. **
  143. ** Side Effects: none
  144. */
  145. PRIVATE_CODE BOOL RegisterURLProtocolFlags(PCSTR pcszProtocol)
  146. {
  147. DWORD dwEditFlags = FTA_Show;
  148. ASSERT(IS_VALID_STRING_PTR(pcszProtocol, CSTR));
  149. /* FEATURE: What about preserving any existing EditFlags here? */
  150. /* (+ 1) for null terminator. */
  151. return(SetRegKeyValue(g_hkeyURLProtocols, pcszProtocol, g_cszEditFlags,
  152. REG_BINARY, (PCBYTE)&dwEditFlags, sizeof(dwEditFlags))
  153. == ERROR_SUCCESS);
  154. }
  155. /*
  156. ** RegisterURLProtocol()
  157. **
  158. ** Under g_hkeyURLSettings\url-protocol, add URL Protocol = "".
  159. **
  160. ** Arguments:
  161. **
  162. ** Returns:
  163. **
  164. ** Side Effects: none
  165. */
  166. PRIVATE_CODE BOOL RegisterURLProtocol(PCSTR pcszProtocol)
  167. {
  168. ASSERT(IS_VALID_STRING_PTR(pcszProtocol, CSTR));
  169. /* (+ 1) for null terminator. */
  170. return(SetRegKeyValue(g_hkeyURLProtocols, pcszProtocol, g_cszURLProtocol,
  171. REG_SZ, (PCBYTE)EMPTY_STRING,
  172. lstrlen(EMPTY_STRING) + 1) == ERROR_SUCCESS);
  173. }
  174. /*
  175. ** RegisterURLProtocolDefaultIcon()
  176. **
  177. ** Under g_hkeyURLSettings\url-protocol\DefaultIcon, add default value =
  178. ** app.exe,0.
  179. **
  180. ** Arguments:
  181. **
  182. ** Returns:
  183. **
  184. ** Side Effects: none
  185. */
  186. PRIVATE_CODE BOOL RegisterURLProtocolDefaultIcon(PCSTR pcszProtocol)
  187. {
  188. BOOL bResult = FALSE;
  189. DWORD dwcbDefaultIconSubKeyLen;
  190. PSTR pszDefaultIconSubKey;
  191. ASSERT(IS_VALID_STRING_PTR(pcszProtocol, CSTR));
  192. /* (+ 1) for null terminator. */
  193. dwcbDefaultIconSubKeyLen = sizeof(s_cszDefaultIconSubKeyFmt) + 1
  194. + lstrlen(pcszProtocol);
  195. if (AllocateMemory(dwcbDefaultIconSubKeyLen, &pszDefaultIconSubKey))
  196. {
  197. EVAL((DWORD)wsprintf(pszDefaultIconSubKey, s_cszDefaultIconSubKeyFmt,
  198. pcszProtocol) < dwcbDefaultIconSubKeyLen);
  199. bResult = (SetRegKeyValue(g_hkeyURLProtocols, pszDefaultIconSubKey,
  200. NULL, REG_SZ, (PCBYTE)s_cszDefaultIcon,
  201. sizeof(s_cszDefaultIcon))
  202. == ERROR_SUCCESS);
  203. FreeMemory(pszDefaultIconSubKey);
  204. pszDefaultIconSubKey = NULL;
  205. }
  206. return(bResult);
  207. }
  208. PRIVATE_CODE BOOL AllowedToRegisterMIMEType(PCSTR pcszMIMEContentType)
  209. {
  210. BOOL bResult;
  211. #pragma data_seg(DATA_SEG_READ_ONLY)
  212. bResult = (lstrcmpi(pcszMIMEContentType, "application/octet-stream") != 0 &&
  213. lstrcmpi(pcszMIMEContentType, "application/octet-string") != 0);
  214. #pragma data_seg()
  215. if (bResult)
  216. TRACE_OUT(("AllowedToRegisterMIMEType(): MIME type %s may be registered.",
  217. pcszMIMEContentType));
  218. else
  219. WARNING_OUT(("AllowedToRegisterMIMEType(): MIME type %s may not be registered.",
  220. pcszMIMEContentType));
  221. return(bResult);
  222. }
  223. /****************************** Public Functions *****************************/
  224. /*
  225. ** RegisterMIMETypeForExtension()
  226. **
  227. ** Under HKEY_CLASSES_ROOT\.ext, add Content Type = mime/type.
  228. **
  229. ** Arguments:
  230. **
  231. ** Returns:
  232. **
  233. ** Side Effects: none
  234. */
  235. PUBLIC_CODE BOOL RegisterMIMETypeForExtension(PCSTR pcszExtension,
  236. PCSTR pcszMIMEContentType)
  237. {
  238. ASSERT(IS_VALID_STRING_PTR(pcszExtension, CSTR));
  239. ASSERT(IS_VALID_STRING_PTR(pcszMIMEContentType, CSTR));
  240. ASSERT(IsValidExtension(pcszExtension));
  241. /* (+ 1) for null terminator. */
  242. return(SetRegKeyValue(HKEY_CLASSES_ROOT, pcszExtension, g_cszContentType, REG_SZ,
  243. (PCBYTE)pcszMIMEContentType,
  244. lstrlen(pcszMIMEContentType) + 1) == ERROR_SUCCESS);
  245. }
  246. /*
  247. ** UnregisterMIMETypeForExtension()
  248. **
  249. ** Deletes Content Type under HKEY_CLASSES_ROOT\.ext.
  250. **
  251. ** Arguments:
  252. **
  253. ** Returns:
  254. **
  255. ** Side Effects: none
  256. */
  257. PUBLIC_CODE BOOL UnregisterMIMETypeForExtension(PCSTR pcszExtension)
  258. {
  259. ASSERT(IS_VALID_STRING_PTR(pcszExtension, CSTR));
  260. ASSERT(IsValidExtension(pcszExtension));
  261. return(NO_ERROR == SHDeleteValue(HKEY_CLASSES_ROOT, pcszExtension, g_cszContentType));
  262. }
  263. /*
  264. ** RegisterExtensionForMIMEType()
  265. **
  266. ** Under g_hkeyMIMESettings\MIME\Database\Content Type\mime/type, add
  267. ** Content Type = mime/type and Extension = .ext.
  268. **
  269. ** Arguments:
  270. **
  271. ** Returns:
  272. **
  273. ** Side Effects: none
  274. */
  275. PUBLIC_CODE BOOL RegisterExtensionForMIMEType(PCSTR pcszExtension,
  276. PCSTR pcszMIMEContentType)
  277. {
  278. BOOL bResult;
  279. char szMIMEContentTypeSubKey[MAX_PATH_LEN];
  280. ASSERT(IS_VALID_STRING_PTR(pcszExtension, CSTR));
  281. ASSERT(IS_VALID_STRING_PTR(pcszMIMEContentType, CSTR));
  282. ASSERT(IsValidExtension(pcszExtension));
  283. bResult = GetMIMETypeSubKey(pcszMIMEContentType, szMIMEContentTypeSubKey,
  284. sizeof(szMIMEContentTypeSubKey));
  285. if (bResult)
  286. /* (+ 1) for null terminator. */
  287. bResult = (SetRegKeyValue(g_hkeyMIMESettings, szMIMEContentTypeSubKey,
  288. g_cszExtension, REG_SZ, (PCBYTE)pcszExtension,
  289. lstrlen(pcszExtension) + 1) == ERROR_SUCCESS);
  290. if (bResult)
  291. TRACE_OUT(("RegisterExtensionForMIMEType(): Registered extension %s as default extension for MIME type %s.",
  292. pcszExtension,
  293. pcszMIMEContentType));
  294. else
  295. WARNING_OUT(("RegisterExtensionForMIMEType(): Failed to register extension %s as default extension for MIME type %s.",
  296. pcszExtension,
  297. pcszMIMEContentType));
  298. return(bResult);
  299. }
  300. /*
  301. ** UnregisterExtensionForMIMEType()
  302. **
  303. ** Deletes Extension under
  304. ** g_hkeyMIMESettings\MIME\Database\Content Type\mime/type. If no other values
  305. ** or sub keys are left, deletes
  306. ** g_hkeyMIMESettings\MIME\Database\Content Type\mime/type.
  307. **
  308. ** Arguments:
  309. **
  310. ** Returns:
  311. **
  312. ** Side Effects: May also delete MIME key.
  313. */
  314. PUBLIC_CODE BOOL UnregisterExtensionForMIMEType(PCSTR pcszMIMEContentType)
  315. {
  316. BOOL bResult;
  317. char szMIMEContentTypeSubKey[MAX_PATH_LEN];
  318. ASSERT(IS_VALID_STRING_PTR(pcszMIMEContentType, CSTR));
  319. bResult = (GetMIMETypeSubKey(pcszMIMEContentType, szMIMEContentTypeSubKey,
  320. sizeof(szMIMEContentTypeSubKey)) &&
  321. SHDeleteValue(g_hkeyMIMESettings, szMIMEContentTypeSubKey,
  322. g_cszExtension) == ERROR_SUCCESS &&
  323. SHDeleteOrphanKey(g_hkeyMIMESettings, szMIMEContentTypeSubKey) == ERROR_SUCCESS);
  324. if (bResult)
  325. TRACE_OUT(("UnregisterExtensionForMIMEType(): Unregistered default extension for MIME type %s.",
  326. pcszMIMEContentType));
  327. else
  328. WARNING_OUT(("UnregisterExtensionForMIMEType(): Failed to unregister default extension for MIME type %s.",
  329. pcszMIMEContentType));
  330. return(bResult);
  331. }
  332. PUBLIC_CODE BOOL RegisterMIMEAssociation(PCSTR pcszFile,
  333. PCSTR pcszMIMEContentType)
  334. {
  335. BOOL bResult;
  336. PCSTR pcszExtension;
  337. ASSERT(IS_VALID_STRING_PTR(pcszFile, CSTR));
  338. ASSERT(IS_VALID_STRING_PTR(pcszMIMEContentType, CSTR));
  339. pcszExtension = ExtractExtension(pcszFile);
  340. /*
  341. * Don't allow association of flag unknown MIME types
  342. * application/octet-stream and application/octet-string.
  343. */
  344. if (EVAL(*pcszExtension) &&
  345. AllowedToRegisterMIMEType(pcszMIMEContentType))
  346. bResult = (RegisterMIMETypeForExtension(pcszExtension, pcszMIMEContentType) &&
  347. RegisterExtensionForMIMEType(pcszExtension, pcszMIMEContentType));
  348. else
  349. bResult = FALSE;
  350. return(bResult);
  351. }
  352. PUBLIC_CODE BOOL RegisterURLAssociation(PCSTR pcszProtocol, PCSTR pcszApp)
  353. {
  354. ASSERT(IS_VALID_STRING_PTR(pcszProtocol, CSTR));
  355. ASSERT(IS_VALID_STRING_PTR(pcszApp, CSTR));
  356. return(RegisterAppAsURLProtocolHandler(pcszProtocol, pcszApp) &&
  357. RegisterURLProtocolDescription(pcszProtocol) &&
  358. RegisterURLProtocol(pcszProtocol) &&
  359. RegisterURLProtocolFlags(pcszProtocol) &&
  360. RegisterURLProtocolDefaultIcon(pcszProtocol));
  361. }
  362. PUBLIC_CODE HRESULT MyMIMEAssociationDialog(HWND hwndParent, DWORD dwInFlags,
  363. PCSTR pcszFile,
  364. PCSTR pcszMIMEContentType,
  365. PSTR pszAppBuf, UINT ucAppBufLen)
  366. {
  367. HRESULT hr;
  368. OPENASINFO oainfo;
  369. ASSERT(IS_VALID_HANDLE(hwndParent, WND));
  370. ASSERT(FLAGS_ARE_VALID(dwInFlags, ALL_MIMEASSOCDLG_FLAGS));
  371. ASSERT(IS_VALID_STRING_PTR(pcszFile, CSTR));
  372. ASSERT(IS_VALID_STRING_PTR(pcszMIMEContentType, CSTR));
  373. ASSERT(IS_VALID_WRITE_BUFFER_PTR(pszAppBuf, STR, ucAppBufLen));
  374. /* Use default file name if not supplied by caller. */
  375. if (ucAppBufLen > 0)
  376. *pszAppBuf = '\0';
  377. oainfo.pcszFile = pcszFile;
  378. oainfo.pcszClass = pcszMIMEContentType;
  379. oainfo.dwInFlags = 0;
  380. if (IS_FLAG_SET(dwInFlags, MIMEASSOCDLG_FL_REGISTER_ASSOC))
  381. SET_FLAG(oainfo.dwInFlags, (OPENASINFO_FL_ALLOW_REGISTRATION |
  382. OPENASINFO_FL_REGISTER_EXT));
  383. hr = MyOpenAsDialog(hwndParent, &oainfo);
  384. if (hr == S_OK &&
  385. IS_FLAG_SET(dwInFlags, MIMEASSOCDLG_FL_REGISTER_ASSOC))
  386. hr = RegisterMIMEAssociation(pcszFile, pcszMIMEContentType) ? S_OK
  387. : E_OUTOFMEMORY;
  388. if (SUCCEEDED(hr))
  389. lstrcpyn(pszAppBuf, oainfo.szApp, ucAppBufLen);
  390. ASSERT(! ucAppBufLen ||
  391. (IS_VALID_STRING_PTR(pszAppBuf, STR) &&
  392. EVAL((UINT)lstrlen(pszAppBuf) < ucAppBufLen)));
  393. ASSERT(SUCCEEDED(hr) ||
  394. (! ucAppBufLen ||
  395. EVAL(! *pszAppBuf)));
  396. return(hr);
  397. }
  398. PUBLIC_CODE HRESULT MyURLAssociationDialog(HWND hwndParent, DWORD dwInFlags,
  399. PCSTR pcszFile, PCSTR pcszURL,
  400. PSTR pszAppBuf, UINT ucAppBufLen)
  401. {
  402. HRESULT hr;
  403. PSTR pszProtocol;
  404. ASSERT(IS_VALID_HANDLE(hwndParent, WND));
  405. ASSERT(FLAGS_ARE_VALID(dwInFlags, ALL_URLASSOCDLG_FLAGS));
  406. ASSERT(IS_FLAG_SET(dwInFlags, URLASSOCDLG_FL_USE_DEFAULT_NAME) ||
  407. IS_VALID_STRING_PTR(pcszFile, CSTR));
  408. ASSERT(IS_VALID_STRING_PTR(pcszURL, CSTR));
  409. ASSERT(IS_VALID_WRITE_BUFFER_PTR(pszAppBuf, STR, ucAppBufLen));
  410. /* Use URL protocol as class name. */
  411. if (ucAppBufLen > 0)
  412. *pszAppBuf = '\0';
  413. hr = CopyURLProtocol(pcszURL, &pszProtocol);
  414. if (hr == S_OK)
  415. {
  416. char szInternetShortcut[MAX_PATH_LEN];
  417. OPENASINFO oainfo;
  418. /* Use default file name if not supplied by caller. */
  419. if (IS_FLAG_SET(dwInFlags, URLASSOCDLG_FL_USE_DEFAULT_NAME) &&
  420. EVAL(MLLoadStringA(IDS_INTERNET_SHORTCUT,
  421. szInternetShortcut, sizeof(szInternetShortcut))))
  422. pcszFile = szInternetShortcut;
  423. oainfo.pcszFile = pcszFile;
  424. oainfo.pcszClass = pszProtocol;
  425. oainfo.dwInFlags = 0;
  426. if (IS_FLAG_SET(dwInFlags, URLASSOCDLG_FL_REGISTER_ASSOC))
  427. SET_FLAG(oainfo.dwInFlags, OPENASINFO_FL_ALLOW_REGISTRATION);
  428. hr = MyOpenAsDialog(hwndParent, &oainfo);
  429. if (hr == S_OK &&
  430. IS_FLAG_SET(dwInFlags, URLASSOCDLG_FL_REGISTER_ASSOC))
  431. hr = RegisterURLAssociation(pszProtocol, oainfo.szApp) ? S_OK
  432. : E_OUTOFMEMORY;
  433. if (SUCCEEDED(hr))
  434. lstrcpyn(pszAppBuf, oainfo.szApp, ucAppBufLen);
  435. FreeMemory(pszProtocol);
  436. pszProtocol = NULL;
  437. }
  438. ASSERT(! ucAppBufLen ||
  439. (IS_VALID_STRING_PTR(pszAppBuf, STR) &&
  440. EVAL((UINT)lstrlen(pszAppBuf) < ucAppBufLen)));
  441. ASSERT(SUCCEEDED(hr) ||
  442. (! ucAppBufLen ||
  443. EVAL(! *pszAppBuf)));
  444. return(hr);
  445. }
  446. #ifdef DEBUG
  447. PUBLIC_CODE BOOL IsValidPCOPENASINFO(PCOPENASINFO pcoainfo)
  448. {
  449. return(IS_VALID_READ_PTR(pcoainfo, COPENASINFO) &&
  450. IS_VALID_STRING_PTR(pcoainfo->pcszFile, CSTR) &&
  451. (! pcoainfo->pcszClass ||
  452. IS_VALID_STRING_PTR(pcoainfo->pcszClass, CSTR)) &&
  453. FLAGS_ARE_VALID(pcoainfo->dwInFlags, ALL_OPENASINFO_FLAGS) &&
  454. (! *pcoainfo->szApp ||
  455. IS_VALID_STRING_PTR(pcoainfo->szApp, STR)));
  456. }
  457. #endif /* DEBUG */
  458. /***************************** Exported Functions ****************************/
  459. INTSHCUTAPI HRESULT WINAPI MIMEAssociationDialogA(HWND hwndParent,
  460. DWORD dwInFlags,
  461. PCSTR pcszFile,
  462. PCSTR pcszMIMEContentType,
  463. PSTR pszAppBuf,
  464. UINT ucAppBufLen)
  465. {
  466. HRESULT hr;
  467. DebugEntry(MIMEAssociationDialogA);
  468. #ifdef EXPV
  469. /* Verify parameters. */
  470. if (IS_VALID_HANDLE(hwndParent, WND) &&
  471. IS_VALID_STRING_PTR(pcszFile, CSTR) &&
  472. IS_VALID_STRING_PTR(pcszMIMEContentType, CSTR) &&
  473. IS_VALID_WRITE_BUFFER_PTR(pszAppBuf, STR, ucAppBufLen))
  474. {
  475. if (FLAGS_ARE_VALID(dwInFlags, ALL_MIMEASSOCDLG_FLAGS))
  476. #endif
  477. {
  478. hr = MyMIMEAssociationDialog(hwndParent, dwInFlags, pcszFile,
  479. pcszMIMEContentType, pszAppBuf,
  480. ucAppBufLen);
  481. }
  482. #ifdef EXPV
  483. else
  484. hr = E_FLAGS;
  485. }
  486. else
  487. hr = E_POINTER;
  488. #endif
  489. DebugExitHRESULT(MIMEAssociationDialogA, hr);
  490. return(hr);
  491. }
  492. #pragma warning(disable:4100) /* "unreferenced formal parameter" warning */
  493. INTSHCUTAPI HRESULT WINAPI MIMEAssociationDialogW(HWND hwndParent,
  494. DWORD dwInFlags,
  495. PCWSTR pcszFile,
  496. PCWSTR pcszMIMEContentType,
  497. PWSTR pszAppBuf,
  498. UINT ucAppBufLen)
  499. {
  500. HRESULT hr;
  501. DebugEntry(MIMEAssociationDialogW);
  502. SetLastError(ERROR_NOT_SUPPORTED);
  503. hr = E_NOTIMPL;
  504. DebugExitHRESULT(MIMEAssociationDialogW, hr);
  505. return(hr);
  506. }
  507. #pragma warning(default:4100) /* "unreferenced formal parameter" warning */
  508. INTSHCUTAPI HRESULT WINAPI URLAssociationDialogA(HWND hwndParent,
  509. DWORD dwInFlags,
  510. PCSTR pcszFile, PCSTR pcszURL,
  511. PSTR pszAppBuf,
  512. UINT ucAppBufLen)
  513. {
  514. HRESULT hr;
  515. DebugEntry(URLAssociationDialogA);
  516. #ifdef EXPV
  517. /* Verify parameters. */
  518. if (IS_VALID_HANDLE(hwndParent, WND) &&
  519. (IS_FLAG_SET(dwInFlags, URLASSOCDLG_FL_USE_DEFAULT_NAME) ||
  520. IS_VALID_STRING_PTR(pcszFile, CSTR)) &&
  521. IS_VALID_STRING_PTR(pcszURL, CSTR) &&
  522. IS_VALID_WRITE_BUFFER_PTR(pszAppBuf, STR, ucAppBufLen))
  523. {
  524. if (FLAGS_ARE_VALID(dwInFlags, ALL_URLASSOCDLG_FLAGS))
  525. #endif
  526. {
  527. hr = MyURLAssociationDialog(hwndParent, dwInFlags, pcszFile, pcszURL,
  528. pszAppBuf, ucAppBufLen);
  529. }
  530. #ifdef EXPV
  531. else
  532. hr = E_FLAGS;
  533. }
  534. else
  535. hr = E_POINTER;
  536. #endif
  537. DebugExitHRESULT(URLAssociationDialogA, hr);
  538. return(hr);
  539. }
  540. #pragma warning(disable:4100) /* "unreferenced formal parameter" warning */
  541. INTSHCUTAPI HRESULT WINAPI URLAssociationDialogW(HWND hwndParent,
  542. DWORD dwInFlags,
  543. PCWSTR pcszFile,
  544. PCWSTR pcszURL,
  545. PWSTR pszAppBuf,
  546. UINT ucAppBufLen)
  547. {
  548. HRESULT hr;
  549. DebugEntry(URLAssociationDialogW);
  550. SetLastError(ERROR_NOT_SUPPORTED);
  551. hr = E_NOTIMPL;
  552. DebugExitHRESULT(URLAssociationDialogW, hr);
  553. return(hr);
  554. }
  555. #pragma warning(default:4100) /* "unreferenced formal parameter" warning */