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.

465 lines
14 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1999 **
  4. //*********************************************************************
  5. //
  6. // Status.CPP - Header for the implementation of CStatus
  7. //
  8. // HISTORY:
  9. //
  10. // 1/27/99 a-jaswed Created.
  11. //
  12. #include "status.h"
  13. #include "appdefs.h"
  14. #include "dispids.h"
  15. #include "msobmain.h"
  16. #include "resource.h"
  17. CONST WCHAR GUIDPIDCOMPLETED[] = L"{2B7AF08A-C619-11d2-B71B-00C04F794977}";
  18. CONST WCHAR GUIDTAPICOMPLETED[] = L"{2B7AF08B-C619-11d2-B71B-00C04F794977}";
  19. CONST WCHAR GUIDLANGUAGECOMPLETED[]
  20. = L"{2B7AF08C-C619-11d2-B71B-00C04F794977}";
  21. CONST WCHAR GUIDEULACOMPLETED[] = L"{2B7AF08D-C619-11d2-B71B-00C04F794977}";
  22. CONST WCHAR GUIDMOUSETUTORCOMPLETED[]
  23. = L"{2B7AF08E-C619-11d2-B71B-00C04F794977}";
  24. CONST WCHAR GUIDUSERINFOPOSTED[]
  25. = L"{2B7AF08F-C619-11d2-B71B-00C04F794977}";
  26. CONST WCHAR GUIDUSERINFOSTAMPED[]
  27. = L"{2B7AF093-C619-11d2-B71B-00C04F794977}";
  28. CONST WCHAR GUIDOEMINFOCOMPLETED[]
  29. = L"{2B7AF090-C619-11d2-B71B-00C04F794977}";
  30. CONST WCHAR GUIDISPSIGNUPCOMPLETED[]
  31. = L"{2B7AF091-C619-11d2-B71B-00C04F794977}";
  32. CONST WCHAR GUIDSIGNATURECOMPLETED[]
  33. = L"{2B7AF092-C619-11d2-B71B-00C04F794977}";
  34. CONST WCHAR GUIDTIMEZONECOMPLETED[]
  35. = L"{23EC9481-C951-11d2-B275-0080C7CF863E}";
  36. DISPATCHLIST StatusExternalInterface[] =
  37. {
  38. {L"get_PIDCompleted", DISPID_STATUS_GET_PID_COMPLETED },
  39. {L"set_PIDCompleted", DISPID_STATUS_SET_PID_COMPLETED },
  40. {L"get_TAPICompleted", DISPID_STATUS_GET_TAPI_COMPLETED },
  41. {L"set_TAPICompleted", DISPID_STATUS_SET_TAPI_COMPLETED },
  42. {L"get_LanguageCompleted", DISPID_STATUS_GET_LANGUAGE_COMPLETED },
  43. {L"set_LanguageCompleted", DISPID_STATUS_SET_LANGUAGE_COMPLETED },
  44. {L"get_EULACompleted", DISPID_STATUS_GET_EULA_COMPLETED },
  45. {L"set_EULACompleted", DISPID_STATUS_SET_EULA_COMPLETED },
  46. {L"get_MouseTutorCompleted",DISPID_STATUS_GET_MOUSETUTOR_COMPLETED },
  47. {L"set_MouseTutorCompleted",DISPID_STATUS_SET_MOUSETUTOR_COMPLETED },
  48. {L"get_UserInfoPosted", DISPID_STATUS_GET_USERINFO_POSTED },
  49. {L"set_UserInfoPosted", DISPID_STATUS_SET_USERINFO_POSTED },
  50. {L"get_UserInfoStamped", DISPID_STATUS_GET_USERINFO_STAMPED },
  51. {L"set_UserInfoStamped", DISPID_STATUS_SET_USERINFO_STAMPED },
  52. {L"get_OEMInfoCompleted", DISPID_STATUS_GET_OEMINFO_COMPLETED },
  53. {L"set_OEMInfoCompleted", DISPID_STATUS_SET_OEMINFO_COMPLETED },
  54. {L"get_ISPSignupCompleted", DISPID_STATUS_GET_ISPSIGNUP_COMPLETED },
  55. {L"set_ISPSignupCompleted", DISPID_STATUS_SET_ISPSIGNUP_COMPLETED },
  56. {L"get_SignatureCompleted", DISPID_STATUS_GET_SIGNATURE_COMPLETED },
  57. {L"set_SignatureCompleted", DISPID_STATUS_SET_SIGNATURE_COMPLETED },
  58. {L"get_TimeZoneCompleted", DISPID_STATUS_GET_TIMEZONE_COMPLETED },
  59. {L"set_TimeZoneCompleted", DISPID_STATUS_SET_TIMEZONE_COMPLETED },
  60. {L"get_Status", DISPID_STATUS_GET_STATUS },
  61. {L"set_Status", DISPID_STATUS_SET_STATUS }
  62. };
  63. /////////////////////////////////////////////////////////////
  64. // CStatus::CStatus
  65. CStatus::CStatus(HINSTANCE hInstance)
  66. {
  67. // Init member vars
  68. m_cRef = 0;
  69. lstrcpy(m_szRegPath, OOBE_MAIN_REG_KEY);
  70. GetString(hInstance, IDS_STATUS_REG_KEY, m_szRegPath + lstrlen(m_szRegPath));
  71. }
  72. /////////////////////////////////////////////////////////////
  73. // CStatus::~CStatus
  74. CStatus::~CStatus()
  75. {
  76. assert(m_cRef == 0);
  77. }
  78. ////////////////////////////////////////////////
  79. ////////////////////////////////////////////////
  80. //// GET / SET :: Status
  81. ////
  82. HRESULT CStatus::set_Status(LPCWSTR szGUID, LPVARIANT pvBool)
  83. {
  84. HKEY hKey = NULL;
  85. LONG rc = ERROR_SUCCESS;
  86. if (VARIANT_TRUE == V_BOOL(pvBool))
  87. {
  88. WCHAR szCompletePath[1024];
  89. lstrcpy(szCompletePath, m_szRegPath);
  90. lstrcat(szCompletePath, L"\\");
  91. lstrcat(szCompletePath, szGUID);
  92. rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, szCompletePath, 0,
  93. NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
  94. }
  95. else
  96. {
  97. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  98. m_szRegPath,
  99. 0,
  100. KEY_QUERY_VALUE,
  101. &hKey))
  102. RegDeleteKey(hKey, szGUID);
  103. }
  104. if (NULL != hKey)
  105. RegCloseKey(hKey);
  106. return (ERROR_SUCCESS == rc ? S_OK : E_FAIL);
  107. }
  108. HRESULT CStatus::get_Status(LPCWSTR szGUID, LPVARIANT pvBool)
  109. {
  110. VariantInit(pvBool);
  111. V_VT(pvBool) = VT_BOOL;
  112. HKEY hKey;
  113. WCHAR szCompletePath[1024];
  114. lstrcpy(szCompletePath, m_szRegPath);
  115. lstrcat(szCompletePath, L"\\");
  116. lstrcat(szCompletePath, szGUID);
  117. if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  118. szCompletePath,
  119. 0,
  120. KEY_QUERY_VALUE,
  121. &hKey))
  122. {
  123. V_BOOL(pvBool) = VARIANT_TRUE;
  124. RegCloseKey(hKey);
  125. }
  126. else
  127. V_BOOL(pvBool) = VARIANT_FALSE;
  128. return (S_OK);
  129. }
  130. /////////////////////////////////////////////////////////////
  131. /////////////////////////////////////////////////////////////
  132. /////////////////////////////////////////////////////////////
  133. /////// IUnknown implementation
  134. ///////
  135. ///////
  136. /////////////////////////////////////////////////////////////
  137. // CStatus::QueryInterface
  138. STDMETHODIMP CStatus::QueryInterface(REFIID riid, LPVOID* ppvObj)
  139. {
  140. // must set out pointer parameters to NULL
  141. *ppvObj = NULL;
  142. if ( riid == IID_IUnknown)
  143. {
  144. AddRef();
  145. *ppvObj = (IUnknown*)this;
  146. return ResultFromScode(S_OK);
  147. }
  148. if (riid == IID_IDispatch)
  149. {
  150. AddRef();
  151. *ppvObj = (IDispatch*)this;
  152. return ResultFromScode(S_OK);
  153. }
  154. // Not a supported interface
  155. return ResultFromScode(E_NOINTERFACE);
  156. }
  157. /////////////////////////////////////////////////////////////
  158. // CStatus::AddRef
  159. STDMETHODIMP_(ULONG) CStatus::AddRef()
  160. {
  161. return ++m_cRef;
  162. }
  163. /////////////////////////////////////////////////////////////
  164. // CStatus::Release
  165. STDMETHODIMP_(ULONG) CStatus::Release()
  166. {
  167. return --m_cRef;
  168. }
  169. /////////////////////////////////////////////////////////////
  170. /////////////////////////////////////////////////////////////
  171. /////////////////////////////////////////////////////////////
  172. /////// IDispatch implementation
  173. ///////
  174. ///////
  175. /////////////////////////////////////////////////////////////
  176. // CStatus::GetTypeInfo
  177. STDMETHODIMP CStatus::GetTypeInfo(UINT, LCID, ITypeInfo**)
  178. {
  179. return E_NOTIMPL;
  180. }
  181. /////////////////////////////////////////////////////////////
  182. // CStatus::GetTypeInfoCount
  183. STDMETHODIMP CStatus::GetTypeInfoCount(UINT* pcInfo)
  184. {
  185. return E_NOTIMPL;
  186. }
  187. /////////////////////////////////////////////////////////////
  188. // CStatus::GetIDsOfNames
  189. STDMETHODIMP CStatus::GetIDsOfNames(REFIID riid,
  190. OLECHAR** rgszNames,
  191. UINT cNames,
  192. LCID lcid,
  193. DISPID* rgDispId)
  194. {
  195. HRESULT hr = DISP_E_UNKNOWNNAME;
  196. rgDispId[0] = DISPID_UNKNOWN;
  197. for (int iX = 0; iX < sizeof(StatusExternalInterface)/sizeof(DISPATCHLIST); iX ++)
  198. {
  199. if(lstrcmp(StatusExternalInterface[iX].szName, rgszNames[0]) == 0)
  200. {
  201. rgDispId[0] = StatusExternalInterface[iX].dwDispID;
  202. hr = NOERROR;
  203. break;
  204. }
  205. }
  206. // Set the disid's for the parameters
  207. if (cNames > 1)
  208. {
  209. // Set a DISPID for function parameters
  210. for (UINT i = 1; i < cNames ; i++)
  211. rgDispId[i] = DISPID_UNKNOWN;
  212. }
  213. return hr;
  214. }
  215. /////////////////////////////////////////////////////////////
  216. // CStatus::Invoke
  217. HRESULT CStatus::Invoke
  218. (
  219. DISPID dispidMember,
  220. REFIID riid,
  221. LCID lcid,
  222. WORD wFlags,
  223. DISPPARAMS* pdispparams,
  224. VARIANT* pvarResult,
  225. EXCEPINFO* pexcepinfo,
  226. UINT* puArgErr
  227. )
  228. {
  229. HRESULT hr = S_OK;
  230. switch(dispidMember)
  231. {
  232. case DISPID_STATUS_GET_PID_COMPLETED:
  233. TRACE(L"DISPID_STATUS_GET_PID_COMPLETED\n");
  234. if (NULL != pvarResult)
  235. get_Status(GUIDPIDCOMPLETED, pvarResult);
  236. break;
  237. case DISPID_STATUS_GET_TAPI_COMPLETED:
  238. TRACE(L"DISPID_STATUS_GET_TAPI_COMPLETED\n");
  239. if (NULL != pvarResult)
  240. get_Status(GUIDTAPICOMPLETED, pvarResult);
  241. break;
  242. case DISPID_STATUS_GET_LANGUAGE_COMPLETED:
  243. TRACE(L"DISPID_STATUS_GET_LANGUAGE_COMPLETED\n");
  244. if (NULL != pvarResult)
  245. get_Status(GUIDLANGUAGECOMPLETED, pvarResult);
  246. break;
  247. case DISPID_STATUS_GET_EULA_COMPLETED:
  248. TRACE(L"DISPID_STATUS_GET_EULA_COMPLETED\n");
  249. if (NULL != pvarResult)
  250. get_Status(GUIDEULACOMPLETED, pvarResult);
  251. break;
  252. case DISPID_STATUS_GET_MOUSETUTOR_COMPLETED:
  253. TRACE(L"DISPID_STATUS_GET_MOUSETUTOR_COMPLETED\n");
  254. if (NULL != pvarResult)
  255. get_Status(GUIDMOUSETUTORCOMPLETED, pvarResult);
  256. break;
  257. case DISPID_STATUS_GET_USERINFO_POSTED:
  258. TRACE(L"DISPID_STATUS_GET_USERINFO_POSTED\n");
  259. if (NULL != pvarResult)
  260. get_Status(GUIDUSERINFOPOSTED, pvarResult);
  261. break;
  262. case DISPID_STATUS_GET_USERINFO_STAMPED:
  263. TRACE(L"DISPID_STATUS_GET_USERINFO_STAMPED\n");
  264. if (NULL != pvarResult)
  265. get_Status(GUIDUSERINFOSTAMPED, pvarResult);
  266. break;
  267. case DISPID_STATUS_GET_OEMINFO_COMPLETED:
  268. TRACE(L"DISPID_STATUS_GET_OEMINFO_COMPLETED\n");
  269. if (NULL != pvarResult)
  270. get_Status(GUIDOEMINFOCOMPLETED, pvarResult);
  271. break;
  272. case DISPID_STATUS_GET_ISPSIGNUP_COMPLETED:
  273. TRACE(L"DISPID_STATUS_GET_ISPSIGNUP_COMPLETED\n");
  274. if (NULL != pvarResult)
  275. get_Status(GUIDISPSIGNUPCOMPLETED, pvarResult);
  276. break;
  277. case DISPID_STATUS_GET_SIGNATURE_COMPLETED:
  278. TRACE(L"DISPID_STATUS_GET_SIGNATURE_COMPLETED\n");
  279. if (NULL != pvarResult)
  280. get_Status(GUIDSIGNATURECOMPLETED, pvarResult);
  281. break;
  282. case DISPID_STATUS_GET_TIMEZONE_COMPLETED:
  283. TRACE(L"DISPID_STATUS_GET_TIMEZONE_COMPLETED\n");
  284. if (NULL != pvarResult)
  285. get_Status(GUIDTIMEZONECOMPLETED, pvarResult);
  286. break;
  287. case DISPID_STATUS_GET_STATUS:
  288. TRACE(L"DISPID_STATUS_GET_STATUS\n");
  289. if (NULL != pdispparams && NULL != pvarResult && 0 < pdispparams->cArgs)
  290. get_Status(V_BSTR(pdispparams->rgvarg), pvarResult);
  291. break;
  292. case DISPID_STATUS_SET_PID_COMPLETED:
  293. TRACE(L"DISPID_STATUS_SET_PID_COMPLETED\n");
  294. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  295. set_Status(GUIDPIDCOMPLETED, pdispparams->rgvarg);
  296. break;
  297. case DISPID_STATUS_SET_TAPI_COMPLETED:
  298. TRACE(L"DISPID_STATUS_SET_TAPI_COMPLETED\n");
  299. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  300. set_Status(GUIDTAPICOMPLETED, pdispparams->rgvarg);
  301. break;
  302. case DISPID_STATUS_SET_LANGUAGE_COMPLETED:
  303. TRACE(L"DISPID_STATUS_SET_LANGUAGE_COMPLETED\n");
  304. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  305. set_Status(GUIDLANGUAGECOMPLETED, pdispparams->rgvarg);
  306. break;
  307. case DISPID_STATUS_SET_EULA_COMPLETED:
  308. TRACE(L"DISPID_STATUS_SET_EULA_COMPLETED\n");
  309. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  310. set_Status(GUIDEULACOMPLETED, pdispparams->rgvarg);
  311. break;
  312. case DISPID_STATUS_SET_MOUSETUTOR_COMPLETED:
  313. TRACE(L"DISPID_STATUS_SET_MOUSETUTOR_COMPLETED\n");
  314. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  315. set_Status(GUIDMOUSETUTORCOMPLETED, pdispparams->rgvarg);
  316. break;
  317. case DISPID_STATUS_SET_USERINFO_POSTED:
  318. TRACE(L"DISPID_STATUS_SET_USERINFO_POSTED\n");
  319. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  320. set_Status(GUIDUSERINFOPOSTED, pdispparams->rgvarg);
  321. break;
  322. case DISPID_STATUS_SET_USERINFO_STAMPED:
  323. TRACE(L"DISPID_STATUS_SET_USERINFO_STAMPED\n");
  324. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  325. set_Status(GUIDUSERINFOSTAMPED, pdispparams->rgvarg);
  326. break;
  327. case DISPID_STATUS_SET_OEMINFO_COMPLETED:
  328. TRACE(L"DISPID_STATUS_SET_OEMINFO_COMPLETED\n");
  329. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  330. set_Status(GUIDOEMINFOCOMPLETED, pdispparams->rgvarg);
  331. break;
  332. case DISPID_STATUS_SET_ISPSIGNUP_COMPLETED:
  333. TRACE(L"DISPID_STATUS_SET_ISPSIGNUP_COMPLETED\n");
  334. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  335. set_Status(GUIDISPSIGNUPCOMPLETED, pdispparams->rgvarg);
  336. break;
  337. case DISPID_STATUS_SET_SIGNATURE_COMPLETED:
  338. TRACE(L"DISPID_STATUS_SET_SIGNATURE_COMPLETED\n");
  339. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  340. set_Status(GUIDSIGNATURECOMPLETED, pdispparams->rgvarg);
  341. break;
  342. case DISPID_STATUS_SET_TIMEZONE_COMPLETED:
  343. TRACE(L"DISPID_STATUS_SET_TIMEZONE_COMPLETED\n");
  344. if (NULL != pdispparams && 0 < pdispparams->cArgs)
  345. set_Status(GUIDTIMEZONECOMPLETED, pdispparams->rgvarg);
  346. break;
  347. case DISPID_STATUS_SET_STATUS:
  348. TRACE(L"DISPID_STATUS_SET_STATUS\n");
  349. if (NULL != pdispparams && 1 < pdispparams->cArgs)
  350. set_Status(V_BSTR(&pdispparams->rgvarg[1]), &pdispparams->rgvarg[0]);
  351. break;
  352. default:
  353. {
  354. hr = DISP_E_MEMBERNOTFOUND;
  355. break;
  356. }
  357. }
  358. return hr;
  359. }