home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / activexcontrol / basectl / todosvr / todosvr.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-05  |  8.7 KB  |  263 lines

  1. //=--------------------------------------------------------------------------=
  2. // ToDoSvr.Cpp
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995-1997  Microsoft Corporation.  All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF 
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO 
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A 
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // various routines et all that aren't in a file for a particular automation
  13. // object, and don't need to be in the generic ole automation code.
  14. //
  15. #define INITOBJECTS                // define the descriptions for our objects
  16.  
  17. #include "IPServer.H"
  18. #include "LocalSrv.H"
  19.  
  20.  
  21. #include "LocalObj.H"
  22. #include "ToDoSvrIfc.H"
  23. #include "CDocObj.H"
  24. #include "Globals.H"
  25. #include "Util.H"
  26. #include "Resource.H"
  27.  
  28. #include "ToDoCtl.H"
  29. #include "ToDoPPG.H"
  30.  
  31. // needed for ASSERTs and FAIL
  32. //
  33. SZTHISFILE
  34.  
  35. //=--------------------------------------------------------------------------=
  36. // our Libid.  This should be the LIBID from the Type library, or NULL if you
  37. // don't have one.
  38. //
  39. const CLSID *g_pLibid = &LIBID_ToDoSvrObjects;
  40.  
  41. //=--------------------------------------------------------------------------=
  42. // Set this up if you want to have a window proc for your parking window. This
  43. // is really only interesting for Sub-classed controls that want, in design
  44. // mode, certain messages that are sent only to the parent window.
  45. //
  46. WNDPROC g_ParkingWindowProc = NULL;
  47.  
  48. //=--------------------------------------------------------------------------=
  49. // Localization Information
  50. //
  51. // We need the following two pieces of information:
  52. //    a. whether or not this DLL uses satellite DLLs for localization.  if
  53. //       not, then the lcidLocale is ignored, and we just always get resources
  54. //       from the server module file.
  55. //    b. the ambient LocaleID for this in-proc server.  Controls calling
  56. //       GetResourceHandle() will set this up automatically, but anybody
  57. //       else will need to be sure that it's set up properly.
  58. //
  59. const VARIANT_BOOL g_fSatelliteLocalization = FALSE;
  60. LCID               g_lcidLocale = MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT);
  61.  
  62.  
  63. //=--------------------------------------------------------------------------=
  64. // your license key and where under HKEY_CLASSES_ROOT_LICENSES it's sitting
  65. //
  66. const WCHAR g_wszLicenseKey [] = L"";
  67. const WCHAR g_wszLicenseLocation [] = L"";
  68.  
  69.  
  70. //=--------------------------------------------------------------------------=
  71. // This Table describes all the automatible objects in your automation server.
  72. // See AutomationObject.H for a description of what goes in this structure
  73. // and what it's used for.
  74. //
  75. // DOCOBJ: Use DOCOBJECT macro to describe our DocObject, not CONTROLOBJECT
  76. //         as usual.
  77. //
  78. OBJECTINFO g_ObjectInfo[] = {
  79.     DOCOBJECT(ToDo),
  80.     PROPERTYPAGE(ToDoGeneral),
  81.     EMPTYOBJECT
  82. };
  83.  
  84. const char g_szLibName[] = "ToDoSvr";
  85.  
  86. //=--------------------------------------------------------------------------=
  87. // InitializeLibrary
  88. //=--------------------------------------------------------------------------=
  89. // called from DllMain:DLL_PROCESS_ATTACH.  allows the user to do any sort of
  90. // initialization they want to.
  91. //
  92. // Notes:
  93. //
  94. void WINAPI InitializeLibrary(void)
  95. {
  96.     // TODO: initialization here.  control window class should be set up in
  97.     // RegisterClassData.
  98. }
  99.  
  100. //=--------------------------------------------------------------------------=
  101. // UninitializeLibrary
  102. //=--------------------------------------------------------------------------=
  103. // called from DllMain:DLL_PROCESS_DETACH.  allows the user to clean up anything
  104. // they want.
  105. //
  106. // Notes:
  107. //
  108. void WINAPI UninitializeLibrary(void)
  109. {
  110.     // TODO: uninitialization here.  control window class will be unregistered
  111.     // for you, but anything else needs to be cleaned up manually.
  112.     // Please Note that the Window 95 DLL_PROCESS_DETACH isn't quite as stable
  113.     // as NT's, and you might crash doing certain things here ...
  114. }
  115.  
  116.  
  117. //=--------------------------------------------------------------------------=
  118. // CheckForLicense
  119. //=--------------------------------------------------------------------------=
  120. // users can implement this if they wish to support Licensing.  otherwise,
  121. // they can just return TRUE all the time.
  122. //
  123. // Parameters:
  124. //    none
  125. //
  126. // Output:
  127. //    BOOL            - TRUE means the license exists, and we can proceed
  128. //                      FALSE means we're not licensed and cannot proceed
  129. //
  130. // Notes:
  131. //    - implementers should use g_wszLicenseKey and g_wszLicenseLocation
  132. //      from the top of this file to define their licensing [the former
  133. //      is necessary, the latter is recommended]
  134. //
  135. BOOL WINAPI CheckForLicense(void)
  136. {
  137.     // TODO: you should make sure the machine has your license key here.
  138.     // this is typically done by looking in the registry.
  139.     //
  140.     return TRUE;
  141. }
  142.  
  143. //=--------------------------------------------------------------------------=
  144. // CheckLicenseKey
  145. //=--------------------------------------------------------------------------=
  146. // when IClassFactory2::CreateInstanceLic is called, a license key is passed
  147. // in, and then passed on to this routine.  users should return a boolean 
  148. // indicating whether it is a valid license key or not
  149. //
  150. // Parameters:
  151. //    LPWSTR          - [in] the key to check
  152. //
  153. // Output:
  154. //    BOOL            - false means it's not valid, true otherwise
  155. //
  156. // Notes:
  157. //
  158. BOOL WINAPI CheckLicenseKey(LPWSTR pwszKey)
  159. {
  160.     // TODO: check the license key against your values here and make sure it's
  161.     // valid.
  162.     //
  163.     return TRUE;
  164. }
  165.  
  166. //=--------------------------------------------------------------------------=
  167. // GetLicenseKey
  168. //=--------------------------------------------------------------------------=
  169. // returns our current license key that should be saved out, and then passed
  170. // back to us in IClassFactory2::CreateInstanceLic
  171. //
  172. // Parameters:
  173. //    none
  174. //
  175. // Output:
  176. //    BSTR                 - key or NULL if Out of memory
  177. //
  178. // Notes:
  179. //
  180. BSTR WINAPI GetLicenseKey(void)
  181. {
  182.     // TODO: return your license key here.
  183.     //
  184.     return SysAllocString(L"");
  185. }
  186.  
  187. //=--------------------------------------------------------------------------=
  188. // RegisterData
  189. //=--------------------------------------------------------------------------=
  190. // lets the inproc server writer register any data in addition to that in
  191. // any other objects.
  192. //
  193. // Output:
  194. //    BOOL            - false means failure.
  195. //
  196. // Notes:
  197. //
  198. BOOL WINAPI RegisterData(void)
  199. {
  200.     // DOCOBJ: DocObjects need some additional registry entries.
  201.     //         Register them here!
  202.  
  203.     // read file extension and file description strings from resources
  204.     char szExt[20];
  205.     if (!LoadString(GetResourceHandle(),  
  206.                     DEFAULTEXTIDOFDOCOBJECT(OBJECT_TYPE_CTLTODO),
  207.                     szExt,
  208.                     sizeof(szExt)))
  209.         szExt[0] = '\0';
  210.  
  211.     char szDesc[40];
  212.     if (!LoadString(GetResourceHandle(),  
  213.                     FILEDESCRIPTIONIDOFDOCOBJECT(OBJECT_TYPE_CTLTODO),
  214.                     szDesc,
  215.                     sizeof(szDesc)))
  216.         szDesc[0] = '\0';
  217.  
  218.     // register special docobj keys
  219.     return RegisterDocObject(g_szLibName, NAMEOFOBJECT(OBJECT_TYPE_CTLTODO),
  220.                              CLSIDOFOBJECT(OBJECT_TYPE_CTLTODO), 
  221.                              MISCFLAGSOFDOCOBJECT(OBJECT_TYPE_CTLTODO),
  222.                              PRINTOFDOCOBJECT(OBJECT_TYPE_CTLTODO),
  223.                              szExt, szDesc);
  224. }
  225.  
  226. //=--------------------------------------------------------------------------=
  227. // UnregisterData
  228. //=--------------------------------------------------------------------------=
  229. // inproc server writers should unregister anything they registered in
  230. // RegisterData() here.
  231. //
  232. // Output:
  233. //    BOOL            - false means failure.
  234. //
  235. // Notes:
  236. //
  237. BOOL WINAPI UnregisterData(void)
  238. {
  239.     // TODO: any additional registry cleanup that you might wish to do.
  240.     //
  241.     return TRUE;
  242. }
  243.  
  244.  
  245. //=--------------------------------------------------------------------------=
  246. // CRT stubs
  247. //=--------------------------------------------------------------------------=
  248. // these two things are here so the CRTs aren't needed. this is good.
  249. //
  250. // basically, the CRTs define this to suck in a bunch of stuff.  we'll just
  251. // define them here so we don't get an unresolved external.
  252. //
  253. // TODO: if you are going to use the CRTs, then remove this line.
  254. //
  255. // extern "C" int _fltused = 1;
  256.  
  257. extern "C" int _purecall(void)
  258. {
  259.   FAIL("Pure virtual function called.");
  260.   return 0;
  261. }
  262.  
  263.