Source code of Windows XP (NT5)
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.

1383 lines
44 KiB

  1. //-------------------------------------------------------------------
  2. //
  3. // FILE: LicCpa.cpp
  4. //
  5. // Summary;
  6. // This file contians the DLL & CPL entry points, F1 Help message
  7. // hooking, and misc common dialog functions.
  8. //
  9. // Entry Points;
  10. // CPlSetup
  11. // CPlApplet
  12. // DllMain
  13. //
  14. // History;
  15. // Nov-30-94 MikeMi Created
  16. // Mar-14-95 MikeMi Added F1 Message Filter and PWM_HELP message
  17. // Apr-26-95 MikeMi Added Computer name and remoting
  18. // Dec-12-95 JeffParh Added secure certificate support
  19. //
  20. //-------------------------------------------------------------------
  21. #include <windows.h>
  22. #include <cpl.h>
  23. #include "resource.h"
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include "PriDlgs.hpp"
  27. #include "SecDlgs.hpp"
  28. #include "liccpa.hpp"
  29. #include "Special.hpp"
  30. extern "C"
  31. {
  32. BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved);
  33. BOOL APIENTRY CPlSetup( DWORD nArgs, LPSTR apszArgs[], LPSTR *ppszResult );
  34. LONG CALLBACK CPlApplet( HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2);
  35. LRESULT CALLBACK msgprocHelpFilter( int nCode, WPARAM wParam, LPARAM lParam );
  36. }
  37. // Setup routines
  38. //
  39. const CHAR szSETUP_NORMAL[] = "FULLSETUP";
  40. const CHAR szSETUP_PERSEAT[] = "PERSEAT";
  41. const CHAR szSETUP_UNATTENDED[] = "UNATTENDED";
  42. const CHAR szSETUP_NORMALNOEXIT[] = "FULLSETUPNOEXIT";
  43. const CHAR szREMOTESETUP_NORMAL[] = "REMOTEFULLSETUP";
  44. const CHAR szREMOTESETUP_PERSEAT[] = "REMOTEPERSEAT";
  45. const CHAR szREMOTESETUP_UNATTENDED[] = "REMOTEUNATTENDED";
  46. const CHAR szREMOTESETUP_NORMALNOEXIT[] = "REMOTEFULLSETUPNOEXIT";
  47. // Modes for unattended setup
  48. //
  49. const CHAR szUNATTENDED_PERSEAT[] = "PERSEAT";
  50. const CHAR szUNATTENDED_PERSERVER[] = "PERSERVER";
  51. // Certificate required / not required
  52. const CHAR szSETUP_CERTREQUIRED[] = "CERTREQUIRED";
  53. const CHAR szSETUP_CERTNOTREQUIRED[] = "CERTNOTREQUIRED";
  54. // Use default help file
  55. const CHAR szSETUP_DEFAULTHELP[] = "DEFAULTHELP";
  56. // Setup Error return strings
  57. //
  58. static CHAR szSETUP_EXIT[] = "EXIT";
  59. static CHAR szSETUP_ERROR[] = "ERROR";
  60. static CHAR szSETUP_SECURITY[] = "SECURITY";
  61. static CHAR szSETUP_NOREMOTE[] = "NOREMOTE";
  62. static CHAR szSETUP_DOWNLEVEL[] = "DOWNLEVEL";
  63. static CHAR szSETUP_OK[] = "OK";
  64. // Registered help message for F1 hooking
  65. //
  66. const WCHAR szF1HELPMESSAGE[] = L"LicCpaF1Help";
  67. HINSTANCE g_hinst = NULL; // global hinstance of this dll
  68. HHOOK g_hhook = NULL; // global hhook for F1 message filter
  69. UINT PWM_HELP = 0; // global help message when F1 is pressed
  70. //-------------------------------------------------------------------
  71. //
  72. // Function: msgprocHelpFilter
  73. //
  74. // Summary;
  75. // This functions will filter the messages looking for F1, then send
  76. // the registered message to the top most parent of that window
  77. // informing it that F1 for help was pressed.
  78. //
  79. // Arguments;
  80. // (see Win32 MessageProc)
  81. //
  82. // History;
  83. // Mar-13-95 MikeMi Created
  84. //
  85. //-------------------------------------------------------------------
  86. LRESULT CALLBACK msgprocHelpFilter( int nCode, WPARAM wParam, LPARAM lParam )
  87. {
  88. LRESULT lrt = 0;
  89. PMSG pmsg = (PMSG)lParam;
  90. if (nCode < 0)
  91. {
  92. lrt = CallNextHookEx( g_hhook, nCode, wParam, lParam );
  93. }
  94. else
  95. {
  96. if (MSGF_DIALOGBOX == nCode)
  97. {
  98. // handle F1 key
  99. if ( (WM_KEYDOWN == pmsg->message) &&
  100. (VK_F1 == (INT_PTR)pmsg->wParam) )
  101. {
  102. HWND hwnd = pmsg->hwnd;
  103. // post message to parent that handles help
  104. while( GetWindowLong( hwnd, GWL_STYLE ) & WS_CHILD )
  105. {
  106. hwnd = GetParent( hwnd );
  107. }
  108. PostMessage( hwnd, PWM_HELP, 0, 0 );
  109. lrt = 1;
  110. }
  111. }
  112. }
  113. return( lrt );
  114. }
  115. //-------------------------------------------------------------------
  116. //
  117. // Function: InstallF1Hook
  118. //
  119. // Summary;
  120. // This will ready the message filter for handling F1.
  121. // It install the message hook and registers a message that will
  122. // be posted to the dialogs.
  123. //
  124. // Arguments;
  125. // hinst [in] - the module handle of this DLL (needed to install hook)
  126. // dwThreadId [in] - thread to attach filter to
  127. //
  128. // Notes:
  129. // The control.exe does this work and sends the "ShellHelp" message.
  130. // A seperate F1 message filter is needed because these dialogs maybe
  131. // raised by other applications than control.exe.
  132. //
  133. // History;
  134. // Mar-13-95 MikeMi Created
  135. //
  136. //-------------------------------------------------------------------
  137. BOOL InstallF1Hook( HINSTANCE hInst, DWORD dwThreadId )
  138. {
  139. BOOL frt = FALSE;
  140. if (NULL == g_hhook)
  141. {
  142. g_hhook = SetWindowsHookEx( WH_MSGFILTER,
  143. (HOOKPROC)msgprocHelpFilter,
  144. hInst,
  145. dwThreadId );
  146. if (NULL != g_hhook)
  147. {
  148. PWM_HELP = RegisterWindowMessage( szF1HELPMESSAGE );
  149. if (0 != PWM_HELP)
  150. {
  151. frt = TRUE;
  152. }
  153. }
  154. }
  155. return( frt );
  156. }
  157. //-------------------------------------------------------------------
  158. //
  159. // Function: RemoveF1Hook
  160. //
  161. // Summary;
  162. // This will remove the message filter hook that InstallF1Hook installs.
  163. //
  164. // History;
  165. // Mar-13-95 MikeMi Created
  166. //
  167. //-------------------------------------------------------------------
  168. BOOL RemoveF1Hook( )
  169. {
  170. BOOL frt = UnhookWindowsHookEx( g_hhook );
  171. g_hhook = NULL;
  172. return( frt );
  173. }
  174. //-------------------------------------------------------------------
  175. //
  176. // Function: DLLMain
  177. //
  178. // Summary;
  179. // Entry point for all DLLs
  180. //
  181. // Notes:
  182. // We only support being called from the same thread that called
  183. // LoadLibrary. Because we install a message hook, and passing a
  184. // zero for threadid does not work as documented.
  185. //
  186. // History;
  187. // Nov-30-94 MikeMi Created
  188. //
  189. //-------------------------------------------------------------------
  190. BOOL APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  191. {
  192. BOOL frt = TRUE;
  193. switch (dwReason)
  194. {
  195. case DLL_PROCESS_ATTACH:
  196. g_hinst = hInstance;
  197. frt = InstallF1Hook( g_hinst, GetCurrentThreadId() );
  198. break;
  199. case DLL_PROCESS_DETACH:
  200. RemoveF1Hook();
  201. break;
  202. case DLL_THREAD_ATTACH:
  203. break;
  204. case DLL_THREAD_DETACH:
  205. break;
  206. default:
  207. break;
  208. }
  209. return( frt );
  210. }
  211. //-------------------------------------------------------------------
  212. //
  213. // Function: LowMemoryDlg
  214. //
  215. // Summary;
  216. // Standard function for handling low memory situation
  217. //
  218. // History;
  219. // Nov-30-94 MikeMi Created
  220. //
  221. //-------------------------------------------------------------------
  222. void LowMemoryDlg()
  223. {
  224. WCHAR szText[TEMPSTR_SIZE];
  225. WCHAR szTitle[TEMPSTR_SIZE];
  226. LoadString(g_hinst, IDS_CPATITLE, szTitle, TEMPSTR_SIZE);
  227. LoadString(g_hinst, IDS_LOWMEM, szText, TEMPSTR_SIZE);
  228. MessageBox (NULL, szText, szTitle, MB_OK|MB_ICONEXCLAMATION);
  229. }
  230. //-------------------------------------------------------------------
  231. //
  232. // Function: BadRegDlg
  233. //
  234. // Summary;
  235. // Standard function for handling bad registry situation
  236. //
  237. // History;
  238. // Nov-30-94 MikeMi Created
  239. //
  240. //-------------------------------------------------------------------
  241. void BadRegDlg( HWND hwndDlg )
  242. {
  243. WCHAR szText[TEMPSTR_SIZE];
  244. WCHAR szTitle[TEMPSTR_SIZE];
  245. LoadString(g_hinst, IDS_CPATITLE, szTitle, TEMPSTR_SIZE);
  246. LoadString(g_hinst, IDS_BADREGTERM, szText, TEMPSTR_SIZE);
  247. MessageBox (hwndDlg, szText, szTitle, MB_OK|MB_ICONEXCLAMATION);
  248. }
  249. //-------------------------------------------------------------------
  250. //
  251. // Function: CenterDialogToScreen
  252. //
  253. // Summary;
  254. // Move the window so that it is centered on the screen
  255. //
  256. // Arguments;
  257. // hwndDlg [in] - the hwnd to the dialog to center
  258. //
  259. // History;
  260. // Dec-3-94 MikeMi Created
  261. //
  262. //-------------------------------------------------------------------
  263. void CenterDialogToScreen( HWND hwndDlg )
  264. {
  265. RECT rcDlg;
  266. INT x, y, w, h;
  267. INT sw, sh;
  268. sw = GetSystemMetrics( SM_CXSCREEN );
  269. sh = GetSystemMetrics( SM_CYSCREEN );
  270. GetWindowRect( hwndDlg, &rcDlg );
  271. w = rcDlg.right - rcDlg.left;
  272. h = rcDlg.bottom - rcDlg.top;
  273. x = (sw / 2) - (w / 2);
  274. y = (sh / 2) - (h / 2);
  275. MoveWindow( hwndDlg, x, y, w, h, FALSE );
  276. }
  277. //-------------------------------------------------------------------
  278. //
  279. // Function: InitStaticWithService
  280. // Summary;
  281. // Handle the initialization of a static text with a service name
  282. //
  283. // Arguments;
  284. // hwndDlg [in] - the dialog that contains the static
  285. // wID [in] - the id of the static control
  286. // pszService [in] - the service display name to use
  287. //
  288. // Notes;
  289. //
  290. // History;
  291. // Dec-05-1994 MikeMi Created
  292. //
  293. //-------------------------------------------------------------------
  294. void InitStaticWithService( HWND hwndDlg, UINT wID, LPCWSTR pszService )
  295. {
  296. WCHAR szText[LTEMPSTR_SIZE];
  297. WCHAR szTemp[LTEMPSTR_SIZE];
  298. GetDlgItemText( hwndDlg, wID, szTemp, LTEMPSTR_SIZE );
  299. wsprintf( szText, szTemp, pszService );
  300. SetDlgItemText( hwndDlg, wID, szText );
  301. }
  302. //-------------------------------------------------------------------
  303. //
  304. // Function: InitStaticWithService2
  305. // Summary;
  306. // Handle the initialization of a static text that contians two
  307. // instances of a service name with the service name
  308. //
  309. // Arguments;
  310. // hwndDlg [in] - the dialog that contains the static
  311. // wID [in] - the id of the static control
  312. // pszService [in] - the service display name to use
  313. //
  314. // Notes;
  315. //
  316. // History;
  317. // Dec-05-1994 MikeMi Created
  318. //
  319. //-------------------------------------------------------------------
  320. void InitStaticWithService2( HWND hwndDlg, UINT wID, LPCWSTR pszService )
  321. {
  322. WCHAR szText[LTEMPSTR_SIZE];
  323. WCHAR szTemp[LTEMPSTR_SIZE];
  324. GetDlgItemText( hwndDlg, wID, szTemp, LTEMPSTR_SIZE );
  325. wsprintf( szText, szTemp, pszService, pszService );
  326. SetDlgItemText( hwndDlg, wID, szText );
  327. }
  328. //-------------------------------------------------------------------
  329. //
  330. // Function: CPlApplet
  331. //
  332. // Summary;
  333. // Entry point for Comntrol Panel Applets
  334. //
  335. // Arguments;
  336. // hwndCPL [in] - handle of Control Panel window
  337. // uMsg [in] - message
  338. // lParam1 [in] - first message parameter, usually the application number
  339. // lParam2 [in] - second message parameter
  340. //
  341. // Return;
  342. // message dependant
  343. //
  344. // Notes;
  345. //
  346. // History;
  347. // Nov-11-1994 MikeMi Created
  348. //
  349. //-------------------------------------------------------------------
  350. LONG CALLBACK CPlApplet( HWND hwndCPL, UINT uMsg, LPARAM lParam1, LPARAM lParam2)
  351. {
  352. LPNEWCPLINFO lpNewCPlInfo;
  353. LONG_PTR iApp;
  354. LONG lrt = 0;
  355. iApp = (LONG_PTR) lParam1;
  356. switch (uMsg)
  357. {
  358. case CPL_INIT: /* first message, sent once */
  359. //
  360. // Initialize global special version information is this liccpa
  361. // is a special version (eg: restricted SAM, NFR, etc).
  362. //
  363. InitSpecialVersionInfo();
  364. lrt = TRUE;
  365. break;
  366. case CPL_GETCOUNT: /* second message, sent once */
  367. lrt = 1; // we support only one application within this DLL
  368. break;
  369. case CPL_NEWINQUIRE: /* third message, sent once per app */
  370. lpNewCPlInfo = (LPNEWCPLINFO) lParam2;
  371. lpNewCPlInfo->dwSize = (DWORD) sizeof(NEWCPLINFO);
  372. lpNewCPlInfo->dwFlags = 0;
  373. lpNewCPlInfo->dwHelpContext = LICCPA_HELPCONTEXTMAIN;
  374. lpNewCPlInfo->lData = 0;
  375. lpNewCPlInfo->hIcon = LoadIcon(g_hinst, (LPCWSTR)MAKEINTRESOURCE(IDI_LICCPA));
  376. wcsncpy( lpNewCPlInfo->szHelpFile,
  377. LICCPA_HELPFILE,
  378. sizeof( lpNewCPlInfo->szHelpFile ) / sizeof(WCHAR) );
  379. LoadString(g_hinst,
  380. IDS_CPATITLE,
  381. lpNewCPlInfo->szName,
  382. sizeof( lpNewCPlInfo->szName ) / sizeof(WCHAR) );
  383. LoadString(g_hinst,
  384. IDS_CPADESC,
  385. lpNewCPlInfo->szInfo,
  386. sizeof( lpNewCPlInfo->szInfo ) / sizeof(WCHAR));
  387. break;
  388. case CPL_SELECT: /* application icon selected */
  389. lrt = 1;
  390. break;
  391. case CPL_DBLCLK: /* application icon double-clicked */
  392. //
  393. // Check if this is a special version of liccpa.
  394. //
  395. if (gSpecVerInfo.idsSpecVerWarning)
  396. {
  397. RaiseNotAvailWarning( hwndCPL );
  398. break;
  399. }
  400. CpaDialog( hwndCPL );
  401. break;
  402. case CPL_STOP: /* sent once per app. before CPL_EXIT */
  403. break;
  404. case CPL_EXIT: /* sent once before FreeLibrary called */
  405. break;
  406. default:
  407. break;
  408. }
  409. return( lrt );
  410. }
  411. //-------------------------------------------------------------------
  412. //
  413. // Function: CreateWSTR
  414. //
  415. // Summary;
  416. // Given a STR (ASCII or MB), allocate and translate to WSTR
  417. //
  418. // Arguments;
  419. // ppszWStr [out] - allocated & converted string
  420. // pszStr [in] - string to convert
  421. //
  422. // Return: TRUE if allocated and converted, FALSE if failed
  423. //
  424. // History;
  425. // Nov-30-94 MikeMi Created
  426. //
  427. //-------------------------------------------------------------------
  428. BOOL CreateWSTR( LPWSTR* ppszWStr, LPSTR pszStr )
  429. {
  430. int cchConv;
  431. LPWSTR pszConv;
  432. BOOL frt = FALSE;
  433. WCHAR pszTemp[LTEMPSTR_SIZE];
  434. if (NULL == pszStr)
  435. {
  436. *ppszWStr = NULL;
  437. frt = TRUE;
  438. }
  439. else
  440. {
  441. #ifdef FE_SB
  442. // Since there was a problem in Server setup when calling setlocale or
  443. // linking C-runtime lib, we used Win32 API instead of mbstowcs.
  444. cchConv = ::MultiByteToWideChar(CP_ACP, 0,
  445. pszStr, -1,
  446. NULL, 0);
  447. pszConv = (LPWSTR)::GlobalAlloc( GPTR, cchConv * sizeof( WCHAR ) );
  448. if (NULL != pszConv)
  449. {
  450. ::MultiByteToWideChar(CP_ACP, 0,
  451. pszStr, -1,
  452. pszConv, cchConv);
  453. *ppszWStr = pszConv;
  454. frt = TRUE;
  455. }
  456. #else
  457. cchConv = mbstowcs( pszTemp, pszStr, LTEMPSTR_SIZE );
  458. cchConv++;
  459. pszConv = (LPWSTR)GlobalAlloc( GPTR, cchConv * sizeof( WCHAR ) );
  460. if (NULL != pszConv)
  461. {
  462. lstrcpyW( pszConv, pszTemp );
  463. *ppszWStr = pszConv;
  464. frt = TRUE;
  465. }
  466. #endif
  467. }
  468. return( frt );
  469. }
  470. //-------------------------------------------------------------------
  471. //
  472. // Function: Setup
  473. //
  474. // Summary;
  475. // Run normal setup or Perseat Setup
  476. //
  477. // Arguments
  478. // nArgs [in] - The number of arguments in the apszArgs array
  479. // If this value is 5, help button will call common help
  480. // If this value is 9, help button will call the passed help
  481. // apszArgs[] [in] - The argumnents passed in,
  482. // [0] szRoutine - The type of setup to run (FullSetup | PerSeatSetup)
  483. // [1] szHwnd - The parent Window handle, in HEX!
  484. // [2] szService - The Reg Key name of the service
  485. // [3] szFamilyDisplayName - The family display name of the service
  486. // [4] szDisplayName - The display name of the service
  487. // [5] szHelpFile - The complete path and name to help file
  488. // leave as an empty string to remove help buttons
  489. // [6] szHelpContext - the DWORD to use as the main help context
  490. // [7] szHCPerSeat - the DWORD to use as the PerSeat Help context
  491. // [8] szHCPerServer - the DWORD to use as the PerServer help context
  492. //
  493. // Return:
  494. // 0 - sucessfull
  495. // ERR_HELPPARAMS
  496. // ERR_HWNDPARAM
  497. // ERR_SERVICEPARAM
  498. // ERR_NUMPARAMS
  499. // ERR_CLASSREGFAILED
  500. // ERR_INVALIDROUTINE
  501. // ERR_INVALIDMODE
  502. //
  503. // Notes:
  504. //
  505. // History:
  506. // Nov-17-94 MikeMi Created
  507. //
  508. //-------------------------------------------------------------------
  509. const int SETUPARG_SETUP = 0;
  510. const int SETUPARG_HWND = 1;
  511. const int SETUPARG_SERVICE = 2;
  512. const int SETUPARG_FAMILYNAME = 3;
  513. const int SETUPARG_NAME = 4;
  514. const int SETUPARG_HELPFILE = 5;
  515. const int SETUPARG_HELPCONTEXT = 6;
  516. const int SETUPARG_HCPERSEAT = 7;
  517. const int SETUPARG_HCPERSERVER = 8;
  518. const int SETUPARG_CERTREQUIRED = 9;
  519. const int SETUPARG_WOOPTIONAL = 5; // count of args without optional
  520. const int SETUPARG_WOPTIONAL = 9; // count of args with optional
  521. const int SETUPARG_WOPTIONALEX = 10; // count of args with optional + certrequired extension
  522. INT_PTR Setup( DWORD nArgs, LPSTR apszArgs[] )
  523. {
  524. SETUPDLGPARAM dlgParam;
  525. INT_PTR nError = 0;
  526. HWND hwndParent = NULL;
  527. BOOL fCustomHelp = FALSE;
  528. BOOL bCertRequired = FALSE;
  529. dlgParam.pszHelpFile = (LPWSTR)LICCPA_HELPFILE;
  530. dlgParam.dwHelpContext = LICCPA_HELPCONTEXTMAINSETUP;
  531. dlgParam.dwHCPerServer = LICCPA_HELPCONTEXTPERSERVER;
  532. dlgParam.dwHCPerSeat = LICCPA_HELPCONTEXTPERSEAT;
  533. dlgParam.pszService = NULL;
  534. dlgParam.pszComputer = NULL;
  535. dlgParam.fNoExit = FALSE;
  536. do
  537. {
  538. if ((nArgs == SETUPARG_WOPTIONAL) || (nArgs == SETUPARG_WOOPTIONAL) || (nArgs == SETUPARG_WOPTIONALEX))
  539. {
  540. if (nArgs > SETUPARG_WOOPTIONAL)
  541. {
  542. if ( ( NULL != apszArgs[SETUPARG_HELPFILE] ) && lstrcmpiA( apszArgs[SETUPARG_HELPFILE], szSETUP_DEFAULTHELP ) )
  543. {
  544. // help file given
  545. LPWSTR pszHelpFile;
  546. if ( CreateWSTR( &pszHelpFile, apszArgs[SETUPARG_HELPFILE] ) )
  547. {
  548. if (0 == lstrlen( pszHelpFile ))
  549. {
  550. GlobalFree( (HGLOBAL)pszHelpFile );
  551. dlgParam.pszHelpFile = NULL; // should remove help buttons
  552. }
  553. else
  554. {
  555. fCustomHelp = TRUE;
  556. dlgParam.pszHelpFile = pszHelpFile;
  557. }
  558. }
  559. else
  560. {
  561. nError = ERR_HELPPARAMS;
  562. break;
  563. }
  564. dlgParam.dwHelpContext = (DWORD)strtoul( apszArgs[SETUPARG_HELPCONTEXT], NULL, 0);
  565. dlgParam.dwHCPerSeat = (DWORD)strtoul( apszArgs[SETUPARG_HCPERSEAT], NULL, 0);
  566. dlgParam.dwHCPerServer = (DWORD)strtoul( apszArgs[SETUPARG_HCPERSERVER], NULL, 0);
  567. }
  568. if ( nArgs > SETUPARG_CERTREQUIRED )
  569. {
  570. // cert required / not required given
  571. if ( !lstrcmpiA( szSETUP_CERTREQUIRED, apszArgs[SETUPARG_CERTREQUIRED] ) )
  572. {
  573. bCertRequired = TRUE;
  574. }
  575. else if ( lstrcmpiA( szSETUP_CERTNOTREQUIRED, apszArgs[SETUPARG_CERTREQUIRED] ) )
  576. {
  577. // unrecognized argument for cert required/not required
  578. nError = ERR_CERTREQPARAM;
  579. break;
  580. }
  581. }
  582. }
  583. // hwnd is in hex!
  584. #ifdef _WIN64
  585. {
  586. _int64 val = 0;
  587. sscanf(apszArgs[SETUPARG_HWND], "%I64x", &val);
  588. hwndParent = (HWND)val;
  589. }
  590. #else
  591. hwndParent = (HWND)strtoul( apszArgs[SETUPARG_HWND], NULL, 16);
  592. #endif
  593. if ( !IsWindow( hwndParent ) )
  594. {
  595. nError = ERR_HWNDPARAM;
  596. hwndParent = GetActiveWindow(); // use active window as parent
  597. if (!IsWindow( hwndParent ) )
  598. {
  599. hwndParent = GetDesktopWindow();
  600. }
  601. }
  602. if ( CreateWSTR( &dlgParam.pszService, apszArgs[SETUPARG_SERVICE] ) &&
  603. CreateWSTR( &dlgParam.pszDisplayName, apszArgs[SETUPARG_NAME] ) &&
  604. CreateWSTR( &dlgParam.pszFamilyDisplayName, apszArgs[SETUPARG_FAMILYNAME] ) )
  605. {
  606. if ( bCertRequired )
  607. {
  608. nError = ServiceSecuritySet( dlgParam.pszComputer, dlgParam.pszDisplayName );
  609. }
  610. else
  611. {
  612. nError = ERR_NONE;
  613. }
  614. if ( ERR_NONE == nError )
  615. {
  616. if (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szSETUP_PERSEAT ))
  617. {
  618. // use the licensing help context as the main help context
  619. dlgParam.dwHelpContext = LICCPA_HELPCONTEXTLICENSING;
  620. //
  621. // Check if this is a special version of liccpa.
  622. //
  623. if (gSpecVerInfo.idsSpecVerWarning)
  624. {
  625. dlgParam.fNoExit = TRUE;
  626. nError = SpecialSetupDialog( hwndParent,
  627. dlgParam );
  628. }
  629. else
  630. {
  631. nError = PerSeatSetupDialog( hwndParent,
  632. dlgParam );
  633. }
  634. }
  635. else
  636. {
  637. if (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szSETUP_NORMALNOEXIT ))
  638. {
  639. dlgParam.fNoExit = TRUE;
  640. }
  641. //
  642. // Check if this is a special version of liccpa.
  643. //
  644. if (gSpecVerInfo.idsSpecVerWarning)
  645. {
  646. nError = SpecialSetupDialog( hwndParent,
  647. dlgParam );
  648. }
  649. else
  650. {
  651. nError = SetupDialog( hwndParent, dlgParam );
  652. }
  653. }
  654. }
  655. else
  656. {
  657. nError = ERR_SERVICEPARAM;
  658. }
  659. }
  660. if (fCustomHelp)
  661. {
  662. GlobalFree( (HGLOBAL)dlgParam.pszHelpFile );
  663. }
  664. GlobalFree( (HGLOBAL)dlgParam.pszService );
  665. GlobalFree( (HGLOBAL)dlgParam.pszDisplayName );
  666. GlobalFree( (HGLOBAL)dlgParam.pszFamilyDisplayName );
  667. }
  668. else
  669. {
  670. nError = ERR_NUMPARAMS;
  671. }
  672. } while (FALSE);
  673. return( nError );
  674. }
  675. //-------------------------------------------------------------------
  676. //
  677. // Function: UnattendedSetup
  678. //
  679. // Summary;
  680. // This will save the passed values in the registry, keeping all
  681. // licensing rules in effect and returning errorr/raising dialogs if
  682. // errors occur.
  683. //
  684. // Arguments
  685. // nArgs [in] - The number of arguments in the apszArgs array
  686. // apszArgs[] [in] - The argumnents passed in,
  687. // [0] szRoutine - The type of setup to run (Unattended)
  688. // [1] szService - The Reg Key name of the service
  689. // [2] szFamilyDisplayName - The family display name of the service
  690. // [3] szDisplayName - The display name of the service
  691. // [4] szMode - The string that defines the mode (PerSeat | PerServer)
  692. // [5] szUsers - The DWORD to use as the count of users in PerServer mode
  693. //
  694. // Return:
  695. // 0 - sucessfull
  696. // ERR_HELPPARAMS
  697. // ERR_HWNDPARAM
  698. // ERR_SERVICEPARAM
  699. // ERR_NUMPARAMS
  700. // ERR_CLASSREGFAILED
  701. // ERR_INVALIDROUTINE
  702. // ERR_INVALIDMODE
  703. //
  704. // Notes:
  705. //
  706. // History:
  707. // Dec-09-94 MikeMi Created
  708. //
  709. //-------------------------------------------------------------------
  710. const int UNSETUPARG_SETUP = 0;
  711. const int UNSETUPARG_SERVICE = 1;
  712. const int UNSETUPARG_FAMILYNAME = 2;
  713. const int UNSETUPARG_NAME = 3;
  714. const int UNSETUPARG_MODE = 4;
  715. const int UNSETUPARG_USERS = 5;
  716. const int UNSETUPARG_CERTREQUIRED = 6;
  717. const int UNSETUPARG_NARGSREQUIRED = 6;
  718. const int UNSETUPARG_NARGSWOPTIONAL = 7;
  719. int UnattendedSetup( DWORD nArgs, LPSTR apszArgs[] )
  720. {
  721. int nError = 0;
  722. LPWSTR pszService;
  723. LPWSTR pszDisplayName;
  724. LPWSTR pszFamilyDisplayName;
  725. LICENSE_MODE lmMode;
  726. DWORD dwUsers;
  727. do
  728. {
  729. if ( (nArgs == UNSETUPARG_NARGSREQUIRED) || (nArgs == UNSETUPARG_NARGSWOPTIONAL) )
  730. {
  731. if ( CreateWSTR( &pszService, apszArgs[UNSETUPARG_SERVICE] ) &&
  732. CreateWSTR( &pszDisplayName, apszArgs[UNSETUPARG_NAME] ) &&
  733. CreateWSTR( &pszFamilyDisplayName, apszArgs[UNSETUPARG_FAMILYNAME] ) )
  734. {
  735. nError = ERR_NONE;
  736. if ( nArgs > UNSETUPARG_CERTREQUIRED )
  737. {
  738. // cert required / not required given
  739. if ( !lstrcmpiA( szSETUP_CERTREQUIRED, apszArgs[UNSETUPARG_CERTREQUIRED] ) )
  740. {
  741. nError = ServiceSecuritySet( NULL, pszDisplayName );
  742. }
  743. else if ( lstrcmpiA( szSETUP_CERTNOTREQUIRED, apszArgs[UNSETUPARG_CERTREQUIRED] ) )
  744. {
  745. // unrecognized argument for cert required/not required
  746. nError = ERR_CERTREQPARAM;
  747. }
  748. }
  749. if ( ERR_NONE == nError )
  750. {
  751. //
  752. // Check if this is a special version of liccpa.
  753. //
  754. if (gSpecVerInfo.idsSpecVerWarning)
  755. {
  756. lmMode = gSpecVerInfo.lmSpecialMode;
  757. dwUsers = gSpecVerInfo.dwSpecialUsers;
  758. }
  759. else
  760. {
  761. if (0 == lstrcmpiA( apszArgs[UNSETUPARG_MODE],
  762. szUNATTENDED_PERSERVER ))
  763. {
  764. lmMode = LICMODE_PERSERVER;
  765. }
  766. else if (0 == lstrcmpiA( apszArgs[UNSETUPARG_MODE],
  767. szUNATTENDED_PERSEAT ))
  768. {
  769. lmMode = LICMODE_PERSEAT;
  770. }
  771. else
  772. {
  773. nError = ERR_INVALIDMODE;
  774. break;
  775. }
  776. dwUsers = (DWORD)strtoul( apszArgs[UNSETUPARG_USERS],
  777. NULL, 0);
  778. }
  779. nError = UpdateReg( NULL,
  780. pszService,
  781. pszFamilyDisplayName,
  782. pszDisplayName,
  783. lmMode,
  784. dwUsers );
  785. }
  786. GlobalFree( (HGLOBAL)pszService );
  787. GlobalFree( (HGLOBAL)pszDisplayName );
  788. GlobalFree( (HGLOBAL)pszFamilyDisplayName );
  789. }
  790. else
  791. {
  792. nError = ERR_SERVICEPARAM;
  793. }
  794. }
  795. else
  796. {
  797. nError = ERR_NUMPARAMS;
  798. }
  799. } while (FALSE);
  800. return( nError );
  801. }
  802. //-------------------------------------------------------------------
  803. //
  804. // Function: RemoteSetup
  805. //
  806. // Summary;
  807. // Run normal setup, Perseat Setup, normal setup without exit remotely
  808. //
  809. // Arguments
  810. // nArgs [in] - The number of arguments in the apszArgs array
  811. // If this value is 6, help button will call common help
  812. // If this value is 10, help button will call the passed help
  813. // apszArgs[] [in] - The argumnents passed in,
  814. // [0] szRoutine - The type of setup to run
  815. // [1] szComputer - the name of the computer to setup on (\\name)
  816. // [2] szHwnd - The parent Window handle, in HEX!
  817. // [3] szService - The Reg Key name of the service
  818. // [4] szFamilyDisplayName - The family display name of the service
  819. // [5] szDisplayName - The display name of the service
  820. // [6] szHelpFile - The complete path and name to help file
  821. // leave as an empty string to remove help buttons
  822. // [7] szHelpContext - the DWORD to use as the main help context
  823. // [8] szHCPerSeat - the DWORD to use as the PerSeat Help context
  824. // [9] szHCPerServer - the DWORD to use as the PerServer help context
  825. //
  826. // Return:
  827. // 0 - sucessfull
  828. // ERR_PERMISSIONDENIED
  829. // ERR_HELPPARAMS
  830. // ERR_HWNDPARAM
  831. // ERR_SERVICEPARAM
  832. // ERR_NUMPARAMS
  833. // ERR_CLASSREGFAILED
  834. // ERR_INVALIDROUTINE
  835. // ERR_INVALIDMODE
  836. //
  837. // Notes:
  838. //
  839. // History:
  840. // Apr-26-95 MikeMi Created
  841. //
  842. //-------------------------------------------------------------------
  843. const int REMSETUPARG_SETUP = 0;
  844. const int REMSETUPARG_COMPUTER = 1;
  845. const int REMSETUPARG_HWND = 2;
  846. const int REMSETUPARG_SERVICE = 3;
  847. const int REMSETUPARG_FAMILYNAME = 4;
  848. const int REMSETUPARG_NAME = 5;
  849. const int REMSETUPARG_HELPFILE = 6;
  850. const int REMSETUPARG_HELPCONTEXT = 7;
  851. const int REMSETUPARG_HCPERSEAT = 8;
  852. const int REMSETUPARG_HCPERSERVER = 9;
  853. const int REMSETUPARG_CERTREQUIRED = 10;
  854. const int REMSETUPARG_WOOPTIONAL = 6; // count of args without optional
  855. const int REMSETUPARG_WOPTIONAL = 10; // count of args with optional
  856. const int REMSETUPARG_WOPTIONALEX = 11; // count of args with optional + certrequired
  857. INT_PTR RemoteSetup( DWORD nArgs, LPSTR apszArgs[] )
  858. {
  859. SETUPDLGPARAM dlgParam;
  860. INT_PTR nError = 0;
  861. HWND hwndParent = NULL;
  862. BOOL fCustomHelp = FALSE;
  863. BOOL bCertRequired = FALSE;
  864. dlgParam.pszHelpFile = (LPWSTR)LICCPA_HELPFILE;
  865. dlgParam.dwHelpContext = LICCPA_HELPCONTEXTMAINSETUP;
  866. dlgParam.dwHCPerServer = LICCPA_HELPCONTEXTPERSERVER;
  867. dlgParam.dwHCPerSeat = LICCPA_HELPCONTEXTPERSEAT;
  868. dlgParam.pszService = NULL;
  869. dlgParam.fNoExit = FALSE;
  870. do
  871. {
  872. nError = ERR_NONE;
  873. if ((nArgs == REMSETUPARG_WOPTIONAL) || (nArgs == REMSETUPARG_WOOPTIONAL) || (nArgs == REMSETUPARG_WOPTIONALEX))
  874. {
  875. if (nArgs > REMSETUPARG_WOOPTIONAL)
  876. {
  877. if ( ( NULL != apszArgs[REMSETUPARG_HELPFILE] ) && lstrcmpiA( apszArgs[REMSETUPARG_HELPFILE], szSETUP_DEFAULTHELP ) )
  878. {
  879. LPWSTR pszHelpFile;
  880. if ( CreateWSTR( &pszHelpFile, apszArgs[REMSETUPARG_HELPFILE] ) )
  881. {
  882. if (0 == lstrlen( pszHelpFile ))
  883. {
  884. GlobalFree( (HGLOBAL)pszHelpFile );
  885. dlgParam.pszHelpFile = NULL; // should remove help buttons
  886. }
  887. else
  888. {
  889. fCustomHelp = TRUE;
  890. dlgParam.pszHelpFile = pszHelpFile;
  891. }
  892. }
  893. else
  894. {
  895. nError = ERR_HELPPARAMS;
  896. break;
  897. }
  898. dlgParam.dwHelpContext = (DWORD)strtoul( apszArgs[REMSETUPARG_HELPCONTEXT], NULL, 0);
  899. dlgParam.dwHCPerSeat = (DWORD)strtoul( apszArgs[REMSETUPARG_HCPERSEAT], NULL, 0);
  900. dlgParam.dwHCPerServer = (DWORD)strtoul( apszArgs[REMSETUPARG_HCPERSERVER], NULL, 0);
  901. }
  902. if ( nArgs > REMSETUPARG_CERTREQUIRED )
  903. {
  904. // cert required / not required given
  905. if ( !lstrcmpiA( szSETUP_CERTREQUIRED, apszArgs[REMSETUPARG_CERTREQUIRED] ) )
  906. {
  907. bCertRequired = TRUE;
  908. }
  909. else if ( lstrcmpiA( szSETUP_CERTNOTREQUIRED, apszArgs[REMSETUPARG_CERTREQUIRED] ) )
  910. {
  911. // unrecognized argument for cert required/not required
  912. nError = ERR_CERTREQPARAM;
  913. break;
  914. }
  915. }
  916. }
  917. // hwnd is in hex!
  918. #ifdef _WIN64
  919. {
  920. _int64 val = 0;
  921. sscanf(apszArgs[REMSETUPARG_HWND], "%I64x", &val);
  922. hwndParent = (HWND)val;
  923. }
  924. #else
  925. hwndParent = (HWND)strtoul( apszArgs[REMSETUPARG_HWND], NULL, 16);
  926. #endif
  927. if ( !IsWindow( hwndParent ) )
  928. {
  929. nError = ERR_HWNDPARAM;
  930. hwndParent = GetActiveWindow(); // use active window as parent
  931. if (!IsWindow( hwndParent ) )
  932. {
  933. hwndParent = GetDesktopWindow();
  934. }
  935. }
  936. if ( CreateWSTR( &dlgParam.pszService, apszArgs[REMSETUPARG_SERVICE] ) &&
  937. CreateWSTR( &dlgParam.pszDisplayName, apszArgs[REMSETUPARG_NAME] ) &&
  938. CreateWSTR( &dlgParam.pszComputer, apszArgs[REMSETUPARG_COMPUTER] ) &&
  939. CreateWSTR( &dlgParam.pszFamilyDisplayName, apszArgs[REMSETUPARG_FAMILYNAME] ) )
  940. {
  941. if ( bCertRequired )
  942. {
  943. nError = ServiceSecuritySet( dlgParam.pszComputer, dlgParam.pszDisplayName );
  944. }
  945. else
  946. {
  947. nError = ERR_NONE;
  948. }
  949. if ( ERR_NONE == nError )
  950. {
  951. if (0 == lstrcmpiA( apszArgs[REMSETUPARG_SETUP], szREMOTESETUP_PERSEAT ))
  952. {
  953. // use the licensing help context as the main help context
  954. dlgParam.dwHelpContext = LICCPA_HELPCONTEXTLICENSING;
  955. //
  956. // Check if this is a special version of liccpa.
  957. //
  958. if (gSpecVerInfo.idsSpecVerWarning)
  959. {
  960. dlgParam.fNoExit = TRUE;
  961. nError = SpecialSetupDialog( hwndParent,
  962. dlgParam );
  963. }
  964. else
  965. {
  966. nError = PerSeatSetupDialog( hwndParent,
  967. dlgParam );
  968. }
  969. }
  970. else
  971. {
  972. if (0 == lstrcmpiA( apszArgs[REMSETUPARG_SETUP], szREMOTESETUP_NORMALNOEXIT ))
  973. {
  974. dlgParam.fNoExit = TRUE;
  975. }
  976. //
  977. // Check if this is a special version of liccpa.
  978. //
  979. if (gSpecVerInfo.idsSpecVerWarning)
  980. {
  981. nError = SpecialSetupDialog( hwndParent,
  982. dlgParam );
  983. }
  984. else
  985. {
  986. nError = SetupDialog( hwndParent, dlgParam );
  987. }
  988. }
  989. }
  990. }
  991. else
  992. {
  993. nError = ERR_SERVICEPARAM;
  994. }
  995. if (fCustomHelp)
  996. {
  997. GlobalFree( (HGLOBAL)dlgParam.pszHelpFile );
  998. }
  999. GlobalFree( (HGLOBAL)dlgParam.pszService );
  1000. GlobalFree( (HGLOBAL)dlgParam.pszDisplayName );
  1001. GlobalFree( (HGLOBAL)dlgParam.pszFamilyDisplayName );
  1002. GlobalFree( (HGLOBAL)dlgParam.pszComputer );
  1003. }
  1004. else
  1005. {
  1006. nError = ERR_NUMPARAMS;
  1007. }
  1008. } while (FALSE);
  1009. return( nError );
  1010. }
  1011. //-------------------------------------------------------------------
  1012. //
  1013. // Function: RemoteUnattendedSetup
  1014. //
  1015. // Summary;
  1016. // This will save the passed values in the registry, keeping all
  1017. // licensing rules in effect and returning errorr/raising dialogs if
  1018. // errors occur. This is done remotely on the computer specified.
  1019. //
  1020. // Arguments
  1021. // nArgs [in] - The number of arguments in the apszArgs array
  1022. // apszArgs[] [in] - The argumnents passed in,
  1023. // [0] szRoutine - The type of setup to run (Unattended)
  1024. // [1] szComputer - the name of the computer to setup on (\\name)
  1025. // [2] szService - The Reg Key name of the service
  1026. // [3] szFamilyDisplayName - The family display name of the service
  1027. // [4] szDisplayName - The display name of the service
  1028. // [5] szMode - The string that defines the mode (PerSeat | PerServer)
  1029. // [6] szUsers - The DWORD to use as the count of users in PerServer mode
  1030. //
  1031. // Return:
  1032. // 0 - sucessfull
  1033. // ERR_PERMISSIONDENIED
  1034. // ERR_HELPPARAMS
  1035. // ERR_HWNDPARAM
  1036. // ERR_SERVICEPARAM
  1037. // ERR_USERSPARAM
  1038. // ERR_NUMPARAMS
  1039. // ERR_CLASSREGFAILED
  1040. // ERR_INVALIDROUTINE
  1041. // ERR_INVALIDMODE
  1042. //
  1043. // Notes:
  1044. //
  1045. // History:
  1046. // Apr-26-95 MikeMi Created
  1047. //
  1048. //-------------------------------------------------------------------
  1049. const int REMUNSETUPARG_SETUP = 0;
  1050. const int REMUNSETUPARG_COMPUTER = 1;
  1051. const int REMUNSETUPARG_SERVICE = 2;
  1052. const int REMUNSETUPARG_FAMILYNAME = 3;
  1053. const int REMUNSETUPARG_NAME = 4;
  1054. const int REMUNSETUPARG_MODE = 5;
  1055. const int REMUNSETUPARG_USERS = 6;
  1056. const int REMUNSETUPARG_CERTREQUIRED = 7;
  1057. const int REMUNSETUPARG_NARGSREQUIRED = 7;
  1058. const int REMUNSETUPARG_NARGSWOPTIONAL = 8;
  1059. int RemoteUnattendedSetup( DWORD nArgs, LPSTR apszArgs[] )
  1060. {
  1061. int nError = 0;
  1062. LPWSTR pszService;
  1063. LPWSTR pszDisplayName;
  1064. LPWSTR pszFamilyDisplayName;
  1065. LPWSTR pszComputerName;
  1066. LICENSE_MODE lmMode;
  1067. DWORD dwUsers;
  1068. do
  1069. {
  1070. if ( (nArgs == REMUNSETUPARG_NARGSREQUIRED) || (nArgs == REMUNSETUPARG_NARGSWOPTIONAL) )
  1071. {
  1072. if ( CreateWSTR( &pszService, apszArgs[REMUNSETUPARG_SERVICE] ) &&
  1073. CreateWSTR( &pszDisplayName, apszArgs[REMUNSETUPARG_NAME] ) &&
  1074. CreateWSTR( &pszFamilyDisplayName, apszArgs[REMUNSETUPARG_FAMILYNAME] ) &&
  1075. CreateWSTR( &pszComputerName, apszArgs[REMUNSETUPARG_COMPUTER] ) )
  1076. {
  1077. nError = ERR_NONE;
  1078. if ( nArgs > REMUNSETUPARG_CERTREQUIRED )
  1079. {
  1080. // cert required / not required given
  1081. if ( !lstrcmpiA( szSETUP_CERTREQUIRED, apszArgs[REMUNSETUPARG_CERTREQUIRED] ) )
  1082. {
  1083. nError = ServiceSecuritySet( pszComputerName, pszDisplayName );
  1084. }
  1085. else if ( lstrcmpiA( szSETUP_CERTNOTREQUIRED, apszArgs[REMUNSETUPARG_CERTREQUIRED] ) )
  1086. {
  1087. // unrecognized argument for cert required/not required
  1088. nError = ERR_CERTREQPARAM;
  1089. }
  1090. }
  1091. if ( ERR_NONE == nError )
  1092. {
  1093. //
  1094. // Check if this is a special version of liccpa.
  1095. //
  1096. if (gSpecVerInfo.idsSpecVerWarning)
  1097. {
  1098. lmMode = gSpecVerInfo.lmSpecialMode;
  1099. dwUsers = gSpecVerInfo.dwSpecialUsers;
  1100. }
  1101. else
  1102. {
  1103. if (0 == lstrcmpiA( apszArgs[REMUNSETUPARG_MODE],
  1104. szUNATTENDED_PERSERVER ))
  1105. {
  1106. lmMode = LICMODE_PERSERVER;
  1107. }
  1108. else if (0 == lstrcmpiA( apszArgs[REMUNSETUPARG_MODE],
  1109. szUNATTENDED_PERSEAT ))
  1110. {
  1111. lmMode = LICMODE_PERSEAT;
  1112. }
  1113. else
  1114. {
  1115. nError = ERR_INVALIDMODE;
  1116. break;
  1117. }
  1118. dwUsers = (DWORD)strtoul(
  1119. apszArgs[REMUNSETUPARG_USERS],
  1120. NULL, 0);
  1121. }
  1122. nError = UpdateReg( pszComputerName,
  1123. pszService,
  1124. pszFamilyDisplayName,
  1125. pszDisplayName,
  1126. lmMode,
  1127. dwUsers );
  1128. }
  1129. if(pszService != NULL)
  1130. {
  1131. GlobalFree( (HGLOBAL)pszService );
  1132. }
  1133. if(pszDisplayName != NULL)
  1134. {
  1135. GlobalFree( (HGLOBAL)pszDisplayName );
  1136. }
  1137. if(pszFamilyDisplayName != NULL)
  1138. {
  1139. GlobalFree( (HGLOBAL)pszFamilyDisplayName );
  1140. }
  1141. if(pszComputerName != NULL)
  1142. {
  1143. GlobalFree( (HGLOBAL)pszComputerName );
  1144. }
  1145. }
  1146. else
  1147. {
  1148. nError = ERR_SERVICEPARAM;
  1149. }
  1150. }
  1151. else
  1152. {
  1153. nError = ERR_NUMPARAMS;
  1154. }
  1155. } while (FALSE);
  1156. return( nError );
  1157. }
  1158. //-------------------------------------------------------------------
  1159. //
  1160. // Function: CPlSetup
  1161. //
  1162. // Summary;
  1163. // Dll entry point for License Mode Setup, to be used from Setup
  1164. // programs.
  1165. //
  1166. // Arguments
  1167. // nArgs [in] - The number of arguments in the apszArgs array
  1168. // apszArgs[] [in] - The argumnents passed in,
  1169. // [0] szRoutine - The type of setup to run
  1170. // FullSetup | RemoteFullSetup |
  1171. // PerSeatSetup | RemotePerSeatSetup |
  1172. // Unattended | RemoteUnattended |
  1173. // FullSetupNoexit | RemoteFullSetupNoexit
  1174. // ppszResult [out]- The result string
  1175. //
  1176. // Return:
  1177. //
  1178. // Notes:
  1179. //
  1180. // History:
  1181. // Nov-17-94 MikeMi Created
  1182. // Apr-26-95 MikeMi Added remoting routines
  1183. //
  1184. //-------------------------------------------------------------------
  1185. BOOL APIENTRY CPlSetup( DWORD nArgs, LPSTR apszArgs[], LPSTR *ppszResult )
  1186. {
  1187. INT_PTR nError = 0;
  1188. BOOL frt = TRUE;
  1189. //
  1190. // Initialize global special version information is this liccpa
  1191. // is a special version (eg: restricted SAM, NFR, etc).
  1192. //
  1193. InitSpecialVersionInfo();
  1194. if ((0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szSETUP_PERSEAT )) ||
  1195. (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szSETUP_NORMAL )) ||
  1196. (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szSETUP_NORMALNOEXIT )) )
  1197. {
  1198. nError = Setup( nArgs, apszArgs );
  1199. }
  1200. else if (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szSETUP_UNATTENDED ))
  1201. {
  1202. nError = UnattendedSetup( nArgs, apszArgs );
  1203. }
  1204. else if ((0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szREMOTESETUP_PERSEAT )) ||
  1205. (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szREMOTESETUP_NORMAL )) ||
  1206. (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szREMOTESETUP_NORMALNOEXIT )) )
  1207. {
  1208. nError = RemoteSetup( nArgs, apszArgs );
  1209. }
  1210. else if (0 == lstrcmpiA( apszArgs[SETUPARG_SETUP], szREMOTESETUP_UNATTENDED ))
  1211. {
  1212. nError = RemoteUnattendedSetup( nArgs, apszArgs );
  1213. }
  1214. else
  1215. {
  1216. nError = ERR_INVALIDROUTINE;
  1217. }
  1218. // prepare error for return
  1219. switch (nError)
  1220. {
  1221. case 0:
  1222. *ppszResult = szSETUP_EXIT;
  1223. break;
  1224. case ERR_NONE:
  1225. *ppszResult = szSETUP_OK;
  1226. break;
  1227. case ERR_PERMISSIONDENIED:
  1228. frt = FALSE;
  1229. *ppszResult = szSETUP_SECURITY;
  1230. break;
  1231. case ERR_NOREMOTESERVER:
  1232. frt = FALSE;
  1233. *ppszResult = szSETUP_NOREMOTE;
  1234. break;
  1235. case ERR_DOWNLEVEL:
  1236. frt = FALSE;
  1237. *ppszResult = szSETUP_DOWNLEVEL;
  1238. break;
  1239. default:
  1240. *ppszResult = szSETUP_ERROR;
  1241. frt = FALSE;
  1242. break;
  1243. }
  1244. return( frt );
  1245. }