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.

1395 lines
47 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1997.
  5. //
  6. // File: libmain.cxx
  7. //
  8. // Contents: LibMain for adsiis.dll
  9. //
  10. // Functions: LibMain, DllGetClassObject
  11. //
  12. // History: 25-Oct-94 KrishnaG Created.
  13. //
  14. //----------------------------------------------------------------------------
  15. #include "iis.hxx"
  16. #pragma hdrstop
  17. HINSTANCE g_hInst = NULL;
  18. WCHAR * szIISPrefix = L"@IIS!";
  19. #ifdef ADSI_BUILD_WIN95
  20. STDAPI
  21. DllRegisterServerWin95(VOID);
  22. STDAPI
  23. DllUnregisterServerWin95(VOID);
  24. #endif //ADSI_BUILD_WIN95
  25. //
  26. // Global Data
  27. //
  28. WIN32_CRITSEC * g_pGlobalLock = NULL;
  29. SERVER_CACHE * g_pServerCache = NULL;
  30. extern CRITICAL_SECTION g_ExtCritSect;
  31. extern PCLASS_ENTRY gpClassHead;
  32. DECLARE_DEBUG_PRINTS_OBJECT()
  33. #ifdef _NO_TRACING_
  34. DECLARE_DEBUG_VARIABLE();
  35. #endif
  36. //---------------------------------------------------------------------------
  37. // ADs debug print, mem leak and object tracking-related stuff
  38. //---------------------------------------------------------------------------
  39. DECLARE_INFOLEVEL(ADs)
  40. //+---------------------------------------------------------------------------
  41. //
  42. // Function: ShutDown
  43. //
  44. // Synopsis: Function to handle printing out heap debugging display
  45. //
  46. //----------------------------------------------------------------------------
  47. inline VOID ShutDown()
  48. {
  49. #if DBG==1
  50. #ifndef MSVC
  51. DUMP_TRACKING_INFO_DELETE();
  52. DeleteCriticalSection(&g_csOT);
  53. DeleteCriticalSection(&g_csMem);
  54. #endif // ifndef MSVC
  55. DeleteCriticalSection(&g_csDP);
  56. #endif
  57. }
  58. extern "C" DWORD heapInfoLevel;
  59. extern "C" DWORD OtInfoLevel;
  60. extern "C" DWORD ADsInfoLevel;
  61. //+---------------------------------------------------------------------------
  62. //
  63. // Function: GetINIHeapInfoLevel
  64. //
  65. // Synopsis: Gets various infolevel values from win.ini
  66. //
  67. //----------------------------------------------------------------------------
  68. inline VOID GetINIHeapInfoLevel()
  69. {
  70. #if DBG==1
  71. const INT MAXINFOLEN=11;
  72. WCHAR awcs[MAXINFOLEN];
  73. #ifndef MSVC
  74. if (GetProfileString(L"IIS",L"heapInfoLevel", L"00000003", awcs,MAXINFOLEN))
  75. heapInfoLevel = wcstoul(awcs, NULL, 16);
  76. if (GetProfileString(L"IIS",L"Ot", L"00000003", awcs, MAXINFOLEN))
  77. OtInfoLevel = wcstoul(awcs, NULL, 16);
  78. #endif // MSVC
  79. if (GetProfileString(L"IIS",L"ADsInfoLevel", L"00000003", awcs,MAXINFOLEN))
  80. ADsInfoLevel = wcstoul(awcs, NULL, 16);
  81. #endif
  82. }
  83. // Globals
  84. ULONG g_ulObjCount = 0; // Number of objects alive in oleds.dll
  85. //+------------------------------------------------------------------------
  86. //
  87. // Macro that calculates the number of elements in a statically-defined
  88. // array.
  89. //
  90. // Note - I swiped this from ADsary.cxx - A type-safe array class. Remember
  91. // to swipe the whole thing as required.
  92. //-------------------------------------------------------------------------
  93. #define MY_ARRAY_SIZE(_a) (sizeof(_a) / sizeof(_a[0]))
  94. CIISProviderCF g_cfProvider;
  95. CIISNamespaceCF g_cfNamespace;
  96. CIISMimeTypeCF g_cfMimeType;
  97. CIISPropertyAttributeCF g_cfPropertyAttribute;
  98. //+------------------------------------------------------------------------
  99. //
  100. // oleds class factories
  101. //
  102. //-------------------------------------------------------------------------
  103. struct CLSCACHE
  104. {
  105. const CLSID * pclsid;
  106. IClassFactory * pCF;
  107. };
  108. CLSCACHE g_aclscache[] =
  109. {
  110. &CLSID_IISProvider, &g_cfProvider,
  111. &CLSID_IISNamespace, &g_cfNamespace,
  112. &CLSID_IISMimeType, &g_cfMimeType,
  113. &CLSID_IISPropertyAttribute, &g_cfPropertyAttribute
  114. };
  115. //+---------------------------------------------------------------
  116. //
  117. // Function: DllGetClassObject
  118. //
  119. // Synopsis: Standard DLL entrypoint for locating class factories
  120. //
  121. //----------------------------------------------------------------
  122. STDAPI
  123. DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID FAR* ppv)
  124. {
  125. HRESULT hr;
  126. size_t i;
  127. for (i = 0; i < MY_ARRAY_SIZE(g_aclscache); i++)
  128. {
  129. if (IsEqualCLSID(clsid, *g_aclscache[i].pclsid))
  130. {
  131. hr = g_aclscache[i].pCF->QueryInterface(iid, ppv);
  132. RRETURN(hr);
  133. }
  134. }
  135. *ppv = NULL;
  136. //
  137. // Add Debugging Code to indicate that the oleds.DllGetClassObject has been called with an unknown CLSID.
  138. //
  139. return E_NOINTERFACE;
  140. }
  141. //+---------------------------------------------------------------
  142. //
  143. // Function: DllCanUnloadNow
  144. //
  145. // Synopsis: Standard DLL entrypoint to determine if DLL can be unloaded
  146. //
  147. //---------------------------------------------------------------
  148. STDAPI
  149. DllCanUnloadNow(void)
  150. {
  151. HRESULT hr;
  152. hr = S_FALSE;
  153. return hr;
  154. }
  155. //+---------------------------------------------------------------
  156. //
  157. // Function: LibMain
  158. //
  159. // Synopsis: Standard DLL initialization entrypoint
  160. //
  161. //---------------------------------------------------------------
  162. EXTERN_C BOOL __cdecl
  163. LibMain(HINSTANCE hInst, ULONG ulReason, LPVOID pvReserved)
  164. {
  165. switch (ulReason)
  166. {
  167. case DLL_PROCESS_ATTACH:
  168. DisableThreadLibraryCalls(hInst);
  169. g_pGlobalLock = new WIN32_CRITSEC();
  170. g_pServerCache = new SERVER_CACHE();
  171. g_hInst = hInst;
  172. #if DBG==1
  173. #ifndef MSVC
  174. INITIALIZE_CRITICAL_SECTION(&g_csOT);
  175. INITIALIZE_CRITICAL_SECTION(&g_csMem);
  176. #endif
  177. INITIALIZE_CRITICAL_SECTION(&g_csDP);
  178. #endif
  179. #ifdef _NO_TRACING_
  180. CREATE_DEBUG_PRINT_OBJECT("adsiis");
  181. SET_DEBUG_FLAGS(DEBUG_ERROR);
  182. #endif
  183. InitializeCriticalSection(&g_ExtCritSect);
  184. gpClassHead = BuildClassesList();
  185. break;
  186. case DLL_PROCESS_DETACH:
  187. //
  188. // free global list of class entries for 3rd party ext
  189. //
  190. FreeClassesList(gpClassHead);
  191. DeleteCriticalSection(&g_ExtCritSect);
  192. #ifdef _NO_TRACING_
  193. DELETE_DEBUG_PRINT_OBJECT();
  194. #endif
  195. ShutDown();
  196. delete(g_pGlobalLock);
  197. delete(g_pServerCache);
  198. break;
  199. default:
  200. break;
  201. }
  202. return TRUE;
  203. }
  204. //+---------------------------------------------------------------------------
  205. //
  206. // Function: DllMain
  207. //
  208. // Synopsis: entry point for NT - post .546
  209. //
  210. //----------------------------------------------------------------------------
  211. BOOL
  212. DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved)
  213. {
  214. return LibMain((HINSTANCE)hDll, dwReason, lpReserved);
  215. }
  216. //+------------------------------------------------------------------------
  217. //
  218. // Function: GetCachedClsidIndex
  219. //
  220. // Synopsis: Returns the index of the given CLSID in the cache, or
  221. // -1 if the CLSID is not present in the cache
  222. //
  223. // Arguments: [clsid]
  224. //
  225. // Returns: int
  226. //
  227. //-------------------------------------------------------------------------
  228. int
  229. GetCachedClsidIndex(REFCLSID clsid)
  230. {
  231. int i;
  232. CLSCACHE * pclscache;
  233. for (i = 0, pclscache = g_aclscache;
  234. i < MY_ARRAY_SIZE(g_aclscache);
  235. i ++, pclscache++)
  236. {
  237. if (IsEqualCLSID(*pclscache->pclsid, clsid))
  238. return i;
  239. }
  240. return -1;
  241. }
  242. //+------------------------------------------------------------------------
  243. //
  244. // Function: GetCachedClassFactory
  245. //
  246. // Synopsis: Returns the cached class factory with the given index.
  247. // The pointer returned has been AddRef'd.
  248. //
  249. // Arguments: [iclsid]
  250. //
  251. // Returns: IClassFactory *
  252. //
  253. //-------------------------------------------------------------------------
  254. IClassFactory *
  255. GetCachedClassFactory(int iclsid)
  256. {
  257. IClassFactory * pCF;
  258. pCF = g_aclscache[iclsid].pCF;
  259. pCF->AddRef();
  260. return pCF;
  261. }
  262. //+------------------------------------------------------------------------
  263. //
  264. // Function: GetCachedClsid
  265. //
  266. // Synopsis: Returns the CLSID corresponding to the given index.
  267. // Normally, code should call GetCachedClassFactory to get
  268. // the class factory directly.
  269. //
  270. // Arguments: [iclsid] -- Clsid index
  271. // [pclsid] -- Matching clsid returned in *pclsid
  272. //
  273. //-------------------------------------------------------------------------
  274. void
  275. GetCachedClsid(int iclsid, CLSID * pclsid)
  276. {
  277. // Assert(iclsid >= 0);
  278. // Assert(iclsid < ARRAY_SIZE(g_aclscache));
  279. *pclsid = *g_aclscache[iclsid].pclsid;
  280. }
  281. //+------------------------------------------------------------------------
  282. //
  283. // Function: DllRegisterServer
  284. //
  285. // Synopsis: Register registry keys for adsiis
  286. //
  287. // Arguments: None
  288. //
  289. //-------------------------------------------------------------------------
  290. STDAPI DllRegisterServer(
  291. )
  292. {
  293. HKEY hKeyCLSID, hKeyTemp;
  294. DWORD dwDisposition;
  295. HMODULE hModule;
  296. HRESULT hr;
  297. ITypeLib *pITypeLib;
  298. WCHAR pszName[MAX_PATH +1];
  299. #ifdef ADSI_BUILD_WIN95
  300. if ( IISGetPlatformType() == PtWindows95 ) {
  301. return(DllRegisterServerWin95());
  302. }
  303. #endif //ADSI_BUILD_WIN95
  304. hModule=GetModuleHandle(TEXT("ADSIIS.DLL"));
  305. if (!hModule) {
  306. return E_UNEXPECTED;
  307. }
  308. if (GetModuleFileName(hModule, pszName, MAX_PATH+1)==0) {
  309. return E_UNEXPECTED;
  310. }
  311. DWORD dwNameSize = ((DWORD)wcslen(pszName) + 1) * sizeof(WCHAR);
  312. hr=LoadTypeLibEx(pszName, REGKIND_REGISTER, &pITypeLib);
  313. if (FAILED(hr)) {
  314. return E_UNEXPECTED;
  315. }
  316. pITypeLib->Release();
  317. if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,
  318. TEXT("Software\\Microsoft\\ADs\\Providers\\IIS"),
  319. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  320. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  321. return E_UNEXPECTED;
  322. }
  323. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  324. (BYTE*) TEXT("IISNamespace"),
  325. sizeof(TEXT("IISNamespace")))!=ERROR_SUCCESS) {
  326. RegCloseKey(hKeyTemp);
  327. return E_UNEXPECTED;
  328. }
  329. RegCloseKey(hKeyTemp);
  330. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  331. TEXT("IISNamespace\\CLSID"),
  332. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  333. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  334. return E_UNEXPECTED;
  335. }
  336. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  337. (BYTE*) TEXT("{d6bfa35e-89f2-11d0-8527-00c04fd8d503}"),
  338. sizeof(TEXT("{d6bfa35e-89f2-11d0-8527-00c04fd8d503}")))!=ERROR_SUCCESS) {
  339. RegCloseKey(hKeyTemp);
  340. return E_UNEXPECTED;
  341. }
  342. RegCloseKey(hKeyTemp);
  343. //
  344. // register CLSID
  345. //
  346. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  347. TEXT("CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}"),
  348. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  349. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  350. return E_UNEXPECTED;
  351. }
  352. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  353. (BYTE*) TEXT("IIS Namespace Object"),
  354. sizeof(TEXT("IIS Namespace Object")))!=ERROR_SUCCESS) {
  355. RegCloseKey(hKeyCLSID);
  356. return E_UNEXPECTED;
  357. }
  358. if (RegCreateKeyEx(hKeyCLSID,
  359. TEXT("InprocServer32"),
  360. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  361. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  362. RegCloseKey(hKeyCLSID);
  363. return E_UNEXPECTED;
  364. }
  365. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  366. (BYTE*) pszName,
  367. dwNameSize)!=ERROR_SUCCESS) {
  368. RegCloseKey(hKeyTemp);
  369. RegCloseKey(hKeyCLSID);
  370. return E_UNEXPECTED;
  371. }
  372. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  373. (BYTE*) TEXT("Both"),
  374. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  375. RegCloseKey(hKeyTemp);
  376. RegCloseKey(hKeyCLSID);
  377. return E_UNEXPECTED;
  378. }
  379. RegCloseKey(hKeyTemp);
  380. if (RegCreateKeyEx(hKeyCLSID,
  381. TEXT("ProgID"),
  382. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  383. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  384. RegCloseKey(hKeyCLSID);
  385. return E_UNEXPECTED;
  386. }
  387. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  388. (BYTE*) TEXT("IISNamespace"),
  389. sizeof(TEXT("IISNamespace")))!=ERROR_SUCCESS) {
  390. RegCloseKey(hKeyTemp);
  391. RegCloseKey(hKeyCLSID);
  392. return E_UNEXPECTED;
  393. }
  394. RegCloseKey(hKeyTemp);
  395. if (RegCreateKeyEx(hKeyCLSID,
  396. TEXT("TypeLib"),
  397. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  398. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  399. RegCloseKey(hKeyCLSID);
  400. return E_UNEXPECTED;
  401. }
  402. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  403. (BYTE*) TEXT("{49d704a0-89f7-11d0-8527-00c04fd8d503}"),
  404. sizeof(TEXT("{49d704a0-89f7-11d0-8527-00c04fd8d503}")))!=ERROR_SUCCESS) {
  405. RegCloseKey(hKeyTemp);
  406. RegCloseKey(hKeyCLSID);
  407. return E_UNEXPECTED;
  408. }
  409. RegCloseKey(hKeyTemp);
  410. if (RegCreateKeyEx(hKeyCLSID,
  411. TEXT("Version"),
  412. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  413. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  414. RegCloseKey(hKeyCLSID);
  415. return E_UNEXPECTED;
  416. }
  417. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  418. (BYTE*) TEXT("0.0"),
  419. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  420. RegCloseKey(hKeyTemp);
  421. RegCloseKey(hKeyCLSID);
  422. return E_UNEXPECTED;
  423. }
  424. RegCloseKey(hKeyTemp);
  425. RegCloseKey(hKeyCLSID);
  426. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  427. TEXT("IIS\\CLSID"),
  428. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  429. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  430. return E_UNEXPECTED;
  431. }
  432. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  433. (BYTE*) TEXT("{d88966de-89f2-11d0-8527-00c04fd8d503}"),
  434. sizeof(TEXT("{d88966de-89f2-11d0-8527-00c04fd8d503}")))!=ERROR_SUCCESS) {
  435. RegCloseKey(hKeyTemp);
  436. return E_UNEXPECTED;
  437. }
  438. RegCloseKey(hKeyTemp);
  439. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  440. TEXT("CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}"),
  441. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  442. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  443. return E_UNEXPECTED;
  444. }
  445. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  446. (BYTE*) TEXT("IIS Provider Object"),
  447. sizeof(TEXT("IIS Provider Object")))!=ERROR_SUCCESS) {
  448. RegCloseKey(hKeyCLSID);
  449. return E_UNEXPECTED;
  450. }
  451. if (RegCreateKeyEx(hKeyCLSID,
  452. TEXT("InprocServer32"),
  453. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  454. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  455. RegCloseKey(hKeyCLSID);
  456. return E_UNEXPECTED;
  457. }
  458. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  459. (BYTE*) pszName,
  460. dwNameSize)!=ERROR_SUCCESS) {
  461. RegCloseKey(hKeyTemp);
  462. RegCloseKey(hKeyCLSID);
  463. return E_UNEXPECTED;
  464. }
  465. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  466. (BYTE*) TEXT("Both"),
  467. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  468. RegCloseKey(hKeyTemp);
  469. RegCloseKey(hKeyCLSID);
  470. return E_UNEXPECTED;
  471. }
  472. RegCloseKey(hKeyTemp);
  473. if (RegCreateKeyEx(hKeyCLSID,
  474. TEXT("ProgID"),
  475. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  476. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  477. RegCloseKey(hKeyCLSID);
  478. return E_UNEXPECTED;
  479. }
  480. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  481. (BYTE*) TEXT("IIS"),
  482. sizeof(TEXT("IIS")))!=ERROR_SUCCESS) {
  483. RegCloseKey(hKeyTemp);
  484. RegCloseKey(hKeyCLSID);
  485. return E_UNEXPECTED;
  486. }
  487. RegCloseKey(hKeyTemp);
  488. if (RegCreateKeyEx(hKeyCLSID,
  489. TEXT("TypeLib"),
  490. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  491. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  492. RegCloseKey(hKeyCLSID);
  493. return E_UNEXPECTED;
  494. }
  495. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  496. (BYTE*) TEXT("{49d704a0-89f7-11d0-8527-00c04fd8d503}"),
  497. sizeof(TEXT("{49d704a0-89f7-11d0-8527-00c04fd8d503}")))!=ERROR_SUCCESS) {
  498. RegCloseKey(hKeyTemp);
  499. RegCloseKey(hKeyCLSID);
  500. return E_UNEXPECTED;
  501. }
  502. RegCloseKey(hKeyTemp);
  503. if (RegCreateKeyEx(hKeyCLSID,
  504. TEXT("Version"),
  505. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  506. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  507. RegCloseKey(hKeyCLSID);
  508. return E_UNEXPECTED;
  509. }
  510. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  511. (BYTE*) TEXT("0.0"),
  512. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  513. RegCloseKey(hKeyTemp);
  514. RegCloseKey(hKeyCLSID);
  515. return E_UNEXPECTED;
  516. }
  517. RegCloseKey(hKeyTemp);
  518. RegCloseKey(hKeyCLSID);
  519. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  520. TEXT("Mimemap\\CLSID"),
  521. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  522. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  523. return E_UNEXPECTED;
  524. }
  525. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  526. (BYTE*) TEXT("{9036b028-a780-11d0-9b3d-0080c710ef95}"),
  527. sizeof(TEXT("{9036b028-a780-11d0-9b3d-0080c710ef95}")))!=ERROR_SUCCESS) {
  528. RegCloseKey(hKeyTemp);
  529. return E_UNEXPECTED;
  530. }
  531. RegCloseKey(hKeyTemp);
  532. if (RegCreateKeyEx(HKEY_CLASSES_ROOT,
  533. TEXT("CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}"),
  534. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  535. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  536. return E_UNEXPECTED;
  537. }
  538. if (RegSetValueEx(hKeyCLSID, TEXT(""), NULL, REG_SZ,
  539. (BYTE*) TEXT("IIS Mimemap Object"),
  540. sizeof(TEXT("IIS Mimemap Object")))!=ERROR_SUCCESS) {
  541. RegCloseKey(hKeyCLSID);
  542. return E_UNEXPECTED;
  543. }
  544. if (RegCreateKeyEx(hKeyCLSID,
  545. TEXT("InprocServer32"),
  546. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  547. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  548. RegCloseKey(hKeyCLSID);
  549. return E_UNEXPECTED;
  550. }
  551. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  552. (BYTE*) pszName,
  553. dwNameSize)!=ERROR_SUCCESS) {
  554. RegCloseKey(hKeyTemp);
  555. RegCloseKey(hKeyCLSID);
  556. return E_UNEXPECTED;
  557. }
  558. if (RegSetValueEx(hKeyTemp, TEXT("ThreadingModel"), NULL, REG_SZ,
  559. (BYTE*) TEXT("Both"),
  560. sizeof(TEXT("Both")))!=ERROR_SUCCESS) {
  561. RegCloseKey(hKeyTemp);
  562. RegCloseKey(hKeyCLSID);
  563. return E_UNEXPECTED;
  564. }
  565. RegCloseKey(hKeyTemp);
  566. if (RegCreateKeyEx(hKeyCLSID,
  567. TEXT("ProgID"),
  568. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  569. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  570. RegCloseKey(hKeyCLSID);
  571. return E_UNEXPECTED;
  572. }
  573. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  574. (BYTE*) TEXT("IISMimemap"),
  575. sizeof(TEXT("IISMimemap")))!=ERROR_SUCCESS) {
  576. RegCloseKey(hKeyTemp);
  577. RegCloseKey(hKeyCLSID);
  578. return E_UNEXPECTED;
  579. }
  580. RegCloseKey(hKeyTemp);
  581. if (RegCreateKeyEx(hKeyCLSID,
  582. TEXT("TypeLib"),
  583. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  584. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  585. RegCloseKey(hKeyCLSID);
  586. return E_UNEXPECTED;
  587. }
  588. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  589. (BYTE*) TEXT("{49d704a0-89f7-11d0-8527-00c04fd8d503}"),
  590. sizeof(TEXT("{49d704a0-89f7-11d0-8527-00c04fd8d503}")))!=ERROR_SUCCESS) {
  591. RegCloseKey(hKeyTemp);
  592. RegCloseKey(hKeyCLSID);
  593. return E_UNEXPECTED;
  594. }
  595. RegCloseKey(hKeyTemp);
  596. if (RegCreateKeyEx(hKeyCLSID,
  597. TEXT("Version"),
  598. NULL, TEXT(""), REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  599. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  600. RegCloseKey(hKeyCLSID);
  601. return E_UNEXPECTED;
  602. }
  603. if (RegSetValueEx(hKeyTemp, TEXT(""), NULL, REG_SZ,
  604. (BYTE*) TEXT("0.0"),
  605. sizeof(TEXT("0.0")))!=ERROR_SUCCESS) {
  606. RegCloseKey(hKeyTemp);
  607. RegCloseKey(hKeyCLSID);
  608. return E_UNEXPECTED;
  609. }
  610. RegCloseKey(hKeyTemp);
  611. RegCloseKey(hKeyCLSID);
  612. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  613. "PropertyAttribute\\CLSID",
  614. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  615. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  616. return E_UNEXPECTED;
  617. }
  618. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  619. (BYTE*) "{FD2280A8-51A4-11D2-A601-3078302C2030}",
  620. sizeof("{FD2280A8-51A4-11D2-A601-3078302C2030}"))!=ERROR_SUCCESS) {
  621. RegCloseKey(hKeyTemp);
  622. return E_UNEXPECTED;
  623. }
  624. RegCloseKey(hKeyTemp);
  625. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  626. "CLSID\\{FD2280A8-51A4-11D2-A601-3078302C2030}",
  627. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  628. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  629. return E_UNEXPECTED;
  630. }
  631. if (RegSetValueExA(hKeyCLSID, "", NULL, REG_SZ,
  632. (BYTE*) "IIS PropertyAttribute Object",
  633. sizeof("IIS PropertyAttribute Object"))!=ERROR_SUCCESS) {
  634. RegCloseKey(hKeyCLSID);
  635. return E_UNEXPECTED;
  636. }
  637. if (RegCreateKeyExA(hKeyCLSID,
  638. "InprocServer32",
  639. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  640. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  641. RegCloseKey(hKeyCLSID);
  642. return E_UNEXPECTED;
  643. }
  644. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  645. (BYTE*) pszName,
  646. dwNameSize)!=ERROR_SUCCESS) {
  647. RegCloseKey(hKeyTemp);
  648. RegCloseKey(hKeyCLSID);
  649. return E_UNEXPECTED;
  650. }
  651. if (RegSetValueExA(hKeyTemp, "ThreadingModel", NULL, REG_SZ,
  652. (BYTE*) "Both",
  653. sizeof("Both"))!=ERROR_SUCCESS) {
  654. RegCloseKey(hKeyTemp);
  655. RegCloseKey(hKeyCLSID);
  656. return E_UNEXPECTED;
  657. }
  658. RegCloseKey(hKeyTemp);
  659. if (RegCreateKeyExA(hKeyCLSID,
  660. "ProgID",
  661. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  662. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  663. RegCloseKey(hKeyCLSID);
  664. return E_UNEXPECTED;
  665. }
  666. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  667. (BYTE*) "IISPropertyAttribute",
  668. sizeof("IISPropertyAttribute"))!=ERROR_SUCCESS) {
  669. RegCloseKey(hKeyTemp);
  670. RegCloseKey(hKeyCLSID);
  671. return E_UNEXPECTED;
  672. }
  673. RegCloseKey(hKeyTemp);
  674. if (RegCreateKeyExA(hKeyCLSID,
  675. "TypeLib",
  676. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  677. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  678. RegCloseKey(hKeyCLSID);
  679. return E_UNEXPECTED;
  680. }
  681. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  682. (BYTE*) "{49d704a0-89f7-11d0-8527-00c04fd8d503}",
  683. sizeof("{49d704a0-89f7-11d0-8527-00c04fd8d503}"))!=ERROR_SUCCESS) {
  684. RegCloseKey(hKeyTemp);
  685. RegCloseKey(hKeyCLSID);
  686. return E_UNEXPECTED;
  687. }
  688. RegCloseKey(hKeyTemp);
  689. if (RegCreateKeyExA(hKeyCLSID,
  690. "Version",
  691. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  692. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  693. RegCloseKey(hKeyCLSID);
  694. return E_UNEXPECTED;
  695. }
  696. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  697. (BYTE*) "0.0",
  698. sizeof("0.0"))!=ERROR_SUCCESS) {
  699. RegCloseKey(hKeyTemp);
  700. RegCloseKey(hKeyCLSID);
  701. return E_UNEXPECTED;
  702. }
  703. RegCloseKey(hKeyTemp);
  704. RegCloseKey(hKeyCLSID);
  705. return NOERROR;
  706. }
  707. //+------------------------------------------------------------------------
  708. //
  709. // Function: DllUnregisterServer
  710. //
  711. // Synopsis: Register registry keys for adsiis
  712. //
  713. // Arguments: None
  714. //
  715. //+------------------------------------------------------------------------
  716. /* #pragma INTRINSA suppress=all */
  717. STDAPI DllUnregisterServer(void) {
  718. #ifdef ADSI_BUILD_WIN95
  719. if ( IISGetPlatformType() == PtWindows95 ) {
  720. return(DllUnregisterServerWin95());
  721. }
  722. #endif //ADSI_BUILD_WIN95
  723. HRESULT hr = S_OK;
  724. hr = UnRegisterTypeLib(LIBID_IISOle,
  725. 1,
  726. 0,
  727. 0,
  728. SYS_WIN32);
  729. RegDeleteKey(HKEY_LOCAL_MACHINE, TEXT("Software\\Microsoft\\ADs\\Providers\\IIS"));
  730. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISNamespace\\CLSID"));
  731. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IISNamespace"));
  732. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\InprocServer32"));
  733. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\ProgID"));
  734. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\TypeLib"));
  735. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\Version"));
  736. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}"));
  737. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IIS\\CLSID"));
  738. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("IIS"));
  739. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\InprocServer32"));
  740. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\ProgID"));
  741. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\TypeLib"));
  742. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\Version"));
  743. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}"));
  744. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Mimemap\\CLSID"));
  745. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("Mimemap"));
  746. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\InprocServer32"));
  747. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\ProgID"));
  748. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\TypeLib"));
  749. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\Version"));
  750. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}"));
  751. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("PropertyAttribute\\CLSID"));
  752. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("PropertyAttribute"));
  753. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{FD2280A8-51A4-11D2-A601-3078302C2030}\\InprocServer32"));
  754. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{FD2280A8-51A4-11D2-A601-3078302C2030}\\ProgID"));
  755. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{FD2280A8-51A4-11D2-A601-3078302C2030}\\TypeLib"));
  756. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{FD2280A8-51A4-11D2-A601-3078302C2030}\\Version"));
  757. RegDeleteKey(HKEY_CLASSES_ROOT, TEXT("CLSID\\{FD2280A8-51A4-11D2-A601-3078302C2030}"));
  758. return hr;
  759. }
  760. #ifdef ADSI_BUILD_WIN95
  761. //+------------------------------------------------------------------------
  762. //
  763. // Function: DllRegisterServerWin95
  764. //
  765. // Synopsis: Register registry keys for adsiis on win95
  766. //
  767. // Arguments: None
  768. //
  769. //-------------------------------------------------------------------------
  770. STDAPI
  771. DllRegisterServerWin95(
  772. )
  773. {
  774. HKEY hKeyCLSID, hKeyTemp;
  775. DWORD dwDisposition;
  776. HMODULE hModule;
  777. HRESULT hr;
  778. ITypeLib *pITypeLib;
  779. WCHAR pszName[MAX_PATH +1];
  780. CHAR pszNameA[MAX_PATH +1];
  781. hModule=GetModuleHandleA("ADSIIS.DLL");
  782. if (!hModule) {
  783. return E_UNEXPECTED;
  784. }
  785. if (GetModuleFileNameA(hModule, pszNameA, MAX_PATH+1)==0) {
  786. return E_UNEXPECTED;
  787. }
  788. swprintf(pszName, OLESTR("%S"), pszNameA);
  789. DWORD dwNameSize = (DWORD)strlen(pszNameA + 1) * sizeof(CHAR);
  790. hr=LoadTypeLibEx(pszName, REGKIND_REGISTER, &pITypeLib);
  791. if (FAILED(hr)) {
  792. return E_UNEXPECTED;
  793. }
  794. pITypeLib->Release();
  795. if (RegCreateKeyExA(HKEY_LOCAL_MACHINE,
  796. "Software\\Microsoft\\ADs\\Providers\\IIS",
  797. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  798. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  799. return E_UNEXPECTED;
  800. }
  801. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  802. (BYTE*) "IISNamespace",
  803. sizeof("IISNamespace"))!=ERROR_SUCCESS) {
  804. RegCloseKey(hKeyTemp);
  805. return E_UNEXPECTED;
  806. }
  807. RegCloseKey(hKeyTemp);
  808. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  809. "IISNamespace\\CLSID",
  810. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  811. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  812. return E_UNEXPECTED;
  813. }
  814. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  815. (BYTE*) "{d6bfa35e-89f2-11d0-8527-00c04fd8d503}",
  816. sizeof("{d6bfa35e-89f2-11d0-8527-00c04fd8d503}"))!=ERROR_SUCCESS) {
  817. RegCloseKey(hKeyTemp);
  818. return E_UNEXPECTED;
  819. }
  820. RegCloseKey(hKeyTemp);
  821. //
  822. // register CLSID
  823. //
  824. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  825. "CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}",
  826. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  827. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  828. return E_UNEXPECTED;
  829. }
  830. if (RegSetValueExA(hKeyCLSID, "", NULL, REG_SZ,
  831. (BYTE*) "IIS Namespace Object",
  832. sizeof("IIS Namespace Object"))!=ERROR_SUCCESS) {
  833. RegCloseKey(hKeyCLSID);
  834. return E_UNEXPECTED;
  835. }
  836. if (RegCreateKeyExA(hKeyCLSID,
  837. "InprocServer32",
  838. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  839. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  840. RegCloseKey(hKeyCLSID);
  841. return E_UNEXPECTED;
  842. }
  843. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  844. (BYTE*) pszNameA,
  845. dwNameSize)!=ERROR_SUCCESS) {
  846. RegCloseKey(hKeyTemp);
  847. RegCloseKey(hKeyCLSID);
  848. return E_UNEXPECTED;
  849. }
  850. if (RegSetValueExA(hKeyTemp, "ThreadingModel", NULL, REG_SZ,
  851. (BYTE*) "Both",
  852. sizeof("Both"))!=ERROR_SUCCESS) {
  853. RegCloseKey(hKeyTemp);
  854. RegCloseKey(hKeyCLSID);
  855. return E_UNEXPECTED;
  856. }
  857. RegCloseKey(hKeyTemp);
  858. if (RegCreateKeyExA(hKeyCLSID,
  859. "ProgID",
  860. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  861. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  862. RegCloseKey(hKeyCLSID);
  863. return E_UNEXPECTED;
  864. }
  865. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  866. (BYTE*) "IISNamespace",
  867. sizeof("IISNamespace"))!=ERROR_SUCCESS) {
  868. RegCloseKey(hKeyTemp);
  869. RegCloseKey(hKeyCLSID);
  870. return E_UNEXPECTED;
  871. }
  872. RegCloseKey(hKeyTemp);
  873. if (RegCreateKeyExA(hKeyCLSID,
  874. "TypeLib",
  875. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  876. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  877. RegCloseKey(hKeyCLSID);
  878. return E_UNEXPECTED;
  879. }
  880. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  881. (BYTE*) "{49d704a0-89f7-11d0-8527-00c04fd8d503}",
  882. sizeof("{49d704a0-89f7-11d0-8527-00c04fd8d503}"))!=ERROR_SUCCESS) {
  883. RegCloseKey(hKeyTemp);
  884. RegCloseKey(hKeyCLSID);
  885. return E_UNEXPECTED;
  886. }
  887. RegCloseKey(hKeyTemp);
  888. if (RegCreateKeyExA(hKeyCLSID,
  889. "Version",
  890. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  891. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  892. RegCloseKey(hKeyCLSID);
  893. return E_UNEXPECTED;
  894. }
  895. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  896. (BYTE*) "0.0",
  897. sizeof("0.0"))!=ERROR_SUCCESS) {
  898. RegCloseKey(hKeyTemp);
  899. RegCloseKey(hKeyCLSID);
  900. return E_UNEXPECTED;
  901. }
  902. RegCloseKey(hKeyTemp);
  903. RegCloseKey(hKeyCLSID);
  904. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  905. "IIS\\CLSID",
  906. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  907. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  908. return E_UNEXPECTED;
  909. }
  910. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  911. (BYTE*) "{d88966de-89f2-11d0-8527-00c04fd8d503}",
  912. sizeof("{d88966de-89f2-11d0-8527-00c04fd8d503}"))!=ERROR_SUCCESS) {
  913. RegCloseKey(hKeyTemp);
  914. return E_UNEXPECTED;
  915. }
  916. RegCloseKey(hKeyTemp);
  917. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  918. "CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}",
  919. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  920. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  921. return E_UNEXPECTED;
  922. }
  923. if (RegSetValueExA(hKeyCLSID, "", NULL, REG_SZ,
  924. (BYTE*) "IIS Provider Object",
  925. sizeof("IIS Provider Object"))!=ERROR_SUCCESS) {
  926. RegCloseKey(hKeyCLSID);
  927. return E_UNEXPECTED;
  928. }
  929. if (RegCreateKeyExA(hKeyCLSID,
  930. "InprocServer32",
  931. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  932. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  933. RegCloseKey(hKeyCLSID);
  934. return E_UNEXPECTED;
  935. }
  936. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  937. (BYTE*) pszNameA,
  938. dwNameSize)!=ERROR_SUCCESS) {
  939. RegCloseKey(hKeyTemp);
  940. RegCloseKey(hKeyCLSID);
  941. return E_UNEXPECTED;
  942. }
  943. if (RegSetValueExA(hKeyTemp, "ThreadingModel", NULL, REG_SZ,
  944. (BYTE*) "Both",
  945. sizeof("Both"))!=ERROR_SUCCESS) {
  946. RegCloseKey(hKeyTemp);
  947. RegCloseKey(hKeyCLSID);
  948. return E_UNEXPECTED;
  949. }
  950. RegCloseKey(hKeyTemp);
  951. if (RegCreateKeyExA(hKeyCLSID,
  952. "ProgID",
  953. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  954. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  955. RegCloseKey(hKeyCLSID);
  956. return E_UNEXPECTED;
  957. }
  958. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  959. (BYTE*) "IIS",
  960. sizeof("IIS"))!=ERROR_SUCCESS) {
  961. RegCloseKey(hKeyTemp);
  962. RegCloseKey(hKeyCLSID);
  963. return E_UNEXPECTED;
  964. }
  965. RegCloseKey(hKeyTemp);
  966. if (RegCreateKeyExA(hKeyCLSID,
  967. "TypeLib",
  968. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  969. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  970. RegCloseKey(hKeyCLSID);
  971. return E_UNEXPECTED;
  972. }
  973. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  974. (BYTE*) "{49d704a0-89f7-11d0-8527-00c04fd8d503}",
  975. sizeof("{49d704a0-89f7-11d0-8527-00c04fd8d503}"))!=ERROR_SUCCESS) {
  976. RegCloseKey(hKeyTemp);
  977. RegCloseKey(hKeyCLSID);
  978. return E_UNEXPECTED;
  979. }
  980. RegCloseKey(hKeyTemp);
  981. if (RegCreateKeyExA(hKeyCLSID,
  982. "Version",
  983. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  984. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  985. RegCloseKey(hKeyCLSID);
  986. return E_UNEXPECTED;
  987. }
  988. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  989. (BYTE*) "0.0",
  990. sizeof("0.0"))!=ERROR_SUCCESS) {
  991. RegCloseKey(hKeyTemp);
  992. RegCloseKey(hKeyCLSID);
  993. return E_UNEXPECTED;
  994. }
  995. RegCloseKey(hKeyTemp);
  996. RegCloseKey(hKeyCLSID);
  997. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  998. "Mimemap\\CLSID",
  999. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1000. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1001. return E_UNEXPECTED;
  1002. }
  1003. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  1004. (BYTE*) "{9036b028-a780-11d0-9b3d-0080c710ef95}",
  1005. sizeof("{9036b028-a780-11d0-9b3d-0080c710ef95}"))!=ERROR_SUCCESS) {
  1006. RegCloseKey(hKeyTemp);
  1007. return E_UNEXPECTED;
  1008. }
  1009. RegCloseKey(hKeyTemp);
  1010. if (RegCreateKeyExA(HKEY_CLASSES_ROOT,
  1011. "CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}",
  1012. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1013. &hKeyCLSID, &dwDisposition)!=ERROR_SUCCESS) {
  1014. return E_UNEXPECTED;
  1015. }
  1016. if (RegSetValueExA(hKeyCLSID, "", NULL, REG_SZ,
  1017. (BYTE*) "IIS Mimemap Object",
  1018. sizeof("IIS Mimemap Object"))!=ERROR_SUCCESS) {
  1019. RegCloseKey(hKeyCLSID);
  1020. return E_UNEXPECTED;
  1021. }
  1022. if (RegCreateKeyExA(hKeyCLSID,
  1023. "InprocServer32",
  1024. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1025. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1026. RegCloseKey(hKeyCLSID);
  1027. return E_UNEXPECTED;
  1028. }
  1029. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  1030. (BYTE*) pszNameA,
  1031. dwNameSize)!=ERROR_SUCCESS) {
  1032. RegCloseKey(hKeyTemp);
  1033. RegCloseKey(hKeyCLSID);
  1034. return E_UNEXPECTED;
  1035. }
  1036. if (RegSetValueExA(hKeyTemp, "ThreadingModel", NULL, REG_SZ,
  1037. (BYTE*) "Both",
  1038. sizeof("Both"))!=ERROR_SUCCESS) {
  1039. RegCloseKey(hKeyTemp);
  1040. RegCloseKey(hKeyCLSID);
  1041. return E_UNEXPECTED;
  1042. }
  1043. RegCloseKey(hKeyTemp);
  1044. if (RegCreateKeyExA(hKeyCLSID,
  1045. "ProgID",
  1046. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1047. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1048. RegCloseKey(hKeyCLSID);
  1049. return E_UNEXPECTED;
  1050. }
  1051. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  1052. (BYTE*) "IISMimemap",
  1053. sizeof("IISMimemap"))!=ERROR_SUCCESS) {
  1054. RegCloseKey(hKeyTemp);
  1055. RegCloseKey(hKeyCLSID);
  1056. return E_UNEXPECTED;
  1057. }
  1058. RegCloseKey(hKeyTemp);
  1059. if (RegCreateKeyExA(hKeyCLSID,
  1060. "TypeLib",
  1061. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1062. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1063. RegCloseKey(hKeyCLSID);
  1064. return E_UNEXPECTED;
  1065. }
  1066. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  1067. (BYTE*) "{49d704a0-89f7-11d0-8527-00c04fd8d503}",
  1068. sizeof("{49d704a0-89f7-11d0-8527-00c04fd8d503}"))!=ERROR_SUCCESS) {
  1069. RegCloseKey(hKeyTemp);
  1070. RegCloseKey(hKeyCLSID);
  1071. return E_UNEXPECTED;
  1072. }
  1073. RegCloseKey(hKeyTemp);
  1074. if (RegCreateKeyExA(hKeyCLSID,
  1075. "Version",
  1076. NULL, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
  1077. &hKeyTemp, &dwDisposition)!=ERROR_SUCCESS) {
  1078. RegCloseKey(hKeyCLSID);
  1079. return E_UNEXPECTED;
  1080. }
  1081. if (RegSetValueExA(hKeyTemp, "", NULL, REG_SZ,
  1082. (BYTE*) "0.0",
  1083. sizeof("0.0"))!=ERROR_SUCCESS) {
  1084. RegCloseKey(hKeyTemp);
  1085. RegCloseKey(hKeyCLSID);
  1086. return E_UNEXPECTED;
  1087. }
  1088. RegCloseKey(hKeyTemp);
  1089. RegCloseKey(hKeyCLSID);
  1090. return NOERROR;
  1091. }
  1092. //+------------------------------------------------------------------------
  1093. //
  1094. // Function: DllUnregisterServerWin95
  1095. //
  1096. // Synopsis: Register registry keys for adsiis on win95
  1097. //
  1098. // Arguments: None
  1099. //
  1100. //+------------------------------------------------------------------------
  1101. /* #pragma INTRINSA suppress=all */
  1102. STDAPI
  1103. DllUnregisterServerWin95(void) {
  1104. HRESULT hr = S_OK;
  1105. hr = UnRegisterTypeLib(LIBID_IISOle,
  1106. 1,
  1107. 0,
  1108. 0,
  1109. SYS_WIN32);
  1110. RegDeleteKeyA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\ADs\\Providers\\IIS");
  1111. RegDeleteKeyA(HKEY_CLASSES_ROOT, "IISNamespace\\CLSID");
  1112. RegDeleteKeyA(HKEY_CLASSES_ROOT, "IISNamespace");
  1113. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\InprocServer32");
  1114. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\ProgID");
  1115. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\TypeLib");
  1116. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}\\Version");
  1117. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d6bfa35e-89f2-11d0-8527-00c04fd8d503}");
  1118. RegDeleteKeyA(HKEY_CLASSES_ROOT, "IIS\\CLSID");
  1119. RegDeleteKeyA(HKEY_CLASSES_ROOT, "IIS");
  1120. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\InprocServer32");
  1121. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\ProgID");
  1122. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\TypeLib");
  1123. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}\\Version");
  1124. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{d88966de-89f2-11d0-8527-00c04fd8d503}");
  1125. RegDeleteKeyA(HKEY_CLASSES_ROOT, "Mimemap\\CLSID");
  1126. RegDeleteKeyA(HKEY_CLASSES_ROOT, "Mimemap");
  1127. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\InprocServer32");
  1128. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\ProgID");
  1129. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\TypeLib");
  1130. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}\\Version");
  1131. RegDeleteKeyA(HKEY_CLASSES_ROOT, "CLSID\\{9036b028-a780-11d0-9b3d-0080c710ef95}");
  1132. return hr;
  1133. }
  1134. #endif // ADSI_BUILD_WIN95