Leaked source code of windows server 2003
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.

743 lines
24 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // File Name: fxocMapi.cpp
  4. //
  5. // Abstract: This file implements wrappers for all mapi apis.
  6. // The wrappers are necessary because mapi does not
  7. // implement unicode and this code must be non-unicode.
  8. //
  9. // Environment: WIN32 User Mode
  10. //
  11. // Copyright (c) 2000 Microsoft Corporation
  12. //
  13. // Revision History:
  14. //
  15. // Date: Developer: Comments:
  16. // ----- ---------- ---------
  17. // 7-Aug-1996 Wesley Witt (wesw) Created (used to be mapi.c)
  18. // 23-Mar-2000 Oren Rosenbloom (orenr) Minimal cleanup, no change in logic
  19. //
  20. //////////////////////////////////////////////////////////////////////////////
  21. #include "faxocm.h"
  22. #pragma warning (disable : 4200)
  23. #include <mapiwin.h>
  24. #include <mapix.h>
  25. #include <stdio.h>
  26. #pragma warning (default : 4200)
  27. ///////////////////////// Static Function Prototypes //////////////////////
  28. static DWORD RemoveTransportProvider(LPSTR lpstrMessageServiceName,LPCTSTR lpctstrProcessName);
  29. #define SYSOCMGR_IMAGE_NAME _T("sysocmgr.exe")
  30. #define RUNDLL_IMAGE_NAME _T("rundll32.exe")
  31. ///////////////////////////////
  32. // fxocMapi_Init
  33. //
  34. // Initialize the exchange update
  35. // subsystem
  36. //
  37. // Params:
  38. // - void.
  39. // Returns:
  40. // - NO_ERROR on success
  41. // - error code otherwise.
  42. //
  43. BOOL fxocMapi_Init(void)
  44. {
  45. BOOL bRslt = TRUE;
  46. DBG_ENTER(_T("Init MAPI Module"), bRslt);
  47. return bRslt;
  48. }
  49. ///////////////////////////////
  50. // fxocMapi_Term
  51. //
  52. // Terminate the exchange update
  53. // subsystem
  54. //
  55. // Params:
  56. // - void.
  57. // Returns:
  58. // - NO_ERROR on success
  59. // - error code otherwise.
  60. //
  61. DWORD fxocMapi_Term(void)
  62. {
  63. BOOL bRslt = TRUE;
  64. DBG_ENTER(_T("Term MAPI Module"),bRslt);
  65. return bRslt;
  66. }
  67. /*
  68. HOWTO: Find the Correct Path to MAPISVC.INF Under Outlook 2000
  69. Q229700
  70. SUMMARY
  71. Outlook exposes a function, FGetComponentPath(), in the Mapistub.dll file that helps us find the path to the Mapisvc.inf file.
  72. This article contains a code sample demonstrating how to do this.
  73. Prior to Outlook 2000, the Mapisvc.inf file was always installed under the system directory (as returned by the Win32 API GetSystemDirectory()).
  74. Note that the following code sample is also backward compatible with all prior versions of Outlook.
  75. It will find the path to the Mapisvc.inf file whether it exists under the system directory or not.
  76. */
  77. typedef BOOL (STDAPICALLTYPE FGETCOMPONENTPATH)
  78. (LPSTR szComponent,
  79. LPSTR szQualifier,
  80. LPSTR szDllPath,
  81. DWORD cchBufferSize,
  82. BOOL fInstall);
  83. typedef FGETCOMPONENTPATH FAR * LPFGETCOMPONENTPATH;
  84. static CHAR s_szMSIApplicationLCID[] = "Microsoft\\Office\\9.0\\Outlook\0LastUILanguage\0";
  85. static CHAR s_szMSIOfficeLCID[] = "Microsoft\\Office\\9.0\\Common\\LanguageResources\0UILanguage\0InstallLanguage\0";
  86. ///////////////////////////////////////////////////////////////////////////////
  87. // Function name : GetMapiSvcInfPath
  88. // Description : For Outlook 2000 compliance. This will get the correct path to the
  89. // : MAPISVC.INF file.
  90. // Return type : void
  91. // Argument : LPSTR szMAPIDir - Buffer to hold the path to the MAPISVC file.
  92. void GetMapiSvcInfPath(LPTSTR szINIFileName)
  93. {
  94. // Get the mapisvc.inf filename.
  95. // The MAPISVC.INF file can live in the system directory.
  96. // and/or "\Program Files\Common Files\SYSTEM\Mapi"
  97. UINT cchT;
  98. static const TCHAR szMapiSvcInf[] = TEXT("\\mapisvc.inf");
  99. LPFGETCOMPONENTPATH pfnFGetComponentPath;
  100. DBG_ENTER(_T("GetMapiSvcInfPath"));
  101. // Char array for private mapisvc.inf.
  102. CHAR szPrivateMAPIDir[MAX_PATH] = {0};
  103. HINSTANCE hinstStub = NULL;
  104. // Get Windows System Directory.
  105. if(!(cchT = GetSystemDirectory(szINIFileName, MAX_PATH)))
  106. goto Done; //return MAPI_E_CALL_FAILED;
  107. // Append Filename to the Path.
  108. _tcscat(szINIFileName, szMapiSvcInf);
  109. // Call common code in mapistub.dll.
  110. hinstStub = LoadLibrary(_T("mapistub.dll"));
  111. if (!hinstStub)
  112. {
  113. VERBOSE (DBG_WARNING,_T("LoadLibrary MAPISTUB.DLL failed (ec: %ld)."),GetLastError());
  114. // Try stub mapi32.dll if mapistub.dll missing.
  115. hinstStub = LoadLibrary(_T("mapi32.dll"));
  116. if (!hinstStub)
  117. {
  118. VERBOSE (DBG_WARNING,_T("LoadLibrary MAPI32.DLL failed (ec: %ld)."),GetLastError());
  119. goto Done;
  120. }
  121. }
  122. if(hinstStub)
  123. {
  124. pfnFGetComponentPath = (LPFGETCOMPONENTPATH)GetProcAddress(hinstStub, "FGetComponentPath");
  125. if (!pfnFGetComponentPath)
  126. {
  127. VERBOSE (DBG_WARNING,_T("GetProcAddress FGetComponentPath failed (ec: %ld)."),GetLastError());
  128. goto Done;
  129. }
  130. if ((pfnFGetComponentPath("{FF1D0740-D227-11D1-A4B0-006008AF820E}",
  131. s_szMSIApplicationLCID, szPrivateMAPIDir, MAX_PATH, TRUE) ||
  132. pfnFGetComponentPath("{FF1D0740-D227-11D1-A4B0-006008AF820E}",
  133. s_szMSIOfficeLCID, szPrivateMAPIDir, MAX_PATH, TRUE) ||
  134. pfnFGetComponentPath("{FF1D0740-D227-11D1-A4B0-006008AF820E}",
  135. NULL, szPrivateMAPIDir, MAX_PATH, TRUE)) &&
  136. szPrivateMAPIDir[0] != '\0')
  137. {
  138. szPrivateMAPIDir[strlen(szPrivateMAPIDir) - 13] = 0; // Strip "\msmapi32.dll"
  139. }
  140. else
  141. {
  142. szPrivateMAPIDir[0] = '\0'; // Terminate String at pos 0.
  143. }
  144. // Write private mapisvc.inf in szINIFileName if it exists
  145. if (*szPrivateMAPIDir)
  146. {
  147. CHAR szPathToIni[MAX_PATH];
  148. strcpy(szPathToIni, szPrivateMAPIDir);
  149. if (MultiByteToWideChar(CP_ACP,
  150. MB_PRECOMPOSED,
  151. szPathToIni,
  152. -1,
  153. szINIFileName,
  154. MAX_PATH)==0)
  155. {
  156. VERBOSE (DBG_WARNING,_T("MultiByteToWideChar failed (ec: %ld)."),GetLastError());
  157. goto Done;
  158. }
  159. _tcscat(szINIFileName, szMapiSvcInf);
  160. }
  161. }
  162. Done:
  163. VERBOSE (DBG_MSG,_T("Path to MAPISVC.INF is %s"),szINIFileName);
  164. if (hinstStub)
  165. {
  166. FreeLibrary(hinstStub);
  167. }
  168. }
  169. ///////////////////////////////
  170. // fxocMapi_Install
  171. //
  172. // Make changes to exchange to
  173. // allow for integration with fax.
  174. //
  175. // Params:
  176. // - pszSubcomponentId.
  177. // - pszInstallSection - section in INF to install from
  178. // Returns:
  179. // - NO_ERROR on success
  180. // - error code otherwise.
  181. //
  182. DWORD fxocMapi_Install(const TCHAR *pszSubcomponentId,
  183. const TCHAR *pszInstallSection)
  184. {
  185. BOOL bSuccess = FALSE;
  186. DWORD dwReturn = NO_ERROR;
  187. TCHAR szPathToMapiSvcInf[MAX_PATH] = {0};
  188. DBG_ENTER( _T("fxocMapi_Install"),
  189. dwReturn,
  190. _T("%s - %s"),
  191. pszSubcomponentId,
  192. pszInstallSection);
  193. // we have to find the 'real' MAPISVC.INF somewhere on the system
  194. GetMapiSvcInfPath(szPathToMapiSvcInf);
  195. // following section is done to fix the W2K transport provider in MAPISVC.INF
  196. // Under [MSFAX XP] section change PR_SERVICE_DLL_NAME from FAXXP.DLL to FXSXP.DLL
  197. if (!WritePrivateProfileString( FAX_MESSAGE_SERVICE_NAME_T,
  198. _T("PR_SERVICE_DLL_NAME"),
  199. FAX_MESSAGE_TRANSPORT_IMAGE_NAME_T,
  200. szPathToMapiSvcInf))
  201. {
  202. VERBOSE ( GENERAL_ERR,
  203. _T("WritePrivateProfileString (%s %s) failed (ec: %ld)."),
  204. _T("PR_SERVICE_DLL_NAME"),
  205. FAX_MESSAGE_TRANSPORT_IMAGE_NAME_T,
  206. GetLastError());
  207. }
  208. // Under [MSFAX XP] section change PR_SERVICE_SUPPORT_FILES from FAXXP.DLL to FXSXP.DLL
  209. if (!WritePrivateProfileString( FAX_MESSAGE_SERVICE_NAME_T,
  210. _T("PR_SERVICE_SUPPORT_FILES"),
  211. FAX_MESSAGE_TRANSPORT_IMAGE_NAME_T,
  212. szPathToMapiSvcInf))
  213. {
  214. VERBOSE ( GENERAL_ERR,
  215. _T("WritePrivateProfileString (%s %s) failed (ec: %ld)."),
  216. _T("PR_SERVICE_SUPPORT_FILES"),
  217. FAX_MESSAGE_TRANSPORT_IMAGE_NAME_T,
  218. GetLastError());
  219. }
  220. // Under [MSFAX XPP] section change PR_PROVIDER_DLL_NAME from FAXXP.DLL to FXSXP.DLL
  221. if (!WritePrivateProfileString( FAX_MESSAGE_PROVIDER_NAME_T,
  222. _T("PR_PROVIDER_DLL_NAME"),
  223. FAX_MESSAGE_TRANSPORT_IMAGE_NAME_T,
  224. szPathToMapiSvcInf))
  225. {
  226. VERBOSE ( GENERAL_ERR,
  227. _T("WritePrivateProfileString (%s %s) failed (ec: %ld)."),
  228. _T("PR_PROVIDER_DLL_NAME"),
  229. FAX_MESSAGE_TRANSPORT_IMAGE_NAME_T,
  230. GetLastError());
  231. }
  232. // following section is done to remove SBS2000 transport provider from MAPISVC.INF
  233. if (!WritePrivateProfileString( TEXT("Default Services"),
  234. FAX_MESSAGE_SERVICE_NAME_SBS50_T,
  235. NULL,
  236. szPathToMapiSvcInf))
  237. {
  238. VERBOSE (GENERAL_ERR,
  239. TEXT("WritePrivateProfileString failed (ec: %ld)."),
  240. GetLastError());
  241. }
  242. if (!WritePrivateProfileString( TEXT("Services"),
  243. FAX_MESSAGE_SERVICE_NAME_SBS50_T,
  244. NULL,
  245. szPathToMapiSvcInf))
  246. {
  247. VERBOSE (GENERAL_ERR,
  248. TEXT("WritePrivateProfileString failed (ec: %ld)."),
  249. GetLastError());
  250. }
  251. if (!WritePrivateProfileString( FAX_MESSAGE_SERVICE_NAME_SBS50_T,
  252. NULL,
  253. NULL,
  254. szPathToMapiSvcInf))
  255. {
  256. VERBOSE (GENERAL_ERR,
  257. TEXT("WritePrivateProfileString failed (ec: %ld)."),
  258. GetLastError());
  259. }
  260. if (!WritePrivateProfileString( FAX_MESSAGE_PROVIDER_NAME_SBS50_T,
  261. NULL,
  262. NULL,
  263. szPathToMapiSvcInf))
  264. {
  265. VERBOSE (GENERAL_ERR,
  266. TEXT("WritePrivateProfileString failed (ec: %ld)."),
  267. GetLastError());
  268. }
  269. return dwReturn;
  270. }
  271. ///////////////////////////////
  272. // fxocMapi_Uninstall
  273. //
  274. // Used to be "DeleteFaxMsgServices"
  275. // in old FaxOCM.dll, it was in
  276. // "mapi.c" file
  277. //
  278. // Params:
  279. // - pszSubcomponentId.
  280. // - pszInstallSection - section in INF to install from
  281. //
  282. // Returns:
  283. // - NO_ERROR on success
  284. // - error code otherwise.
  285. //
  286. DWORD fxocMapi_Uninstall(const TCHAR *pszSubcomponentId,
  287. const TCHAR *pszUninstallSection)
  288. {
  289. DWORD dwReturn = NO_ERROR;
  290. DBG_ENTER( _T("fxocMapi_Uninstall"),
  291. dwReturn,
  292. _T("%s - %s %d"),
  293. pszSubcomponentId,
  294. pszUninstallSection);
  295. VERBOSE(DBG_MSG,_T("Removing the MSFAX XP51 service provider"));
  296. if( RemoveTransportProvider(FAX_MESSAGE_SERVICE_NAME,SYSOCMGR_IMAGE_NAME)!=NO_ERROR)
  297. {
  298. dwReturn = GetLastError();
  299. VERBOSE(DBG_WARNING,_T("Cannot delete XP Transport Provider %d"),dwReturn);
  300. }
  301. return dwReturn;
  302. }
  303. ///////////////////////////////////////////////////////////////////////////////////////
  304. // Function:
  305. // RemoveTransportProviderFromProfile
  306. //
  307. // Purpose: removes the Trasnport Provider from a specific MAPI profile
  308. //
  309. // Params:
  310. // LPSERVICEADMIN lpServiceAdmin - profile to remove the provider from
  311. // LPSTR lpstrMessageServiceName - service name to remove
  312. //
  313. // Return Value:
  314. // Win32 Error code
  315. //
  316. // Author:
  317. // Mooly Beery (MoolyB) 13-dec-2000
  318. ///////////////////////////////////////////////////////////////////////////////////////
  319. HRESULT RemoveTransportProviderFromProfile(LPSERVICEADMIN lpServiceAdmin,LPSTR lpstrMessageServiceName)
  320. {
  321. static SRestriction sres;
  322. static SizedSPropTagArray(2, Columns) = {2,{PR_DISPLAY_NAME_A,PR_SERVICE_UID}};
  323. HRESULT hr = S_OK;
  324. LPMAPITABLE lpMapiTable = NULL;
  325. LPSRowSet lpSRowSet = NULL;
  326. LPSPropValue lpProp = NULL;
  327. ULONG Count = 0;
  328. BOOL bMapiInitialized = FALSE;
  329. SPropValue spv;
  330. MAPIUID ServiceUID;
  331. DBG_ENTER(TEXT("RemoveTransportProviderFromProfile"), hr);
  332. // get message service table
  333. hr = lpServiceAdmin->GetMsgServiceTable(0,&lpMapiTable);
  334. if (FAILED(hr))
  335. {
  336. VERBOSE (GENERAL_ERR,
  337. TEXT("GetMsgServiceTable failed (ec: %ld)."),
  338. hr);
  339. goto exit;
  340. }
  341. // notify MAPI that we want PR_DISPLAY_NAME_A & PR_SERVICE_UID
  342. hr = lpMapiTable->SetColumns((LPSPropTagArray)&Columns, 0);
  343. if (FAILED(hr))
  344. {
  345. VERBOSE (GENERAL_ERR,
  346. TEXT("SetColumns failed (ec: %ld)."),
  347. hr);
  348. goto exit;
  349. }
  350. // restrict the search to our service provider
  351. sres.rt = RES_PROPERTY;
  352. sres.res.resProperty.relop = RELOP_EQ;
  353. sres.res.resProperty.ulPropTag = PR_SERVICE_NAME_A;
  354. sres.res.resProperty.lpProp = &spv;
  355. spv.ulPropTag = PR_SERVICE_NAME_A;
  356. spv.Value.lpszA = lpstrMessageServiceName;
  357. // find it
  358. hr = lpMapiTable->FindRow(&sres, BOOKMARK_BEGINNING, 0);
  359. if (FAILED(hr))
  360. {
  361. VERBOSE (GENERAL_ERR,
  362. TEXT("FindRow failed (ec: %ld)."),
  363. hr);
  364. goto exit;
  365. }
  366. // get our service provider's row
  367. hr = lpMapiTable->QueryRows(1, 0, &lpSRowSet);
  368. if (FAILED(hr))
  369. {
  370. VERBOSE (GENERAL_ERR,
  371. TEXT("QueryRows failed (ec: %ld)."),
  372. hr);
  373. goto exit;
  374. }
  375. if (lpSRowSet->cRows != 1)
  376. {
  377. VERBOSE (GENERAL_ERR,
  378. TEXT("QueryRows returned %d rows, there should be only one."),
  379. lpSRowSet->cRows);
  380. hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  381. goto exit;
  382. }
  383. // get the MAPIUID of our service
  384. lpProp = &lpSRowSet->aRow[0].lpProps[1];
  385. if (lpProp->ulPropTag != PR_SERVICE_UID)
  386. {
  387. VERBOSE (GENERAL_ERR,
  388. TEXT("Property is %d, should be PR_SERVICE_UID."),
  389. lpProp->ulPropTag);
  390. hr = HRESULT_FROM_WIN32(ERROR_INVALID_PARAMETER);
  391. goto exit;
  392. }
  393. // Copy the UID into our member.
  394. memcpy(&ServiceUID.ab, lpProp->Value.bin.lpb,lpProp->Value.bin.cb);
  395. // finally, delete our service provider
  396. hr = lpServiceAdmin->DeleteMsgService(&ServiceUID);
  397. if (FAILED(hr))
  398. {
  399. VERBOSE (GENERAL_ERR,
  400. TEXT("DeleteMsgService failed (ec: %ld)."),
  401. hr);
  402. goto exit;
  403. }
  404. exit:
  405. return hr;
  406. }
  407. ///////////////////////////////////////////////////////////////////////////////////////
  408. // Function:
  409. // RemoveTransportProvider
  410. //
  411. // Purpose: removes the Trasnport Provider from MAPI profiles
  412. //
  413. // Params:
  414. // LPSTR lpstrMessageServiceName - service name to remove
  415. // LPCTSTR lpctstrProcessName - process for which MAPI calls are routed
  416. //
  417. // Return Value:
  418. // Win32 Error code
  419. //
  420. // Author:
  421. // Mooly Beery (MoolyB) 13-dec-2000
  422. ///////////////////////////////////////////////////////////////////////////////////////
  423. DWORD RemoveTransportProvider(LPSTR lpstrMessageServiceName,LPCTSTR lpctstrProcessName)
  424. {
  425. DWORD err = 0;
  426. DWORD rc = ERROR_SUCCESS;
  427. HRESULT hr = S_OK;
  428. LPSERVICEADMIN lpServiceAdmin = NULL;
  429. LPMAPITABLE lpMapiTable = NULL;
  430. LPPROFADMIN lpProfAdmin = NULL;
  431. LPMAPITABLE lpTable = NULL;
  432. LPSRowSet lpSRowSet = NULL;
  433. LPSPropValue lpProp = NULL;
  434. ULONG Count = 0;
  435. int iIndex = 0;
  436. BOOL bMapiInitialized = FALSE;
  437. HINSTANCE hMapiDll = NULL;
  438. LPMAPIINITIALIZE fnMapiInitialize = NULL;
  439. LPMAPIADMINPROFILES fnMapiAdminProfiles = NULL;
  440. LPMAPIUNINITIALIZE fnMapiUninitialize = NULL;
  441. DBG_ENTER(TEXT("RemoveTransportProvider"), rc);
  442. CRouteMAPICalls rmcRouteMapiCalls;
  443. // now remove the MAPI Service provider
  444. rc = rmcRouteMapiCalls.Init(lpctstrProcessName);
  445. if (rc!=ERROR_SUCCESS)
  446. {
  447. CALL_FAIL(GENERAL_ERR, TEXT("CRouteMAPICalls::Init failed (ec: %ld)."), rc);
  448. goto exit;
  449. }
  450. hMapiDll = LoadLibrary(_T("MAPI32.DLL"));
  451. if (NULL == hMapiDll)
  452. {
  453. CALL_FAIL(GENERAL_ERR, TEXT("LoadLibrary"), GetLastError());
  454. goto exit;
  455. }
  456. fnMapiInitialize = (LPMAPIINITIALIZE)GetProcAddress(hMapiDll, "MAPIInitialize");
  457. if (NULL == fnMapiInitialize)
  458. {
  459. CALL_FAIL(GENERAL_ERR, TEXT("GetProcAddress(MAPIInitialize)"), GetLastError());
  460. goto exit;
  461. }
  462. fnMapiAdminProfiles = (LPMAPIADMINPROFILES)GetProcAddress(hMapiDll, "MAPIAdminProfiles");
  463. if (NULL == fnMapiAdminProfiles)
  464. {
  465. CALL_FAIL(GENERAL_ERR, TEXT("GetProcAddress(fnMapiAdminProfiles)"), GetLastError());
  466. goto exit;
  467. }
  468. fnMapiUninitialize = (LPMAPIUNINITIALIZE)GetProcAddress(hMapiDll, "MAPIUninitialize");
  469. if (NULL == fnMapiUninitialize)
  470. {
  471. CALL_FAIL(GENERAL_ERR, TEXT("GetProcAddress(MAPIUninitialize)"), GetLastError());
  472. goto exit;
  473. }
  474. // get access to MAPI functinality
  475. hr = fnMapiInitialize(NULL);
  476. if (FAILED(hr))
  477. {
  478. VERBOSE (GENERAL_ERR,
  479. TEXT("MAPIInitialize failed (ec: %ld)."),
  480. rc = hr);
  481. goto exit;
  482. }
  483. bMapiInitialized = TRUE;
  484. // get admin profile object
  485. hr = fnMapiAdminProfiles(0,&lpProfAdmin);
  486. if (FAILED(hr))
  487. {
  488. VERBOSE (GENERAL_ERR,
  489. TEXT("MAPIAdminProfiles failed (ec: %ld)."),
  490. rc = hr);
  491. goto exit;
  492. }
  493. // get profile table
  494. hr = lpProfAdmin->GetProfileTable(0,&lpTable);
  495. if (FAILED(hr))
  496. {
  497. VERBOSE (GENERAL_ERR,
  498. TEXT("GetProfileTable failed (ec: %ld)."),
  499. rc = hr);
  500. goto exit;
  501. }
  502. // get profile rows
  503. hr = lpTable->QueryRows(4000, 0, &lpSRowSet);
  504. if (FAILED(hr))
  505. {
  506. VERBOSE (GENERAL_ERR,
  507. TEXT("QueryRows failed (ec: %ld)."),
  508. hr);
  509. goto exit;
  510. }
  511. for (iIndex=0; iIndex<(int)lpSRowSet->cRows; iIndex++)
  512. {
  513. lpProp = &lpSRowSet->aRow[iIndex].lpProps[0];
  514. if (lpProp->ulPropTag != PR_DISPLAY_NAME_A)
  515. {
  516. VERBOSE (GENERAL_ERR,
  517. TEXT("Property is %d, should be PR_DISPLAY_NAME_A."),
  518. lpProp->ulPropTag);
  519. hr = HRESULT_FROM_WIN32(ERROR_INVALID_TABLE);
  520. goto exit;
  521. }
  522. hr = lpProfAdmin->AdminServices(LPTSTR(lpProp->Value.lpszA),NULL,0,0,&lpServiceAdmin);
  523. if (FAILED(hr))
  524. {
  525. VERBOSE (GENERAL_ERR,
  526. TEXT("AdminServices failed (ec: %ld)."),
  527. rc = hr);
  528. goto exit;
  529. }
  530. hr = RemoveTransportProviderFromProfile(lpServiceAdmin,lpstrMessageServiceName);
  531. if (FAILED(hr))
  532. {
  533. VERBOSE (GENERAL_ERR,
  534. TEXT("RemoveTransportProviderFromProfile failed (ec: %ld)."),
  535. rc = hr);
  536. goto exit;
  537. }
  538. }
  539. exit:
  540. if (bMapiInitialized)
  541. {
  542. fnMapiUninitialize();
  543. }
  544. if (hMapiDll)
  545. {
  546. FreeLibrary(hMapiDll);
  547. hMapiDll = NULL;
  548. }
  549. return rc;
  550. }
  551. #define prv_DEBUG_FILE_NAME _T("%windir%\\FaxSetup.log")
  552. ///////////////////////////////////////////////////////////////////////////////////////
  553. // Function:
  554. // AWF_UninstallProvider
  555. //
  556. // Purpose: removes the AWF Trasnport Provider from MAPI profiles
  557. // called from Active Setup key for every new user once.
  558. //
  559. // Params:
  560. // None
  561. //
  562. // Return Value:
  563. // Win32 Error code
  564. //
  565. // Author:
  566. // Mooly Beery (MoolyB) 01-Jun-2001
  567. ///////////////////////////////////////////////////////////////////////////////////////
  568. DWORD AWF_UninstallProvider()
  569. {
  570. DWORD dwReturn = NO_ERROR;
  571. SET_FORMAT_MASK(DBG_PRNT_ALL_TO_FILE);
  572. SET_DEBUG_MASK(DBG_ALL);
  573. OPEN_DEBUG_LOG_FILE(prv_DEBUG_FILE_NAME);
  574. {
  575. DBG_ENTER(_T("AWF_UninstallProvider"),dwReturn);
  576. // this is an upgrade from W9X, we should remove the AWF transport.
  577. VERBOSE(DBG_MSG,_T("Removing the AWFAX service provider"));
  578. if( RemoveTransportProvider(FAX_MESSAGE_SERVICE_NAME_W9X,RUNDLL_IMAGE_NAME)!=NO_ERROR)
  579. {
  580. VERBOSE(DBG_WARNING,_T("Cannot delete W9X Transport Provider %d"),GetLastError());
  581. }
  582. }
  583. return dwReturn;
  584. }
  585. ///////////////////////////////////////////////////////////////////////////////////////
  586. // Function:
  587. // PFW_UninstallProvider
  588. //
  589. // Purpose: removes the PFW Trasnport Provider from MAPI profiles
  590. // called from Active Setup key for every new user once.
  591. //
  592. // Params:
  593. // None
  594. //
  595. // Return Value:
  596. // Win32 Error code
  597. //
  598. // Author:
  599. // Mooly Beery (MoolyB) 01-Jun-2001
  600. ///////////////////////////////////////////////////////////////////////////////////////
  601. DWORD PFW_UninstallProvider()
  602. {
  603. DWORD dwReturn = NO_ERROR;
  604. SET_FORMAT_MASK(DBG_PRNT_ALL_TO_FILE);
  605. SET_DEBUG_MASK(DBG_ALL);
  606. OPEN_DEBUG_LOG_FILE(prv_DEBUG_FILE_NAME);
  607. {
  608. DBG_ENTER(_T("PFW_UninstallProvider"),dwReturn);
  609. // this is an upgrade from W2K, we should remove the PFW transport.
  610. VERBOSE(DBG_MSG,_T("Removing the MSFAX XP service provider"));
  611. if( RemoveTransportProvider(FAX_MESSAGE_SERVICE_NAME_W2K,RUNDLL_IMAGE_NAME)!=NO_ERROR)
  612. {
  613. VERBOSE(DBG_WARNING,_T("Cannot delete W2K Transport Provider %d"),GetLastError());
  614. }
  615. }
  616. return dwReturn;
  617. }
  618. ///////////////////////////////////////////////////////////////////////////////////////
  619. // Function:
  620. // XP_UninstallProvider
  621. //
  622. // Purpose: removes the Windows XP Trasnport Provider from MAPI profiles
  623. // called from Active Setup key for every new user once.
  624. //
  625. // Params:
  626. // None
  627. //
  628. // Return Value:
  629. // Win32 Error code
  630. //
  631. // Author:
  632. // Mooly Beery (MoolyB) 01-Jun-2001
  633. ///////////////////////////////////////////////////////////////////////////////////////
  634. DWORD XP_UninstallProvider()
  635. {
  636. DWORD dwReturn = NO_ERROR;
  637. SET_FORMAT_MASK(DBG_PRNT_ALL_TO_FILE);
  638. SET_DEBUG_MASK(DBG_ALL);
  639. OPEN_DEBUG_LOG_FILE(prv_DEBUG_FILE_NAME);
  640. {
  641. DBG_ENTER(_T("XP_UninstallProvider"),dwReturn);
  642. VERBOSE(DBG_MSG,_T("Removing the MSFAX XP service provider"));
  643. if( RemoveTransportProvider(FAX_MESSAGE_SERVICE_NAME,RUNDLL_IMAGE_NAME)!=NO_ERROR)
  644. {
  645. VERBOSE(DBG_WARNING,_T("Cannot delete XP Transport Provider %d"),GetLastError());
  646. }
  647. }
  648. return dwReturn;
  649. }