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.

880 lines
20 KiB

  1. /*++
  2. Copyright (c) 1996-2002 Microsoft Corp. & Ricoh Co., Ltd. All rights reserved.
  3. FILE: COMOEM.CPP
  4. Abstract: Necessary COM class definition to Unidrv
  5. OEM rendering plugin module.
  6. Environment: Windows NT Unidrv5 driver
  7. Revision History:
  8. 04/24/1998 -takashim-
  9. Written the original sample so that it is more C++.
  10. 02/16/1999 -Masatoshi Kubokura-
  11. Last modified for Windows2000.
  12. 03/01/2002 -Masatoshi Kubokura-
  13. Include strsafe.h.
  14. 03/29/2002 -Masatoshi Kubokura-
  15. Eliminate "#if 0".
  16. Check return value at OutputCharStr() and SendFontCmd().
  17. Check NULL pointer at QueryInterface(), EnablePDEV(), and CommandCallback().
  18. --*/
  19. #define INITGUID // for GUID one-time initialization
  20. #include "pdev.h"
  21. #include "names.h"
  22. #ifndef WINNT_40
  23. #include "strsafe.h" // @Mar/01/2002
  24. #endif // !WINNT_40
  25. // External Functions' prototype
  26. extern "C" {
  27. extern BOOL APIENTRY bOEMSendFontCmd(PDEVOBJ pdevobj, PUNIFONTOBJ pUFObj, PFINVOCATION pFInv);
  28. extern BOOL APIENTRY bOEMOutputCharStr(PDEVOBJ pdevobj, PUNIFONTOBJ pUFObj, DWORD dwType, DWORD dwCount, PVOID pGlyph);
  29. } // End of extern "C"
  30. // Globals
  31. static HMODULE g_hModule = NULL ; // DLL module handle
  32. static long g_cComponents = 0 ; // Count of active components
  33. static long g_cServerLocks = 0 ; // Count of locks
  34. //
  35. // IOemCB Definition
  36. //
  37. class IOemCB : public IPrintOemUni
  38. {
  39. public:
  40. //
  41. // IUnknown methods
  42. //
  43. STDMETHODIMP
  44. QueryInterface(
  45. const IID& iid, void** ppv)
  46. {
  47. VERBOSE((DLLTEXT("IOemCB: QueryInterface entry\n")));
  48. // @Mar/29/2002 ->
  49. if (NULL == ppv)
  50. return E_FAIL;
  51. // @Mar/29/2002 <-
  52. if (iid == IID_IUnknown)
  53. {
  54. *ppv = static_cast<IUnknown*>(this);
  55. VERBOSE((DLLTEXT("IOemCB:Return pointer to IUnknown.\n")));
  56. }
  57. else if (iid == IID_IPrintOemUni)
  58. {
  59. *ppv = static_cast<IPrintOemUni*>(this);
  60. VERBOSE((DLLTEXT("IOemCB:Return pointer to IPrintOemUni.\n")));
  61. }
  62. else
  63. {
  64. *ppv = NULL ;
  65. VERBOSE((DLLTEXT("IOemCB:Return NULL.\n")));
  66. return E_NOINTERFACE ;
  67. }
  68. reinterpret_cast<IUnknown*>(*ppv)->AddRef();
  69. return S_OK ;
  70. }
  71. STDMETHODIMP_(ULONG)
  72. AddRef()
  73. {
  74. VERBOSE((DLLTEXT("IOemCB::AddRef() entry.\n")));
  75. return InterlockedIncrement(&m_cRef);
  76. }
  77. STDMETHODIMP_(ULONG)
  78. Release()
  79. {
  80. VERBOSE((DLLTEXT("IOemCB::Release() entry.\n")));
  81. if (InterlockedDecrement(&m_cRef) == 0)
  82. {
  83. delete this ;
  84. return 0 ;
  85. }
  86. return m_cRef ;
  87. }
  88. //
  89. // IPrintOemCommon methods
  90. //
  91. // Function Name: GetInfo
  92. // Plug-in: Any
  93. // Driver: Any
  94. // Type: Mandatory
  95. //
  96. STDMETHODIMP
  97. GetInfo(
  98. DWORD dwMode,
  99. PVOID pBuffer,
  100. DWORD cbSize,
  101. PDWORD pcbNeeded)
  102. {
  103. VERBOSE((DLLTEXT("IOemCB::GetInfo() entry.\n")));
  104. if (OEMGetInfo(dwMode, pBuffer, cbSize, pcbNeeded))
  105. return S_OK;
  106. else
  107. return E_FAIL;
  108. }
  109. //
  110. // Function Name: DevMode
  111. // Plug-in: Rendering module
  112. // Driver: Any
  113. // Type: Optional
  114. //
  115. STDMETHODIMP
  116. DevMode(
  117. DWORD dwMode,
  118. POEMDMPARAM pOemDMParam)
  119. {
  120. VERBOSE((DLLTEXT("IOemCB::DevMode() entry.\n")));
  121. if (OEMDevMode(dwMode, pOemDMParam)) {
  122. return S_OK;
  123. }
  124. else {
  125. return E_FAIL;
  126. }
  127. }
  128. //
  129. // IPrintOemEngine methods
  130. //
  131. //
  132. // Function Name: EnableDriver
  133. // Plug-in: Rendering module
  134. // Driver: Any
  135. // Type: Optional
  136. //
  137. STDMETHODIMP
  138. EnableDriver(
  139. DWORD dwDriverVersion,
  140. DWORD cbSize,
  141. PDRVENABLEDATA pded)
  142. {
  143. VERBOSE((DLLTEXT("IOemCB::EnableDriver() entry.\n")));
  144. // @Sep/17/98 ->
  145. // return E_NOTIMPL;
  146. OEMEnableDriver(dwDriverVersion, cbSize, pded); // @Oct/05/98
  147. // Need to return S_OK so that DisableDriver() will be called, which Releases
  148. // the reference to the Printer Driver's interface.
  149. return S_OK;
  150. // @Sep/17/98 <-
  151. }
  152. //
  153. // Function Name: DisableDriver
  154. // Plug-in: Rendering module
  155. // Driver: Any
  156. // Type: Optional
  157. //
  158. STDMETHODIMP
  159. DisableDriver(VOID)
  160. {
  161. VERBOSE((DLLTEXT("IOemCB::DisaleDriver() entry.\n")));
  162. // @Sep/17/98 ->
  163. // return E_NOTIMPL;
  164. OEMDisableDriver(); // @Oct/05/98
  165. // Release reference to Printer Driver's interface.
  166. if (this->pOEMHelp)
  167. {
  168. this->pOEMHelp->Release();
  169. this->pOEMHelp = NULL;
  170. }
  171. return S_OK;
  172. // @Sep/17/98 <-
  173. }
  174. //
  175. // Function Name: EnablePDEV
  176. // Plug-in: Rendering module
  177. // Driver: Any
  178. // Type: Optional
  179. //
  180. STDMETHODIMP
  181. EnablePDEV(
  182. PDEVOBJ pdevobj,
  183. PWSTR pPrinterName,
  184. ULONG cPatterns,
  185. HSURF *phsurfPatterns,
  186. ULONG cjGdiInfo,
  187. GDIINFO *pGdiInfo,
  188. ULONG cjDevInfo,
  189. DEVINFO *pDevInfo,
  190. DRVENABLEDATA *pded,
  191. OUT PDEVOEM *pDevOem)
  192. {
  193. VERBOSE((DLLTEXT("IOemCB::EnablePDEV() entry.\n")));
  194. // @Oct/06/98 ->
  195. // return E_NOTIMPL;
  196. PDEVOEM pTemp;
  197. // @Mar/29/2002 ->
  198. if (NULL == pDevOem)
  199. return E_FAIL;
  200. // @Mar/29/2002 <-
  201. pTemp = OEMEnablePDEV(pdevobj, pPrinterName, cPatterns, phsurfPatterns,
  202. cjGdiInfo, pGdiInfo, cjDevInfo, pDevInfo, pded);
  203. if (NULL == pTemp)
  204. return E_FAIL;
  205. //
  206. // Save necessary helpder function addresses.
  207. //
  208. // ((MINIDEV *)pTemp)->pIntf = this->pOEMHelp;
  209. *pDevOem = pTemp;
  210. return S_OK;
  211. // @Oct/06/98 <-
  212. }
  213. //
  214. // Function Name: DisablePDEV
  215. // Plug-in: Rendering module
  216. // Driver: Any
  217. // Type: Optional
  218. //
  219. STDMETHODIMP
  220. DisablePDEV(
  221. PDEVOBJ pdevobj)
  222. {
  223. LONG lI;
  224. VERBOSE((DLLTEXT("IOemCB::DisablePDEV() entry.\n")));
  225. // @Oct/05/98 ->
  226. // return E_NOTIMPL;
  227. OEMDisablePDEV(pdevobj);
  228. return S_OK;
  229. // @Oct/05/98 <-
  230. }
  231. //
  232. // Function Name: ResetPDEV
  233. // Plug-in: Rendering module
  234. // Driver: Any
  235. // Type: Optional
  236. //
  237. STDMETHODIMP
  238. ResetPDEV(
  239. PDEVOBJ pdevobjOld,
  240. PDEVOBJ pdevobjNew)
  241. {
  242. VERBOSE((DLLTEXT("IOemCB::ResetPDEV() entry.\n")));
  243. // return E_NOTIMPL;
  244. if (OEMResetPDEV(pdevobjOld, pdevobjNew))
  245. return S_OK;
  246. // @Mar/29/2002 ->
  247. // else
  248. // return S_FALSE;
  249. else
  250. return E_FAIL;
  251. // @Mar/29/2002 <-
  252. }
  253. //
  254. // IPrintOemUni methods
  255. //
  256. //
  257. // Function Name: PublishDriverInterface
  258. // Plug-in: Rendering module
  259. // Driver: Any
  260. // Type: Mandatory
  261. //
  262. STDMETHODIMP
  263. PublishDriverInterface(
  264. IUnknown *pIUnknown)
  265. {
  266. VERBOSE((DLLTEXT("IOemCB::PublishDriverInterface() entry.\n")));
  267. // Need to store pointer to Driver Helper functions, if we already haven't.
  268. if (this->pOEMHelp == NULL)
  269. // @Sep/10/98 ->
  270. // pIUnknown->AddRef();
  271. {
  272. HRESULT hResult;
  273. // Get Interface to Helper Functions.
  274. hResult = pIUnknown->QueryInterface(IID_IPrintOemDriverUni, (void**)&(this->pOEMHelp));
  275. if(!SUCCEEDED(hResult))
  276. {
  277. // Make sure that interface pointer reflects interface query failure.
  278. this->pOEMHelp = NULL;
  279. return E_FAIL;
  280. }
  281. }
  282. // this->pOEMHelp = reinterpret_cast<IPrintOemDriverUni*>(pIUnknown);
  283. // @Sep/10/98 <-
  284. return S_OK;
  285. }
  286. //
  287. // Function Name: GetImplementationMethod
  288. // Plug-in: Rendering module
  289. // Driver: Any
  290. // Type: Mandatory
  291. //
  292. //
  293. // Needed to be static so that it can be passed
  294. // to the bsearch() as a pointer to a functin.
  295. //
  296. static
  297. int __cdecl
  298. iCompNames(
  299. const void *p1,
  300. const void *p2) {
  301. return strcmp(
  302. *((char **)p1),
  303. *((char **)p2));
  304. }
  305. STDMETHODIMP
  306. GetImplementedMethod(
  307. PSTR pMethodName)
  308. {
  309. LONG lRet = E_NOTIMPL;
  310. PSTR pTemp;
  311. VERBOSE((DLLTEXT("IOemCB::GetImplementedMethod() entry.\n")));
  312. if (NULL != pMethodName) {
  313. pTemp = (PSTR)bsearch(
  314. &pMethodName,
  315. gMethodsSupported,
  316. (sizeof (gMethodsSupported) / sizeof (PSTR)),
  317. sizeof (PSTR),
  318. iCompNames);
  319. if (NULL != pTemp)
  320. lRet = S_OK;
  321. }
  322. VERBOSE((DLLTEXT("pMethodName = %s, lRet = %d\n"), pMethodName, lRet));
  323. return lRet;
  324. }
  325. //
  326. // Function Name: CommandCallback
  327. // Plug-in: Rendering module
  328. // Driver: Unidrv
  329. // Type: Optional
  330. //
  331. STDMETHODIMP
  332. CommandCallback(
  333. PDEVOBJ pdevobj,
  334. DWORD dwCallbackID,
  335. DWORD dwCount,
  336. PDWORD pdwParams,
  337. OUT INT *piResult)
  338. {
  339. VERBOSE((DLLTEXT("IOemCB::CommandCallback() entry.\n")));
  340. // @Mar/29/2002 ->
  341. if (NULL == piResult)
  342. return E_FAIL;
  343. // @Mar/29/2002 <-
  344. *piResult = OEMCommandCallback(pdevobj, dwCallbackID, dwCount, pdwParams);
  345. return S_OK;
  346. }
  347. //
  348. // Function Name: ImageProcessing
  349. // Plug-in: Rendering module
  350. // Driver: Unidrv
  351. // Type: Optional
  352. //
  353. STDMETHODIMP
  354. ImageProcessing(
  355. PDEVOBJ pdevobj,
  356. PBYTE pSrcBitmap,
  357. PBITMAPINFOHEADER pBitmapInfoHeader,
  358. PBYTE pColorTable,
  359. DWORD dwCallbackID,
  360. PIPPARAMS pIPParams,
  361. OUT PBYTE *ppbResult)
  362. {
  363. VERBOSE((DLLTEXT("IOemCB::ImageProcessing() entry.\n")));
  364. return E_NOTIMPL;
  365. }
  366. //
  367. // Function Name: FilterGraphics
  368. // Plug-in: Rendering module
  369. // Driver: Unidrv
  370. // Type: Optional
  371. //
  372. STDMETHODIMP
  373. FilterGraphics(
  374. PDEVOBJ pdevobj,
  375. PBYTE pBuf,
  376. DWORD dwLen)
  377. {
  378. VERBOSE((DLLTEXT("IOemCB::FilterGraphis() entry.\n")));
  379. // FilterGraphics disables other compression!
  380. return E_NOTIMPL;
  381. }
  382. //
  383. // Function Name: Compression
  384. // Plug-in: Rendering module
  385. // Driver: Unidrv
  386. // Type: Optional
  387. //
  388. STDMETHODIMP
  389. Compression(
  390. PDEVOBJ pdevobj,
  391. PBYTE pInBuf,
  392. PBYTE pOutBuf,
  393. DWORD dwInLen,
  394. DWORD dwOutLen,
  395. OUT INT *piResult)
  396. {
  397. VERBOSE((DLLTEXT("IOemCB::Compression() entry.\n")));
  398. // @Jul/29/98 ->
  399. // return E_NOTIMPL;
  400. if (0 < (*piResult = OEMCompression(pdevobj, pInBuf, pOutBuf, dwInLen, dwOutLen))) {
  401. return S_OK;
  402. }
  403. else {
  404. return E_FAIL;
  405. }
  406. // @Jul/29/98 <-
  407. }
  408. //
  409. // Function Name: HalftonePattern
  410. // Plug-in: Rendering module
  411. // Driver: Unidrv
  412. // Type: Optional
  413. //
  414. STDMETHODIMP
  415. HalftonePattern(
  416. PDEVOBJ pdevobj,
  417. PBYTE pHTPattern,
  418. DWORD dwHTPatternX,
  419. DWORD dwHTPatternY,
  420. DWORD dwHTNumPatterns,
  421. DWORD dwCallbackID,
  422. PBYTE pResource,
  423. DWORD dwResourceSize)
  424. {
  425. VERBOSE((DLLTEXT("IOemCB::HalftonePattern() entry.\n")));
  426. return E_NOTIMPL;
  427. }
  428. //
  429. // Function Name: MemoryUsge
  430. // Plug-in: Rendering module
  431. // Driver: Unidrv
  432. // Type: Optional
  433. //
  434. STDMETHODIMP
  435. MemoryUsage(
  436. PDEVOBJ pdevobj,
  437. POEMMEMORYUSAGE pMemoryUsage)
  438. {
  439. VERBOSE((DLLTEXT("IOemCB::MemoryUsage() entry.\n")));
  440. return E_NOTIMPL;
  441. }
  442. //
  443. // Function Name: DownloadFontHeader
  444. // Plug-in: Rendering module
  445. // Driver: Unidrv
  446. // Type: Optional
  447. //
  448. STDMETHODIMP
  449. DownloadFontHeader(
  450. PDEVOBJ pdevobj,
  451. PUNIFONTOBJ pUFObj,
  452. OUT DWORD *pdwResult)
  453. {
  454. VERBOSE((DLLTEXT("IOemCB::DownloadFontHeader() entry.\n")));
  455. #ifdef DOWNLOADFONT
  456. if (0 < (*pdwResult = OEMDownloadFontHeader(pdevobj, pUFObj))) {
  457. return S_OK;
  458. }
  459. else {
  460. return E_FAIL;
  461. }
  462. #else // DOWNLOADFONT
  463. return E_NOTIMPL;
  464. #endif // DOWNLOADFONT
  465. }
  466. //
  467. // Function Name: DownloadCharGlyph
  468. // Plug-in: Rendering module
  469. // Driver: Unidrv
  470. // Type: Optional
  471. //
  472. STDMETHODIMP
  473. DownloadCharGlyph(
  474. PDEVOBJ pdevobj,
  475. PUNIFONTOBJ pUFObj,
  476. HGLYPH hGlyph,
  477. PDWORD pdwWidth,
  478. OUT DWORD *pdwResult)
  479. {
  480. VERBOSE((DLLTEXT("IOemCB::DownloadCharGlyph() entry.\n")));
  481. #ifdef DOWNLOADFONT
  482. if (0 < (*pdwResult = OEMDownloadCharGlyph(pdevobj, pUFObj,
  483. hGlyph, pdwWidth))) {
  484. return S_OK;
  485. }
  486. else {
  487. return E_FAIL;
  488. }
  489. #else // DOWNLOADFONT
  490. return E_NOTIMPL;
  491. #endif // DOWNLOADFONT
  492. }
  493. //
  494. // Function Name: TTDonwloadMethod
  495. // Plug-in: Rendering module
  496. // Driver: Unidrv
  497. // Type: Optional
  498. //
  499. STDMETHODIMP
  500. TTDownloadMethod(
  501. PDEVOBJ pdevobj,
  502. PUNIFONTOBJ pUFObj,
  503. OUT DWORD *pdwResult)
  504. {
  505. VERBOSE((DLLTEXT("IOemCB::TTDownloadMethod() entry.\n")));
  506. #ifdef DOWNLOADFONT
  507. *pdwResult = OEMTTDownloadMethod(pdevobj, pUFObj);
  508. return S_OK;
  509. #else // DOWNLOADFONT
  510. return E_NOTIMPL;
  511. #endif // DOWNLOADFONT
  512. }
  513. //
  514. // Function Name: OutputCharStr
  515. // Plug-in: Rendering module
  516. // Driver: Unidrv
  517. // Type: Optional
  518. //
  519. STDMETHODIMP
  520. OutputCharStr(
  521. PDEVOBJ pdevobj,
  522. PUNIFONTOBJ pUFObj,
  523. DWORD dwType,
  524. DWORD dwCount,
  525. PVOID pGlyph)
  526. {
  527. VERBOSE((DLLTEXT("IOemCB::OutputCharStr() entry.\n")));
  528. // @Mar/29/2002 ->
  529. // OEMOutputCharStr(pdevobj, pUFObj, dwType, dwCount, pGlyph);
  530. // return S_OK;
  531. if (bOEMOutputCharStr(pdevobj, pUFObj, dwType, dwCount, pGlyph))
  532. return S_OK;
  533. else
  534. return E_FAIL;
  535. // @Mar/29/2002 <-
  536. }
  537. //
  538. // Function Name: SendFontCmd
  539. // Plug-in: Rendering module
  540. // Driver: Unidrv
  541. // Type: Optional
  542. //
  543. STDMETHODIMP
  544. SendFontCmd(
  545. PDEVOBJ pdevobj,
  546. PUNIFONTOBJ pUFObj,
  547. PFINVOCATION pFInv)
  548. {
  549. VERBOSE((DLLTEXT("IOemCB::SendFontCmd() entry.\n")));
  550. // @Mar/29/2002 ->
  551. // OEMSendFontCmd(pdevobj, pUFObj, pFInv);
  552. // return S_OK;
  553. if (bOEMSendFontCmd(pdevobj, pUFObj, pFInv))
  554. return S_OK;
  555. else
  556. return E_FAIL;
  557. // @Mar/29/2002 <-
  558. }
  559. //
  560. // Function Name: DriverDMS
  561. // Plug-in: Rendering module
  562. // Driver: Unidrv
  563. // Type: Optional
  564. //
  565. STDMETHODIMP
  566. DriverDMS(
  567. PVOID pDevObj,
  568. PVOID pBuffer,
  569. DWORD cbSize,
  570. PDWORD pcbNeeded)
  571. {
  572. VERBOSE((DLLTEXT("IOemCB::DriverDMS() entry.\n")));
  573. return E_NOTIMPL;
  574. }
  575. //
  576. // Function Name: TextOutputAsBitmap
  577. // Plug-in: Rendering module
  578. // Driver: Unidrv
  579. // Type: Optional
  580. //
  581. STDMETHODIMP
  582. TextOutAsBitmap(
  583. SURFOBJ *pso,
  584. STROBJ *pstro,
  585. FONTOBJ *pfo,
  586. CLIPOBJ *pco,
  587. RECTL *prclExtra,
  588. RECTL *prclOpaque,
  589. BRUSHOBJ *pboFore,
  590. BRUSHOBJ *pboOpaque,
  591. POINTL *pptlOrg,
  592. MIX mix)
  593. {
  594. VERBOSE((DLLTEXT("IOemCB::TextOutAsBitmap() entry.\n")));
  595. return E_NOTIMPL;
  596. }
  597. //
  598. // Function Name: TTYGetInfo
  599. // Plug-in: Rendering module
  600. // Driver: Unidrv
  601. // Type: Optional
  602. //
  603. STDMETHODIMP
  604. TTYGetInfo(
  605. PDEVOBJ pdevobj,
  606. DWORD dwInfoIndex,
  607. PVOID pOutputBuf,
  608. DWORD dwSize,
  609. DWORD *pcbcNeeded)
  610. {
  611. VERBOSE((DLLTEXT("IOemCB::TTYGetInfo() entry.\n")));
  612. return E_NOTIMPL;
  613. }
  614. //
  615. // Constructors
  616. //
  617. IOemCB() { m_cRef = 1; pOEMHelp = NULL; };
  618. ~IOemCB() { };
  619. protected:
  620. IPrintOemDriverUni* pOEMHelp;
  621. LONG m_cRef;
  622. };
  623. //
  624. // Class factory definition
  625. //
  626. class IOemCF : public IClassFactory
  627. {
  628. public:
  629. //
  630. // IUnknown methods
  631. //
  632. STDMETHODIMP
  633. QueryInterface(const IID& iid, void** ppv)
  634. {
  635. if ((iid == IID_IUnknown) || (iid == IID_IClassFactory))
  636. {
  637. *ppv = static_cast<IOemCF*>(this);
  638. }
  639. else
  640. {
  641. *ppv = NULL ;
  642. return E_NOINTERFACE ;
  643. }
  644. reinterpret_cast<IUnknown*>(*ppv)->AddRef();
  645. return S_OK ;
  646. }
  647. STDMETHODIMP_(ULONG)
  648. AddRef()
  649. {
  650. return InterlockedIncrement(&m_cRef);
  651. }
  652. STDMETHODIMP_(ULONG)
  653. Release()
  654. {
  655. if (InterlockedDecrement(&m_cRef) == 0)
  656. {
  657. delete this ;
  658. return 0 ;
  659. }
  660. return m_cRef ;
  661. }
  662. //
  663. // IClassFactory methods
  664. //
  665. STDMETHODIMP
  666. CreateInstance(
  667. IUnknown *pUnknownOuter,
  668. const IID &iid,
  669. void **ppv)
  670. {
  671. //VERBOSE((DLLTEXT("IOemCF::CreateInstance() called\n.")));
  672. // Cannot aggregate.
  673. if (NULL != pUnknownOuter) {
  674. return CLASS_E_NOAGGREGATION;
  675. }
  676. // Create component.
  677. IOemCB* pOemCB = new IOemCB;
  678. if (NULL == pOemCB) {
  679. return E_OUTOFMEMORY;
  680. }
  681. // Get the requested interface.
  682. HRESULT hr = pOemCB->QueryInterface(iid, ppv);
  683. // Release the IUnknown pointer.
  684. // (If QueryInterface failed, component will delete itself.)
  685. pOemCB->Release();
  686. return hr ;
  687. }
  688. // LockServer
  689. STDMETHODIMP
  690. LockServer(BOOL bLock)
  691. {
  692. if (bLock)
  693. {
  694. InterlockedIncrement(&g_cServerLocks);
  695. }
  696. else
  697. {
  698. InterlockedDecrement(&g_cServerLocks);
  699. }
  700. return S_OK ;
  701. }
  702. //
  703. // Constructor
  704. //
  705. IOemCF(): m_cRef(1) { };
  706. ~IOemCF() { };
  707. protected:
  708. LONG m_cRef;
  709. };
  710. //
  711. // Export functions
  712. //
  713. //
  714. // Get class factory
  715. //
  716. STDAPI
  717. DllGetClassObject(
  718. const CLSID &clsid,
  719. const IID &iid,
  720. void **ppv)
  721. {
  722. //VERBOSE((DLLTEXT("DllGetClassObject:\tCreate class factory.")));
  723. // Can we create this component?
  724. if (clsid != CLSID_OEMRENDER)
  725. {
  726. return CLASS_E_CLASSNOTAVAILABLE ;
  727. }
  728. // Create class factory.
  729. IOemCF* pFontCF = new IOemCF ; // Reference count set to 1
  730. // in constructor
  731. if (pFontCF == NULL)
  732. {
  733. return E_OUTOFMEMORY ;
  734. }
  735. // Get requested interface.
  736. HRESULT hr = pFontCF->QueryInterface(iid, ppv);
  737. pFontCF->Release();
  738. return hr ;
  739. }
  740. //
  741. //
  742. // Can DLL unload now?
  743. //
  744. STDAPI
  745. DllCanUnloadNow()
  746. {
  747. if ((g_cComponents == 0) && (g_cServerLocks == 0))
  748. {
  749. return S_OK;
  750. }
  751. else
  752. {
  753. // @Mar/29/2002 ->
  754. // return E_FAIL;
  755. return S_FALSE;
  756. // @Mar/29/2002 <-
  757. }
  758. }