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.

841 lines
27 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1993.
  5. //
  6. // File: oletest.cpp
  7. //
  8. // Contents: WinMain and the main message filter for oletest
  9. //
  10. // Classes:
  11. //
  12. // Functions: WinMain
  13. // InitApplication
  14. // InitInstance
  15. // MainWndProc
  16. //
  17. //
  18. // History: dd-mmm-yy Author Comment
  19. //
  20. //--------------------------------------------------------------------------
  21. #include "oletest.h"
  22. #include "appwin.h"
  23. #define MAX_WM_USER 0x7FFF
  24. // Global instance of the app class. All interesting app-wide
  25. // data is contained within this instance.
  26. OleTestApp vApp;
  27. // Constant used to identify the edit window
  28. static const int EDITID=1;
  29. //
  30. // Misc internal prototypes
  31. //
  32. void ListAllTests();
  33. void PrintHelp();
  34. //+-------------------------------------------------------------------------
  35. //
  36. // Function: MainWndProc
  37. //
  38. // Synopsis: main window message filter
  39. //
  40. // Effects:
  41. //
  42. // Arguments: hWnd
  43. // message
  44. // wParam
  45. // lParam
  46. //
  47. // Requires:
  48. //
  49. // Returns:
  50. //
  51. // Signals:
  52. //
  53. // Modifies:
  54. //
  55. // Algorithm:
  56. //
  57. // History: dd-mmm-yy Author Comment
  58. // 09-Dec-94 MikeW Allow running of single tests from menu
  59. // 22-Mar-94 alexgo added an edit window for displaying text
  60. // output.
  61. // 07-Feb-94 alexgo author
  62. //
  63. // Notes:
  64. //
  65. //--------------------------------------------------------------------------
  66. #ifdef WIN32
  67. LONG APIENTRY MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam)
  68. #else
  69. LONG FAR PASCAL _export MainWndProc(HWND hWnd, UINT message, WPARAM wParam,
  70. LPARAM lParam)
  71. #endif
  72. {
  73. //set global variables
  74. if( (message > WM_USER) && (message <= MAX_WM_USER) )
  75. {
  76. vApp.m_message = message;
  77. vApp.m_wparam = wParam;
  78. vApp.m_lparam = lParam;
  79. }
  80. switch (message)
  81. {
  82. case WM_CREATE:
  83. //create the edit window
  84. vApp.m_hwndEdit = CreateWindow( "edit", NULL,
  85. WS_CHILD | WS_VISIBLE | WS_HSCROLL |
  86. WS_VSCROLL | WS_BORDER | ES_LEFT |
  87. ES_MULTILINE | ES_NOHIDESEL | ES_AUTOHSCROLL |
  88. ES_AUTOVSCROLL | ES_READONLY | ES_WANTRETURN,
  89. 0,0,0,0,
  90. hWnd,(HMENU) EDITID, vApp.m_hinst, NULL );
  91. // Reset the error status
  92. vApp.m_fGotErrors = FALSE;
  93. // start the task stack running
  94. // note that if we are running interactive, and no
  95. // tasks were specified on the command line, nothing
  96. // will happen.
  97. PostMessage(hWnd, WM_TESTSTART, 0,0);
  98. break;
  99. case WM_SETFOCUS:
  100. SetFocus(vApp.m_hwndEdit);
  101. break;
  102. case WM_SIZE:
  103. MoveWindow( vApp.m_hwndEdit, 0, 0, LOWORD(lParam),
  104. HIWORD(lParam), TRUE);
  105. break;
  106. case WM_DESTROY:
  107. PostQuitMessage(0);
  108. break;
  109. case WM_TESTEND:
  110. HandleTestEnd();
  111. break;
  112. case WM_TESTSCOMPLETED:
  113. HandleTestsCompleted();
  114. //if we are not in interactive mode, then
  115. //quit the app.
  116. if (!vApp.m_fInteractive)
  117. {
  118. PostQuitMessage(0);
  119. }
  120. else
  121. {
  122. //cleanup
  123. vApp.Reset();
  124. }
  125. break;
  126. case WM_COMMAND:
  127. switch( wParam )
  128. {
  129. case IDM_EXIT:
  130. SendMessage(hWnd, WM_CLOSE, 0, 0L);
  131. break;
  132. case IDM_COPY:
  133. SendMessage(vApp.m_hwndEdit, WM_COPY, 0, 0L);
  134. break;
  135. case IDM_SAVE:
  136. SaveToFile();
  137. break;
  138. }
  139. //
  140. // if the user picked a test, run it
  141. // > 100 tests wouldn't fit on the menu anyway
  142. //
  143. if (wParam >= IDM_RUN_BASE && wParam < IDM_RUN_BASE + 100)
  144. {
  145. vApp.m_TaskStack.Push(&vrgTaskList[wParam - IDM_RUN_BASE]);
  146. vApp.m_TaskStack.PopAndExecute(NULL);
  147. }
  148. break;
  149. default:
  150. //test to see if it's a message the driver
  151. //may understand
  152. if( (message > WM_USER) && (message <= MAX_WM_USER)
  153. && (!vApp.m_TaskStack.IsEmpty()) )
  154. {
  155. vApp.m_TaskStack.PopAndExecute(NULL);
  156. }
  157. else
  158. {
  159. return DefWindowProc(hWnd, message, wParam,
  160. lParam);
  161. }
  162. break;
  163. }
  164. return (0);
  165. }
  166. //+-------------------------------------------------------------------------
  167. //
  168. // Function: InitApplication
  169. //
  170. // Synopsis: initializes and registers the application class
  171. //
  172. // Effects:
  173. //
  174. // Arguments:
  175. //
  176. // Requires:
  177. //
  178. // Returns:
  179. //
  180. // Signals:
  181. //
  182. // Modifies:
  183. //
  184. // Algorithm:
  185. //
  186. // History: dd-mmm-yy Author Comment
  187. // 06-Feb-93 alexgo author
  188. //
  189. // Notes:
  190. //
  191. //--------------------------------------------------------------------------
  192. BOOL InitApplication(HINSTANCE hInstance)
  193. {
  194. WNDCLASS wc;
  195. wc.style = 0;
  196. wc.lpfnWndProc = MainWndProc;
  197. wc.cbClsExtra = 0;
  198. wc.cbWndExtra = 0;
  199. wc.hInstance = hInstance;
  200. wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
  201. wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
  202. wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
  203. wc.lpszMenuName = "OleTestMenu";
  204. wc.lpszClassName = "OleTestWClass";
  205. return (RegisterClass(&wc));
  206. }
  207. //+-------------------------------------------------------------------------
  208. //
  209. // Function: InitInstance
  210. //
  211. // Synopsis: creates the app window
  212. //
  213. // Effects:
  214. //
  215. // Arguments: hInstance
  216. // nCmdShow
  217. //
  218. // Requires:
  219. //
  220. // Returns:
  221. //
  222. // Signals:
  223. //
  224. // Modifies:
  225. //
  226. // Algorithm:
  227. //
  228. // History: dd-mmm-yy Author Comment
  229. // 06-Feb-94 alexgo author
  230. // 09-Dec-94 MikeW add tests to the run menu
  231. //
  232. // Notes:
  233. //
  234. //--------------------------------------------------------------------------
  235. BOOL InitInstance(
  236. HINSTANCE hInstance,
  237. UINT nCmdShow)
  238. {
  239. int nTask;
  240. HMENU hMenu;
  241. vApp.m_hinst = hInstance;
  242. vApp.m_hwndMain = CreateWindow(
  243. "OleTestWClass",
  244. "OleTest Driver",
  245. WS_OVERLAPPEDWINDOW,
  246. CW_USEDEFAULT,
  247. CW_USEDEFAULT,
  248. CW_USEDEFAULT,
  249. CW_USEDEFAULT,
  250. NULL,
  251. NULL,
  252. hInstance,
  253. NULL
  254. );
  255. if (!vApp.m_hwndMain)
  256. return (FALSE);
  257. hMenu = GetSubMenu(GetMenu(vApp.m_hwndMain), 2);
  258. if (!hMenu)
  259. return (FALSE);
  260. //
  261. // Add all of the tests to the "Run" menu
  262. //
  263. for (nTask = 0; vrgTaskList[nTask].szName != (LPSTR) 0; nTask++)
  264. {
  265. AppendMenu(hMenu,
  266. MF_STRING,
  267. IDM_RUN_BASE + nTask,
  268. vrgTaskList[nTask].szName);
  269. }
  270. ShowWindow(vApp.m_hwndMain, nCmdShow);
  271. UpdateWindow(vApp.m_hwndMain);
  272. return (TRUE);
  273. }
  274. //+-------------------------------------------------------------------------
  275. //
  276. // Table: regConfig
  277. //
  278. // Synopsis: Table of registry settings required to run OleTest.
  279. //
  280. // History: dd-mmm-yy Author Comment
  281. // 08-Nov-94 KentCe Created.
  282. //
  283. // Notes: The registry template contains embedded "%s" to permit
  284. // the insertion of the full path of test binaries when the
  285. // registry is updated.
  286. //
  287. // The registry template is passed to wsprintf as an argument
  288. // so verify that changes are wsprintf safe (ie, use %% when
  289. // you want a single %, etc).
  290. //
  291. //--------------------------------------------------------------------------
  292. char * regConfig[] =
  293. {
  294. ".ut1", "ProgID49",
  295. ".ut2", "ProgID48",
  296. ".ut3", "ProgID47",
  297. ".ut4", "ProgID50",
  298. "ProgID49", "test app 1",
  299. "ProgID49\\CLSID", "{99999999-0000-0008-C000-000000000049}",
  300. "ProgID48", "test app 2",
  301. "ProgID48\\CLSID", "{99999999-0000-0008-C000-000000000048}",
  302. "ProgID47", "test app 3",
  303. "ProgID47\\CLSID", "{99999999-0000-0008-C000-000000000047}",
  304. "ProgID50", "test app 4",
  305. "ProgID50\\CLSID", "{99999999-0000-0008-C000-000000000050}",
  306. "CLSID\\{00000009-0000-0008-C000-000000000047}", "BasicSrv",
  307. "CLSID\\{00000009-0000-0008-C000-000000000047}\\LocalServer32", "%s\\testsrv.exe",
  308. "CLSID\\{00000009-0000-0008-C000-000000000048}", "BasicBnd2",
  309. "CLSID\\{00000009-0000-0008-C000-000000000048}\\LocalServer32", "%s\\olesrv.exe",
  310. "CLSID\\{00000009-0000-0008-C000-000000000049}", "BasicBnd",
  311. "CLSID\\{00000009-0000-0008-C000-000000000049}\\InprocServer32", "%s\\oleimpl.dll",
  312. "CLSID\\{99999999-0000-0008-C000-000000000048}", "BasicBnd2",
  313. "CLSID\\{99999999-0000-0008-C000-000000000048}\\LocalServer32", "%s\\olesrv.exe",
  314. "CLSID\\{99999999-0000-0008-C000-000000000049}", "BasicBnd",
  315. "CLSID\\{99999999-0000-0008-C000-000000000049}\\InprocServer32", "%s\\oleimpl.dll",
  316. "CLSID\\{99999999-0000-0008-C000-000000000047}", "TestEmbed",
  317. "CLSID\\{99999999-0000-0008-C000-000000000047}\\InprocHandler32", "ole32.dll",
  318. "CLSID\\{99999999-0000-0008-C000-000000000047}\\InprocServer32", "ole32.dll",
  319. "CLSID\\{99999999-0000-0008-C000-000000000047}\\LocalServer32", "%s\\testsrv.exe",
  320. "CLSID\\{99999999-0000-0008-C000-000000000047}\\protocol\\StdFileEditing", "",
  321. "CLSID\\{99999999-0000-0008-C000-000000000047}\\protocol\\StdFileEditing\\server", "testsrv.exe",
  322. "CLSID\\{99999999-0000-0008-C000-000000000050}", "TestFail",
  323. "CLSID\\{99999999-0000-0008-C000-000000000050}\\LocalServer32", "%s\\fail.exe",
  324. "SIMPSVR", "Simple OLE 2.0 Server",
  325. "SIMPSVR\\protocol\\StdFileEditing\\server", "simpsvr.exe",
  326. "SIMPSVR\\protocol\\StdFileEditing\\verb\\0", "&Edit",
  327. "SIMPSVR\\protocol\\StdFileEditing\\verb\\1", "&Open",
  328. "SIMPSVR\\Insertable", "",
  329. "SIMPSVR\\CLSID", "{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}",
  330. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}", "Simple OLE 2.0 Server",
  331. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\Insertable", "",
  332. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\MiscStatus", "0",
  333. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\DefaultIcon", "simpsvr.exe,0",
  334. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\AuxUserType\\2", "Simple Server",
  335. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\AuxUserType\\3", "Simple OLE 2.0 Server",
  336. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\Verb\\0", "&Play,0,2",
  337. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\Verb\\1", "&Open,0,2",
  338. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\LocalServer32", "%s\\simpsvr.exe",
  339. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\InprocHandler32", "ole32.dll",
  340. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\ProgID", "SIMPSVR",
  341. "CLSID\\{BCF6D4A0-BE8C-1068-B6D4-00DD010C0509}\\DataFormats\\GetSet\\0", "3,1,32,1",
  342. ".svr", "SIMPSVR",
  343. "SPSVR16", "Simple 16 Bit OLE 2.0 Server",
  344. "SPSVR16\\protocol\\StdFileEditing\\server", "spsvr16.exe",
  345. "SPSVR16\\protocol\\StdFileEditing\\verb\\0", "&Edit",
  346. "SPSVR16\\protocol\\StdFileEditing\\verb\\1", "&Open",
  347. "SPSVR16\\Insertable", "",
  348. "SPSVR16\\CLSID", "{9fb878d0-6f88-101b-bc65-00000b65c7a6}",
  349. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}", "Simple 16 Bit OLE 2.0 Server",
  350. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\Insertable", "",
  351. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\MiscStatus", "0",
  352. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\DefaultIcon", "spsvr16.exe,0",
  353. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\AuxUserType\\2", "Simple Server",
  354. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\AuxUserType\\3", "Simple 16 Bit OLE 2.0 Server",
  355. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\Verb\\0", "&Play,0,2",
  356. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\Verb\\1", "&Open,0,2",
  357. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\LocalServer", "%s\\spsvr16.exe",
  358. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\InprocHandler", "ole2.dll",
  359. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\ProgID", "SPSVR16",
  360. "CLSID\\{9fb878d0-6f88-101b-bc65-00000b65c7a6}\\DataFormats\\GetSet\\0", "3,1,32,1",
  361. ".svr", "SPSVR16",
  362. "OLEOutline", "Ole 2.0 In-Place Server Outline",
  363. "OLEOutline\\CLSID", "{00000402-0000-0000-C000-000000000046}",
  364. "OLEOutline\\CurVer", "OLE2ISvrOtl",
  365. "OLEOutline\\CurVer\\Insertable", "",
  366. "OLE2SvrOutl", "Ole 2.0 Server Sample Outline",
  367. "OLE2SvrOutl\\CLSID", "{00000400-0000-0000-C000-000000000046}",
  368. "OLE2SvrOutl\\Insertable", "",
  369. "OLE2SvrOutl\\protocol\\StdFileEditing\\verb\\0", "&Edit",
  370. "OLE2SvrOutl\\protocol\\StdFileEditing\\server", "svroutl.exe",
  371. "OLE2SvrOutl\\Shell\\Print\\Command", "svroutl.exe %%1",
  372. "OLE2SvrOutl\\Shell\\Open\\Command", "svroutl.exe %%1",
  373. "CLSID\\{00000400-0000-0000-C000-000000000046}", "Ole 2.0 Server Sample Outline",
  374. "CLSID\\{00000400-0000-0000-C000-000000000046}\\ProgID", "OLE2SvrOutl",
  375. "CLSID\\{00000400-0000-0000-C000-000000000046}\\InprocHandler32", "ole32.dll",
  376. "CLSID\\{00000400-0000-0000-C000-000000000046}\\LocalServer32", "%s\\svroutl.exe",
  377. "CLSID\\{00000400-0000-0000-C000-000000000046}\\Verb\\0", "&Edit,0,2",
  378. "CLSID\\{00000400-0000-0000-C000-000000000046}\\Insertable", "",
  379. "CLSID\\{00000400-0000-0000-C000-000000000046}\\AuxUserType\\2", "Outline",
  380. "CLSID\\{00000400-0000-0000-C000-000000000046}\\AuxUserType\\3", "Ole 2.0 Outline Server",
  381. "CLSID\\{00000400-0000-0000-C000-000000000046}\\DefaultIcon", "svroutl.exe,0",
  382. "CLSID\\{00000400-0000-0000-C000-000000000046}\\DataFormats\\DefaultFile", "Outline",
  383. "CLSID\\{00000400-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\0", "Outline,1,1,3",
  384. "CLSID\\{00000400-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\1", "1,1,1,3",
  385. "CLSID\\{00000400-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\2", "3,1,32,1",
  386. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\3", "3,4,32,1",
  387. "CLSID\\{00000402-0000-0000-C000-000000000046}\\MiscStatus", "512",
  388. "CLSID\\{00000400-0000-0000-C000-000000000046}\\Conversion\\Readable\\Main", "Outline",
  389. "CLSID\\{00000400-0000-0000-C000-000000000046}\\Conversion\\Readwritable\\Main", "Outline",
  390. "OLE2CntrOutl", "Ole 2.0 Container Sample Outline",
  391. "OLE2CntrOutl\\Clsid", "{00000401-0000-0000-C000-000000000046}",
  392. "OLE2CntrOutl\\Shell\\Print\\Command", "cntroutl.exe %%1",
  393. "OLE2CntrOutl\\Shell\\Open\\Command", "cntroutl.exe %%1",
  394. "CLSID\\{00000401-0000-0000-C000-000000000046}", "Ole 2.0 Container Sample Outline",
  395. "CLSID\\{00000401-0000-0000-C000-000000000046}\\ProgID", "OLE2CntrOutl",
  396. "CLSID\\{00000401-0000-0000-C000-000000000046}\\InprocHandler32", "ole32.dll",
  397. "CLSID\\{00000401-0000-0000-C000-000000000046}\\LocalServer32", "%s\\cntroutl.exe",
  398. "OLE2ISvrOtl", "Ole 2.0 In-Place Server Outline",
  399. "OLE2ISvrOtl\\CLSID", "{00000402-0000-0000-C000-000000000046}",
  400. "OLE2ISvrOtl\\Insertable", "",
  401. "OLE2ISvrOtl\\protocol\\StdFileEditing\\verb\\1", "&Open",
  402. "OLE2ISvrOtl\\protocol\\StdFileEditing\\verb\\0", "&Edit",
  403. "OLE2ISvrOtl\\protocol\\StdFileEditing\\server", "isvrotl.exe",
  404. "OLE2ISvrOtl\\Shell\\Print\\Command", "isvrotl.exe %%1",
  405. "OLE2ISvrOtl\\Shell\\Open\\Command", "isvrotl.exe %%1",
  406. "CLSID\\{00000402-0000-0000-C000-000000000046}", "Ole 2.0 In-Place Server Outline",
  407. "CLSID\\{00000402-0000-0000-C000-000000000046}\\ProgID", "OLE2ISvrOtl",
  408. "CLSID\\{00000402-0000-0000-C000-000000000046}\\ProgID", "OLE2ISvrOtl",
  409. "CLSID\\{00000402-0000-0000-C000-000000000046}\\InprocHandler32", "ole32.dll",
  410. "CLSID\\{00000402-0000-0000-C000-000000000046}\\LocalServer32", "%s\\isvrotl.exe",
  411. "CLSID\\{00000402-0000-0000-C000-000000000046}\\Verb\\1", "&Open,0,2",
  412. "CLSID\\{00000402-0000-0000-C000-000000000046}\\Verb\\0", "&Edit,0,2",
  413. "CLSID\\{00000402-0000-0000-C000-000000000046}\\Insertable", "",
  414. "CLSID\\{00000402-0000-0000-C000-000000000046}\\AuxUserType\\2", "Outline",
  415. "CLSID\\{00000402-0000-0000-C000-000000000046}\\AuxUserType\\3", "Ole 2.0 In-Place Outline Server",
  416. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DefaultIcon", "isvrotl.exe,0",
  417. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DataFormats\\DefaultFile", "Outline",
  418. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\0", "Outline,1,1,3",
  419. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\1", "1,1,1,3",
  420. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\2", "3,1,32,1",
  421. "CLSID\\{00000402-0000-0000-C000-000000000046}\\DataFormats\\GetSet\\3", "3,4,32,1",
  422. "CLSID\\{00000402-0000-0000-C000-000000000046}\\MiscStatus", "512",
  423. "CLSID\\{00000402-0000-0000-C000-000000000046}\\MiscStatus\\1", "896",
  424. "CLSID\\{00000402-0000-0000-C000-000000000046}\\Conversion\\Readable\\Main", "Outline",
  425. "CLSID\\{00000402-0000-0000-C000-000000000046}\\Conversion\\Readwritable\\Main", "Outline",
  426. "OLE2ICtrOtl", "Ole 2.0 In-Place Container Outline",
  427. "OLE2ICtrOtl\\Clsid", "{00000403-0000-0000-C000-000000000046}",
  428. "OLE2ICtrOtl\\Shell\\Print\\Command", "icntrotl.exe %%1",
  429. "OLE2ICtrOtl\\Shell\\Open\\Command", "icntrotl.exe %%1",
  430. ".olc", "OLE2ICtrOtl",
  431. "CLSID\\{00000403-0000-0000-C000-000000000046}", "Ole 2.0 In-Place Container Outline",
  432. "CLSID\\{00000403-0000-0000-C000-000000000046}\\ProgID", "OLE2ICtrOtl",
  433. "CLSID\\{00000403-0000-0000-C000-000000000046}\\InprocHandler32", "ole32.dll",
  434. "CLSID\\{00000403-0000-0000-C000-000000000046}\\LocalServer32", "%s\\icntrotl.exe",
  435. NULL
  436. };
  437. //+-------------------------------------------------------------------------
  438. //
  439. // Function: InitializeRegistry
  440. //
  441. // Synopsis: Initialize the registry for oletest.
  442. //
  443. // Effects:
  444. //
  445. // Arguments: None.
  446. //
  447. // Requires:
  448. //
  449. // Returns:
  450. //
  451. // Signals:
  452. //
  453. // Modifies:
  454. //
  455. // Algorithm:
  456. //
  457. // History: dd-mmm-yy Author Comment
  458. // 08-Nov-94 KentCe Created.
  459. //
  460. // Notes:
  461. //
  462. //--------------------------------------------------------------------------
  463. void InitializeRegistry( void )
  464. {
  465. char szBuf[MAX_PATH * 2];
  466. char szPath[MAX_PATH];
  467. int i;
  468. //
  469. // Assume all the oletest components are in the current directory.
  470. //
  471. if (!GetCurrentDirectory(sizeof(szPath), szPath))
  472. {
  473. assert(0);
  474. }
  475. //
  476. // Loop thru string key/value pairs and update the registry.
  477. //
  478. for (i = 0; regConfig[i] != NULL; i += 2)
  479. {
  480. //
  481. // The registry template contains embedded "%s" to permit
  482. // the insertion of the full path of test binaries.
  483. //
  484. wsprintf(szBuf, regConfig[i+1], szPath);
  485. if (RegSetValue(HKEY_CLASSES_ROOT, regConfig[i+0], REG_SZ,
  486. szBuf, strlen(szBuf)) != ERROR_SUCCESS)
  487. {
  488. assert(0);
  489. }
  490. }
  491. }
  492. //+-------------------------------------------------------------------------
  493. //
  494. // Function: TestSetup
  495. //
  496. // Synopsis: process the command line and setup the tests that need to
  497. // be run.
  498. //
  499. // Effects:
  500. //
  501. // Arguments: lpszCmdLine
  502. //
  503. // Requires:
  504. //
  505. // Returns:
  506. //
  507. // Signals:
  508. //
  509. // Modifies:
  510. //
  511. // Algorithm: We scan the command line for the following information
  512. //
  513. // NULL or empty cmdline, assume running task 0
  514. // (usually run all tasks)
  515. // otherwise scan for n numbers, adding each to the end of
  516. // the stack (so the tasks are run in order).
  517. //
  518. // History: dd-mmm-yy Author Comment
  519. // 12-Dec-94 MikeW restructured parse algorithm, added -? & l
  520. // 07-Feb-94 alexgo author
  521. //
  522. // Notes:
  523. //
  524. //--------------------------------------------------------------------------
  525. void TestSetup( LPSTR lpszCmdLine )
  526. {
  527. LPSTR pszArg;
  528. int nTest, cTests;
  529. // initialize debugger options to nothing.
  530. vApp.m_pszDebuggerOption = "";
  531. //
  532. // count up the number of tests available
  533. //
  534. for (cTests = 0; vrgTaskList[cTests].szName != (LPSTR) 0; cTests++)
  535. {
  536. ;
  537. }
  538. //
  539. // make sure the registery is set up correctly.
  540. //
  541. InitializeRegistry();
  542. //
  543. // if the command line is empty, run all tests
  544. // (assumed to be task 0)
  545. //
  546. pszArg = strtok(lpszCmdLine, " ");
  547. if (NULL == pszArg)
  548. {
  549. vApp.m_TaskStack.Push(&vrgTaskList[0]);
  550. vApp.m_fInteractive = FALSE;
  551. }
  552. //
  553. // otherwise, look for options & test numbers
  554. //
  555. while (NULL != pszArg)
  556. {
  557. if ('-' == *pszArg)
  558. {
  559. while ('\0' != *(++pszArg)) // it's an option
  560. {
  561. switch (*pszArg)
  562. {
  563. case 'r': // 'r' flag is obsolete
  564. break;
  565. case 'R':
  566. OutputString("Warning: 'R' flag to oletest is obsolete.\n");
  567. vApp.m_fInteractive = FALSE;
  568. vApp.m_TaskStack.Push(&vrgTaskList[0]);
  569. break;
  570. case 'i': // run in interactive mode
  571. vApp.m_fInteractive = TRUE;
  572. break;
  573. case 'n': // start apps in debugger
  574. vApp.m_fInteractive = TRUE;
  575. vApp.m_pszDebuggerOption = "ntsd ";
  576. break;
  577. case 'l': // list tests & test nums
  578. ListAllTests();
  579. vApp.m_fInteractive = TRUE;
  580. break;
  581. case '?': // output the option list
  582. PrintHelp();
  583. vApp.m_fInteractive = TRUE;
  584. break;
  585. }
  586. }
  587. }
  588. else // it's not a option, maybe it's a test number
  589. {
  590. if (isdigit(*pszArg))
  591. {
  592. nTest = atoi(pszArg);
  593. if (nTest < 0 || nTest > cTests - 1)
  594. {
  595. OutputString("Ignoring invalid test #%d", nTest);
  596. }
  597. else
  598. {
  599. vApp.m_TaskStack.AddToEnd(&vrgTaskList[nTest]);
  600. }
  601. }
  602. }
  603. pszArg = strtok(NULL, " "); // fetch the next argument
  604. }
  605. vApp.m_fpLog = fopen("clip.log", "w+");
  606. assert(vApp.m_fpLog);
  607. }
  608. //+-------------------------------------------------------------------------
  609. //
  610. // Function: ListAllTests
  611. //
  612. // Synopsis: List all available tests and the corresponding test number
  613. //
  614. // Effects:
  615. //
  616. // Arguments: void
  617. //
  618. // Requires:
  619. //
  620. // Returns:
  621. //
  622. // Signals:
  623. //
  624. // Modifies:
  625. //
  626. // Algorithm: Iterate through vrgTaskList
  627. //
  628. // History: dd-mmm-yy Author Comment
  629. // 12-Dec-94 MikeW author
  630. //
  631. // Notes:
  632. //
  633. //--------------------------------------------------------------------------
  634. void ListAllTests()
  635. {
  636. int nTask;
  637. for (nTask = 0; vrgTaskList[nTask].szName != (LPSTR) 0; nTask++)
  638. {
  639. OutputString("%2d -- %s\r\n", nTask, vrgTaskList[nTask].szName);
  640. }
  641. OutputString("\r\n");
  642. }
  643. //+-------------------------------------------------------------------------
  644. //
  645. // Function: PrintHelp
  646. //
  647. // Synopsis: Print the program options & tests
  648. //
  649. // Effects:
  650. //
  651. // Arguments: void
  652. //
  653. // Requires:
  654. //
  655. // Returns:
  656. //
  657. // Signals:
  658. //
  659. // Modifies:
  660. //
  661. // Algorithm:
  662. //
  663. // History: dd-mmm-yy Author Comment
  664. // 12-Dec-94 MikeW author
  665. //
  666. // Notes:
  667. //
  668. //--------------------------------------------------------------------------
  669. void PrintHelp()
  670. {
  671. OutputString("OleTest [options] [test numbers] -\r\n");
  672. OutputString("\r\n");
  673. OutputString(" -r - Autoregister test apps\r\n");
  674. OutputString(" -R - Autoregister and Run All Tests\r\n");
  675. OutputString(" -i - Run in interactive mode\r\n");
  676. OutputString(" -n - Run test apps using ntsd and run interactive\r\n");
  677. OutputString(" -l - List tests & test numbers and run interactive\r\n");
  678. OutputString(" -? - Print this help\r\n");
  679. OutputString("\r\n");
  680. ListAllTests();
  681. }
  682. //+-------------------------------------------------------------------------
  683. //
  684. // Function: WinMain
  685. //
  686. // Synopsis: main window procedure
  687. //
  688. // Effects:
  689. //
  690. // Arguments: hInstance
  691. // hPrevInstance
  692. // lpCmdLine
  693. // nCmdShow
  694. //
  695. // Requires:
  696. //
  697. // Returns:
  698. //
  699. // Signals:
  700. //
  701. // Modifies:
  702. //
  703. // Algorithm:
  704. //
  705. // History: dd-mmm-yy Author Comment
  706. // 06-Feb-94 alexgo author
  707. //
  708. // Notes:
  709. //
  710. //--------------------------------------------------------------------------
  711. #ifdef WIN32
  712. int APIENTRY WinMain(
  713. HINSTANCE hInstance,
  714. HINSTANCE hPrevInstance,
  715. LPSTR lpCmdLine,
  716. int nCmdShow)
  717. #else
  718. int PASCAL WinMain(
  719. HANDLE hInstance,
  720. HANDLE hPrevInstance,
  721. LPSTR lpCmdLine,
  722. int nCmdShow)
  723. #endif
  724. {
  725. MSG msg;
  726. if (!hPrevInstance)
  727. {
  728. if (!InitApplication(hInstance))
  729. {
  730. return FALSE;
  731. }
  732. }
  733. if (!InitInstance(hInstance, nCmdShow))
  734. {
  735. return FALSE;
  736. }
  737. TestSetup(lpCmdLine);
  738. OleInitialize(NULL);
  739. while (GetMessage(&msg, NULL, 0, 0))
  740. {
  741. TranslateMessage(&msg);
  742. DispatchMessage(&msg);
  743. }
  744. OleUninitialize();
  745. fclose(vApp.m_fpLog);
  746. return (msg.wParam);
  747. }