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.

881 lines
23 KiB

  1. // wamreg.cpp : Implementation of DLL Exports.
  2. // Note: Proxy/Stub Information
  3. // To merge the proxy/stub code into the object DLL, add the file
  4. // dlldatax.c to the project. Make sure precompiled headers
  5. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  6. // defines for the project.
  7. //
  8. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  9. // need to remove the following define from dlldatax.c
  10. // #define _WIN32_WINNT 0x0400
  11. //
  12. // Further, if you are running MIDL without /Oicf switch, you also
  13. // need to remove the following define from dlldatax.c.
  14. // #define USE_STUBLESS_PROXY
  15. //
  16. // Modify the custom build rule for wamreg.idl by adding the following
  17. // files to the Outputs.
  18. // wamreg_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f wamregps.mk in the project directory.
  22. #include "common.h"
  23. #include "objbase.h"
  24. #include "initguid.h"
  25. #include "iwamreg.h"
  26. #include "iadmext.h"
  27. #include "dlldatax.h"
  28. #include "auxfunc.h"
  29. #include "wmrgsv.h"
  30. #include "WamAdm.h"
  31. #include "comobj.h"
  32. #include "dbgutil.h"
  33. #ifdef _MERGE_PROXYSTUB
  34. extern "C" HINSTANCE hProxyDll;
  35. #endif
  36. #define IIS_DEFAULT_PACKAGE 0
  37. #ifndef _NO_TRACING_
  38. #include <initguid.h>
  39. DEFINE_GUID(IisWamRegGuid,
  40. 0x784d8917, 0xaa8c, 0x11d2, 0x92, 0x5e, 0x00, 0xc0, 0x4f, 0x72, 0xd9, 0x0e);
  41. #ifdef _IIS_6_0
  42. #include "w3ctrlps.h"
  43. #endif // _IIS_6_0
  44. #endif
  45. DECLARE_DEBUG_VARIABLE();
  46. DECLARE_DEBUG_PRINTS_OBJECT();
  47. DECLARE_PLATFORM_TYPE();
  48. const CHAR g_pszModuleName[] = "WAMREG";
  49. HINSTANCE g_hModule = NULL;
  50. /////////////////////////////////////////////////////////////////////////////
  51. // DLL Entry Point
  52. extern "C"
  53. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  54. {
  55. lpReserved;
  56. #ifdef _MERGE_PROXYSTUB
  57. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  58. return FALSE;
  59. #endif
  60. BOOL fReturn = FALSE;
  61. if (dwReason == DLL_PROCESS_ATTACH)
  62. {
  63. DisableThreadLibraryCalls(hInstance);
  64. g_hModule = hInstance;
  65. INITIALIZE_PLATFORM_TYPE();
  66. #ifdef _NO_TRACING_
  67. SET_DEBUG_FLAGS(DEBUG_ERROR);
  68. CREATE_DEBUG_PRINT_OBJECT( g_pszModuleName);
  69. #else
  70. // CREATE_DEBUG_PRINT_OBJECT( g_pszModuleName);
  71. #endif
  72. /*
  73. if ( !VALID_DEBUG_PRINT_OBJECT())
  74. {
  75. fReturn = FALSE;
  76. }
  77. else
  78. {
  79. */
  80. g_pWmRgSrvFactory = new CWmRgSrvFactory();
  81. fReturn = g_WamRegGlobal.Init();
  82. //}
  83. }
  84. else if (dwReason == DLL_PROCESS_DETACH)
  85. {
  86. g_WamRegGlobal.UnInit();
  87. delete g_pWmRgSrvFactory;
  88. DELETE_DEBUG_PRINT_OBJECT();
  89. }
  90. fReturn = TRUE; // ok
  91. return fReturn;
  92. }
  93. /////////////////////////////////////////////////////////////////////////////
  94. // Used to determine whether the DLL can be unloaded by OLE
  95. STDAPI DllCanUnloadNow(void)
  96. {
  97. #ifdef _MERGE_PROXYSTUB
  98. if (PrxDllCanUnloadNow() != S_OK)
  99. return S_FALSE;
  100. #endif
  101. if (g_dwRefCount == 0)
  102. {
  103. return S_OK;
  104. }
  105. else
  106. {
  107. return S_FALSE;
  108. }
  109. }
  110. /////////////////////////////////////////////////////////////////////////////
  111. // Returns a class factory to create an object of the requested type
  112. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  113. {
  114. HRESULT hrReturn = E_FAIL;
  115. #ifdef _MERGE_PROXYSTUB
  116. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  117. return S_OK;
  118. #endif
  119. if (rclsid == CLSID_WmRgSrv)
  120. {
  121. if (FAILED(g_pWmRgSrvFactory->QueryInterface(riid, ppv)))
  122. {
  123. *ppv = NULL;
  124. hrReturn = E_INVALIDARG;
  125. }
  126. else
  127. {
  128. hrReturn = NOERROR;
  129. }
  130. }
  131. else
  132. {
  133. hrReturn = S_OK;
  134. }
  135. return hrReturn;
  136. }
  137. HRESULT WamReg_RegisterServer()
  138. {
  139. HKEY hKeyCLSID, hKeyInproc32;
  140. HKEY hKeyIF, hKeyStub32;
  141. HKEY hKeyAppID, hKeyTemp;
  142. DWORD dwDisposition;
  143. BOOL fIsWin95 = FALSE;
  144. char pszName[MAX_PATH+1 + sizeof("inetinfo.exe -e iisadmin")];
  145. //
  146. // if win95, then don't register as service
  147. //
  148. if ( IISGetPlatformType() == PtWindows95 ) {
  149. fIsWin95 = TRUE;
  150. }
  151. if (fIsWin95) {
  152. HMODULE hModule=GetModuleHandle(TEXT("WAMREG.DLL"));
  153. if (!hModule) {
  154. return E_UNEXPECTED;
  155. }
  156. WCHAR wchName[MAX_PATH + 1];
  157. if (GetModuleFileName(hModule, pszName, sizeof(pszName))==0) {
  158. return E_UNEXPECTED;
  159. }
  160. int i;
  161. //
  162. // Set pszName to the command to start the web server
  163. //
  164. for (i = strlen(pszName) -1; (i >= 0) && (pszName[i] != '/') & (pszName[i] != '\\'); i--) {
  165. }
  166. pszName[i + 1] = '\0';
  167. strcat(pszName, "inetinfo.exe -e iisadmin");
  168. }
  169. HRESULT hr;
  170. //
  171. //register AppID
  172. //CLSID_WamAdmin, 0x61738644, 0xF196, 0x11D0, 0x99, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x19, 0xC1)
  173. //
  174. if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT,
  175. TEXT("AppID\\{61738644-F196-11D0-9953-00C04FD919C1}"),
  176. NULL,
  177. TEXT(""),
  178. REG_OPTION_NON_VOLATILE,
  179. KEY_ALL_ACCESS,
  180. NULL,
  181. &hKeyAppID,
  182. &dwDisposition))
  183. {
  184. return E_UNEXPECTED;
  185. }
  186. else
  187. {
  188. if (ERROR_SUCCESS != RegSetValueEx(hKeyAppID,
  189. TEXT(""),
  190. NULL,
  191. REG_SZ,
  192. (BYTE*) TEXT("IIS WAMREG admin Service"),
  193. sizeof(TEXT("IIS WAMREG Admin Service"))))
  194. {
  195. RegCloseKey(hKeyAppID);
  196. return E_UNEXPECTED;
  197. }
  198. if (!fIsWin95)
  199. {
  200. if (ERROR_SUCCESS != RegSetValueEx(hKeyAppID,
  201. TEXT("LocalService"),
  202. NULL,
  203. REG_SZ,
  204. (BYTE *) TEXT("IISADMIN"),
  205. sizeof(TEXT("IISADMIN"))))
  206. {
  207. RegCloseKey(hKeyAppID);
  208. return E_UNEXPECTED;
  209. }
  210. }
  211. RegCloseKey(hKeyAppID);
  212. }
  213. //
  214. // register CLSID
  215. //WamAdmin_CLSID
  216. if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT,
  217. TEXT("CLSID\\{61738644-F196-11D0-9953-00C04FD919C1}"),
  218. NULL,
  219. TEXT(""),
  220. REG_OPTION_NON_VOLATILE,
  221. KEY_ALL_ACCESS,
  222. NULL,
  223. &hKeyCLSID,
  224. &dwDisposition))
  225. {
  226. return E_UNEXPECTED;
  227. }
  228. else
  229. {
  230. if (ERROR_SUCCESS != RegSetValueEx(hKeyCLSID,
  231. TEXT(""),
  232. NULL,
  233. REG_SZ,
  234. (BYTE*) TEXT("IIS WAMREG Admin"),
  235. sizeof(TEXT("IIS WAMREG Admin"))))
  236. {
  237. RegCloseKey(hKeyCLSID);
  238. return E_UNEXPECTED;
  239. }
  240. if (ERROR_SUCCESS != RegSetValueEx(hKeyCLSID,
  241. TEXT("AppID"),
  242. NULL,
  243. REG_SZ,
  244. (BYTE*) TEXT("{61738644-F196-11D0-9953-00C04FD919C1}"),
  245. sizeof(TEXT("{61738644-F196-11D0-9953-00C04FD919C1}"))))
  246. {
  247. RegCloseKey(hKeyCLSID);
  248. return E_UNEXPECTED;
  249. }
  250. if (fIsWin95)
  251. {
  252. if (ERROR_SUCCESS != RegCreateKeyEx(hKeyCLSID,
  253. TEXT("LocalServer32"),
  254. NULL,
  255. TEXT(""),
  256. REG_OPTION_NON_VOLATILE,
  257. KEY_ALL_ACCESS,
  258. NULL,
  259. &hKeyTemp,
  260. &dwDisposition))
  261. {
  262. RegCloseKey(hKeyCLSID);
  263. return E_UNEXPECTED;
  264. }
  265. else
  266. {
  267. if (ERROR_SUCCESS != RegSetValueEx(hKeyTemp,
  268. TEXT(""),
  269. NULL,
  270. REG_SZ,
  271. (BYTE*) pszName,
  272. strlen(pszName) + 1))
  273. {
  274. RegCloseKey(hKeyTemp);
  275. RegCloseKey(hKeyCLSID);
  276. return E_UNEXPECTED;
  277. }
  278. RegCloseKey(hKeyTemp);
  279. }
  280. }
  281. else
  282. {
  283. if (ERROR_SUCCESS != RegSetValueEx(hKeyCLSID,
  284. TEXT("LocalService"),
  285. NULL,
  286. REG_SZ,
  287. (BYTE*) TEXT("IISADMIN"),
  288. sizeof(TEXT("IISADMIN"))))
  289. {
  290. RegCloseKey(hKeyCLSID);
  291. return E_UNEXPECTED;
  292. }
  293. }
  294. RegCloseKey(hKeyCLSID);
  295. }
  296. //
  297. // Main Interfaces
  298. //
  299. //
  300. // WAMREG Admin Interface
  301. //IID_IWamAdmin, 0x29822AB7, 0xF302, 0x11D0, 0x99, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x19, 0xC1
  302. if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT,
  303. TEXT("CLSID\\{29822AB7-F302-11D0-9953-00C04FD919C1}"),
  304. NULL,
  305. TEXT(""),
  306. REG_OPTION_NON_VOLATILE,
  307. KEY_ALL_ACCESS,
  308. NULL,
  309. &hKeyCLSID,
  310. &dwDisposition))
  311. {
  312. return E_UNEXPECTED;
  313. }
  314. else
  315. {
  316. if (ERROR_SUCCESS != RegSetValueEx(hKeyCLSID,
  317. TEXT(""),
  318. NULL,
  319. REG_SZ,
  320. (BYTE*) TEXT("PSFactoryBuffer"),
  321. sizeof(TEXT("PSFactoryBuffer"))))
  322. {
  323. RegCloseKey(hKeyCLSID);
  324. return E_UNEXPECTED;
  325. }
  326. if (ERROR_SUCCESS != RegCreateKeyEx(hKeyCLSID,
  327. "InprocServer32",
  328. NULL,
  329. TEXT(""),
  330. REG_OPTION_NON_VOLATILE,
  331. KEY_ALL_ACCESS,
  332. NULL,
  333. &hKeyInproc32,
  334. &dwDisposition))
  335. {
  336. RegCloseKey(hKeyCLSID);
  337. return E_UNEXPECTED;
  338. }
  339. else
  340. {
  341. if (ERROR_SUCCESS != RegSetValueEx(hKeyInproc32,
  342. TEXT(""),
  343. NULL,
  344. REG_SZ,
  345. (BYTE*) "WAMREGPS.DLL",
  346. sizeof(TEXT("WAMREGPS.DLL"))))
  347. {
  348. RegCloseKey(hKeyInproc32);
  349. RegCloseKey(hKeyCLSID);
  350. return E_UNEXPECTED;
  351. }
  352. if (ERROR_SUCCESS != RegSetValueEx(hKeyInproc32,
  353. TEXT("ThreadingModel"),
  354. NULL,
  355. REG_SZ,
  356. (BYTE*) "Both",
  357. sizeof("Both")-1 ))
  358. {
  359. RegCloseKey(hKeyInproc32);
  360. RegCloseKey(hKeyCLSID);
  361. return E_UNEXPECTED;
  362. }
  363. RegCloseKey(hKeyInproc32);
  364. }
  365. RegCloseKey(hKeyCLSID);
  366. }
  367. //
  368. // WAMREG Admin Interface
  369. //IID_IWamAdmin2, 0x29822AB8, 0xF302, 0x11D0, 0x99, 0x53, 0x00, 0xC0, 0x4F, 0xD9, 0x19, 0xC1
  370. if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT,
  371. TEXT("CLSID\\{29822AB8-F302-11D0-9953-00C04FD919C1}"),
  372. NULL,
  373. TEXT(""),
  374. REG_OPTION_NON_VOLATILE,
  375. KEY_ALL_ACCESS,
  376. NULL,
  377. &hKeyCLSID,
  378. &dwDisposition))
  379. {
  380. return E_UNEXPECTED;
  381. }
  382. else
  383. {
  384. if (ERROR_SUCCESS != RegSetValueEx(hKeyCLSID,
  385. TEXT(""),
  386. NULL,
  387. REG_SZ,
  388. (BYTE*) TEXT("PSFactoryBuffer"),
  389. sizeof(TEXT("PSFactoryBuffer"))))
  390. {
  391. RegCloseKey(hKeyCLSID);
  392. return E_UNEXPECTED;
  393. }
  394. if (ERROR_SUCCESS != RegCreateKeyEx(hKeyCLSID,
  395. "InprocServer32",
  396. NULL,
  397. TEXT(""),
  398. REG_OPTION_NON_VOLATILE,
  399. KEY_ALL_ACCESS,
  400. NULL,
  401. &hKeyInproc32,
  402. &dwDisposition))
  403. {
  404. RegCloseKey(hKeyCLSID);
  405. return E_UNEXPECTED;
  406. }
  407. else
  408. {
  409. if (ERROR_SUCCESS != RegSetValueEx(hKeyInproc32,
  410. TEXT(""),
  411. NULL,
  412. REG_SZ,
  413. (BYTE*) "WAMREGPS.DLL",
  414. sizeof(TEXT("WAMREGPS.DLL"))))
  415. {
  416. RegCloseKey(hKeyInproc32);
  417. RegCloseKey(hKeyCLSID);
  418. return E_UNEXPECTED;
  419. }
  420. if (ERROR_SUCCESS != RegSetValueEx(hKeyInproc32,
  421. TEXT("ThreadingModel"),
  422. NULL,
  423. REG_SZ,
  424. (BYTE*) "Both",
  425. sizeof("Both")-1 ))
  426. {
  427. RegCloseKey(hKeyInproc32);
  428. RegCloseKey(hKeyCLSID);
  429. return E_UNEXPECTED;
  430. }
  431. RegCloseKey(hKeyInproc32);
  432. }
  433. RegCloseKey(hKeyCLSID);
  434. }
  435. //
  436. //
  437. // register Interfaces
  438. //
  439. //
  440. // ANSI Main Interface
  441. // WamReg Admin Interface
  442. if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT,
  443. TEXT("Interface\\{29822AB7-F302-11D0-9953-00C04FD919C1}"),
  444. NULL,
  445. TEXT(""),
  446. REG_OPTION_NON_VOLATILE,
  447. KEY_ALL_ACCESS,
  448. NULL,
  449. &hKeyIF,
  450. &dwDisposition))
  451. {
  452. return E_UNEXPECTED;
  453. }
  454. else
  455. {
  456. if (ERROR_SUCCESS != RegSetValueEx(hKeyIF,
  457. TEXT(""),
  458. NULL,
  459. REG_SZ,
  460. (BYTE*) TEXT("IWamAdmin"),
  461. sizeof(TEXT("IWamAdmin"))))
  462. {
  463. RegCloseKey(hKeyIF);
  464. return E_UNEXPECTED;
  465. }
  466. if (ERROR_SUCCESS != RegCreateKeyEx(hKeyIF,
  467. "ProxyStubClsid32",
  468. NULL,
  469. TEXT(""),
  470. REG_OPTION_NON_VOLATILE,
  471. KEY_ALL_ACCESS,
  472. NULL,
  473. &hKeyStub32,
  474. &dwDisposition))
  475. {
  476. RegCloseKey(hKeyIF);
  477. return E_UNEXPECTED;
  478. }
  479. else
  480. {
  481. if (ERROR_SUCCESS != RegSetValueEx(hKeyStub32,
  482. TEXT(""),
  483. NULL,
  484. REG_SZ,
  485. (BYTE*)"{29822AB7-F302-11D0-9953-00C04FD919C1}",
  486. sizeof("{29822AB7-F302-11D0-9953-00C04FD919C1}")))
  487. {
  488. RegCloseKey(hKeyStub32);
  489. RegCloseKey(hKeyIF);
  490. return E_UNEXPECTED;
  491. }
  492. RegCloseKey(hKeyStub32);
  493. }
  494. RegCloseKey(hKeyIF);
  495. }
  496. // WamReg Admin Interface
  497. // IID_IWamAdmin2
  498. if (ERROR_SUCCESS != RegCreateKeyEx(HKEY_CLASSES_ROOT,
  499. TEXT("Interface\\{29822AB8-F302-11D0-9953-00C04FD919C1}"),
  500. NULL,
  501. TEXT(""),
  502. REG_OPTION_NON_VOLATILE,
  503. KEY_ALL_ACCESS,
  504. NULL,
  505. &hKeyIF,
  506. &dwDisposition))
  507. {
  508. return E_UNEXPECTED;
  509. }
  510. else
  511. {
  512. if (ERROR_SUCCESS != RegSetValueEx(hKeyIF,
  513. TEXT(""),
  514. NULL,
  515. REG_SZ,
  516. (BYTE*) TEXT("IWamAdmin2"),
  517. sizeof(TEXT("IWamAdmin2"))))
  518. {
  519. RegCloseKey(hKeyIF);
  520. return E_UNEXPECTED;
  521. }
  522. if (ERROR_SUCCESS != RegCreateKeyEx(hKeyIF,
  523. "ProxyStubClsid32",
  524. NULL,
  525. TEXT(""),
  526. REG_OPTION_NON_VOLATILE,
  527. KEY_ALL_ACCESS,
  528. NULL,
  529. &hKeyStub32,
  530. &dwDisposition))
  531. {
  532. RegCloseKey(hKeyIF);
  533. return E_UNEXPECTED;
  534. }
  535. else
  536. {
  537. if (ERROR_SUCCESS != RegSetValueEx(hKeyStub32,
  538. TEXT(""),
  539. NULL,
  540. REG_SZ,
  541. (BYTE*)"{29822AB8-F302-11D0-9953-00C04FD919C1}",
  542. sizeof("{29822AB8-F302-11D0-9953-00C04FD919C1}")))
  543. {
  544. RegCloseKey(hKeyStub32);
  545. RegCloseKey(hKeyIF);
  546. return E_UNEXPECTED;
  547. }
  548. RegCloseKey(hKeyStub32);
  549. }
  550. RegCloseKey(hKeyIF);
  551. }
  552. return NOERROR;
  553. }
  554. STDAPI WamReg_UnRegisterServer(void) {
  555. BOOL fIsWin95 = FALSE;
  556. //
  557. // if win95, then don't register as service
  558. //
  559. if ( IISGetPlatformType() == PtWindows95 ) {
  560. fIsWin95 = TRUE;
  561. }
  562. //
  563. // register AppID
  564. //
  565. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("AppID\\{61738644-F196-11D0-9953-00C04FD919C1}"));
  566. //RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("AppID\\{61738646-F196-11D0-9953-00C04FD919C1}"));
  567. //
  568. // register CLSID
  569. //
  570. if (fIsWin95)
  571. {
  572. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{61738644-F196-11D0-9953-00C04FD919C1}\\LocalServer32"));
  573. }
  574. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{61738644-F196-11D0-9953-00C04FD919C1}"));
  575. /*
  576. if (fIsWin95) {
  577. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{61738646-F196-11D0-9953-00C04FD919C1}\\LocalServer32"));
  578. }
  579. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{61738646-F196-11D0-9953-00C04FD919C1}"));
  580. */
  581. //
  582. // WAMREG Interfaces
  583. //
  584. //
  585. // Admin Interface
  586. //
  587. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{29822AB7-F302-11D0-9953-00C04FD919C1}\\InprocServer32"));
  588. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{29822AB7-F302-11D0-9953-00C04FD919C1}"));
  589. //
  590. // Replication Interface
  591. //
  592. /*
  593. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{29822AB8-F302-11D0-9953-00C04FD919C1}\\InprocServer32"));
  594. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{29822AB8-F302-11D0-9953-00C04FD919C1}"));
  595. */
  596. //
  597. // deregister Interfaces
  598. //
  599. //
  600. // Admin Interface
  601. //
  602. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Interface\\{29822AB7-F302-11D0-9953-00C04FD919C1}\\ProxyStubClsid32"));
  603. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Interface\\{29822AB7-F302-11D0-9953-00C04FD919C1}"));
  604. /*
  605. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Interface\\{29822AB8-F302-11D0-9953-00C04FD919C1}\\ProxyStubClsid32"));
  606. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Interface\\{29822AB8-F302-11D0-9953-00C04FD919C1}"));
  607. */
  608. return NOERROR;
  609. }
  610. /////////////////////////////////////////////////////////////////////////////
  611. // DllRegisterServer - Adds entries to the system registry
  612. STDAPI DllRegisterServer(void)
  613. {
  614. HKEY hKeyCLSID, hKeyInproc32;
  615. DWORD dwDisposition;
  616. HMODULE hModule;
  617. DWORD dwReturn = ERROR_SUCCESS;
  618. #ifdef _MERGE_PROXYSTUB
  619. HRESULT hRes = PrxDllRegisterServer();
  620. if (FAILED(hRes))
  621. return hRes;
  622. #endif
  623. dwReturn = RegCreateKeyEx(HKEY_CLASSES_ROOT,
  624. TEXT("CLSID\\{763A6C86-F30F-11D0-9953-00C04FD919C1}"),
  625. NULL,
  626. TEXT(""),
  627. REG_OPTION_NON_VOLATILE,
  628. KEY_ALL_ACCESS,
  629. NULL,
  630. &hKeyCLSID,
  631. &dwDisposition);
  632. if (dwReturn == ERROR_SUCCESS)
  633. {
  634. dwReturn = RegSetValueEx(hKeyCLSID,
  635. TEXT(""),
  636. NULL,
  637. REG_SZ,
  638. (BYTE*) TEXT("WAM REG COM LAYER"),
  639. sizeof(TEXT("WAM REG COM LAYER")));
  640. if (dwReturn == ERROR_SUCCESS)
  641. {
  642. dwReturn = RegCreateKeyEx(hKeyCLSID,
  643. "InprocServer32",
  644. NULL,
  645. TEXT(""),
  646. REG_OPTION_NON_VOLATILE,
  647. KEY_ALL_ACCESS,
  648. NULL,
  649. &hKeyInproc32,
  650. &dwDisposition);
  651. if (dwReturn == ERROR_SUCCESS)
  652. {
  653. hModule=GetModuleHandle(TEXT("WAMREG.DLL"));
  654. if (!hModule)
  655. {
  656. dwReturn = GetLastError();
  657. }
  658. else
  659. {
  660. TCHAR szName[MAX_PATH+1];
  661. if (GetModuleFileName(hModule,
  662. szName,
  663. sizeof(szName)) == NULL)
  664. {
  665. dwReturn = GetLastError();
  666. }
  667. else
  668. {
  669. dwReturn = RegSetValueEx(hKeyInproc32,
  670. TEXT(""),
  671. NULL,
  672. REG_SZ,
  673. (BYTE*) szName,
  674. sizeof(TCHAR)*(lstrlen(szName)+1));
  675. if (dwReturn == ERROR_SUCCESS)
  676. {
  677. dwReturn = RegSetValueEx(hKeyInproc32,
  678. TEXT("ThreadingModel"),
  679. NULL,
  680. REG_SZ,
  681. (BYTE*) TEXT("Both"),
  682. sizeof(TEXT("Both")));
  683. }
  684. }
  685. }
  686. RegCloseKey(hKeyInproc32);
  687. }
  688. }
  689. RegCloseKey(hKeyCLSID);
  690. }
  691. //
  692. // Register the COM object's CLSID under IISADMIN_EXTENSIONS_REG_KEY
  693. //
  694. if (dwReturn == ERROR_SUCCESS)
  695. {
  696. dwReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  697. IISADMIN_EXTENSIONS_REG_KEY
  698. TEXT("\\{763A6C86-F30F-11D0-9953-00C04FD919C1}"),
  699. NULL,
  700. TEXT(""),
  701. REG_OPTION_NON_VOLATILE,
  702. KEY_ALL_ACCESS,
  703. NULL,
  704. &hKeyCLSID,
  705. &dwDisposition);
  706. if (dwReturn == ERROR_SUCCESS)
  707. {
  708. RegCloseKey(hKeyCLSID);
  709. }
  710. }
  711. if (dwReturn == ERROR_SUCCESS)
  712. {
  713. HRESULT hr;
  714. // registers object, typelib and all interfaces in typelib
  715. hr = WamReg_RegisterServer();
  716. return hr;
  717. }
  718. else
  719. {
  720. return RETURNCODETOHRESULT(dwReturn);
  721. }
  722. }
  723. /////////////////////////////////////////////////////////////////////////////
  724. // DllUnregisterServer - Removes entries from the system registry
  725. STDAPI DllUnregisterServer(void)
  726. {
  727. DWORD dwReturn = ERROR_SUCCESS;
  728. DWORD dwTemp;
  729. #ifdef _MERGE_PROXYSTUB
  730. PrxDllUnregisterServer();
  731. #endif
  732. dwTemp = RegDeleteKey(HKEY_CLASSES_ROOT,
  733. TEXT("CLSID\\{763A6C86-F30F-11D0-9953-00C04FD919C1}\\InprocServer32"));
  734. if (dwTemp != ERROR_SUCCESS)
  735. {
  736. dwReturn = dwTemp;
  737. }
  738. dwTemp = RegDeleteKey(HKEY_CLASSES_ROOT,
  739. TEXT("CLSID\\{763A6C86-F30F-11D0-9953-00C04FD919C1}"));
  740. if (dwTemp != ERROR_SUCCESS)
  741. {
  742. dwReturn = dwTemp;
  743. }
  744. dwTemp = RegDeleteKey(HKEY_LOCAL_MACHINE,
  745. IISADMIN_EXTENSIONS_REG_KEY
  746. TEXT("\\{763A6C86-F30F-11D0-9953-00C04FD919C1}"));
  747. if (dwTemp != ERROR_SUCCESS)
  748. {
  749. dwReturn = dwTemp;
  750. }
  751. if (SUCCEEDED(HRESULT_FROM_WIN32(dwReturn)))
  752. {
  753. HRESULT hr;
  754. hr = WamReg_UnRegisterServer();
  755. return hr;
  756. }
  757. else
  758. {
  759. return HRESULT_FROM_WIN32(dwReturn);
  760. }
  761. }