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.

2220 lines
62 KiB

  1. //-------------------------------------------------------------------
  2. //
  3. // FILE: PriDlgs.cpp
  4. //
  5. // Summary;
  6. // This file contians the Primary Dialogs, functions and dialog procs
  7. //
  8. // Entry Points;
  9. //
  10. // History;
  11. // Nov-30-94 MikeMi Created
  12. // Mar-14-95 MikeMi Added F1 Message Filter and PWM_HELP message
  13. // Apr-26-95 MikeMi Added Computer name and remoting
  14. // Dec-15-95 JeffParh Added secure certificate support.
  15. //
  16. //-------------------------------------------------------------------
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <windows.h>
  21. #include "resource.h"
  22. #include "CLicReg.hpp"
  23. #include <stdlib.h>
  24. #include <htmlhelp.h>
  25. #include "liccpa.hpp"
  26. #include "PriDlgs.hpp"
  27. #include "SecDlgs.hpp"
  28. #include <llsapi.h>
  29. #include <strsafe.h>
  30. extern "C"
  31. {
  32. INT_PTR CALLBACK dlgprocLICCPA( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  33. INT_PTR CALLBACK dlgprocLICSETUP( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  34. INT_PTR CALLBACK dlgprocPERSEATSETUP( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  35. INT_PTR CALLBACK dlgprocLICCPACONFIG( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam );
  36. }
  37. // Perserver user count value limits and defaults
  38. //
  39. const int PERSERVER_LIMITDEFAULT = 0;
  40. const int PERSERVER_MAX = 999999;
  41. const int PERSERVER_MIN = 0;
  42. const int PERSERVER_PAGE = 10;
  43. const int cchEDITLIMIT = 6; // the number of chars to represent PERSERVER_MAX
  44. const UINT MB_VALUELIMIT = MB_OK; // beep when value limit is reached
  45. // Used for in memory storage of license mode state
  46. //
  47. typedef struct tagSERVICEENTRY
  48. {
  49. LPWSTR pszComputer;
  50. LPWSTR pszService;
  51. LPWSTR pszDisplayName;
  52. LPWSTR pszFamilyDisplayName;
  53. LICENSE_MODE lm;
  54. DWORD dwLimit;
  55. BOOL fIsNewProduct;
  56. } SERVICEENTRY, *PSERVICEENTRY;
  57. #pragma warning(push)
  58. #pragma warning(disable: 4296) // C4296: '<=' : expression is always true
  59. inline BOOL VALIDUSERCOUNT( UINT users )
  60. {
  61. return ((PERSERVER_MIN <= users) && (PERSERVER_MAX >= users));
  62. }
  63. #pragma warning(pop)
  64. static void UpdatePerServerLicenses( HWND hwndDlg, PSERVICEENTRY pServ );
  65. static int ServiceRegister( LPWSTR pszComputer,
  66. LPWSTR pszFamilyDisplayName,
  67. LPWSTR pszDisplayName );
  68. BOOL g_fWarned = FALSE;
  69. //-------------------------------------------------------------------
  70. //
  71. // Function: AccessOk
  72. //
  73. // Summary;
  74. // Checks access rights from reg call and raise dialog as needed
  75. //
  76. // Arguments;
  77. // hDlg [in] - Handle to working dialog to raise error dlgs with
  78. // lrc [in] - the return status from a reg call
  79. //
  80. // Returns:
  81. // local error mapping;
  82. // ERR_NONE
  83. // ERR_PERMISSIONDENIED
  84. // ERR_NOREMOTESERVER
  85. // ERR_REGISTRYCORRUPT
  86. //
  87. //
  88. // History;
  89. // Nov-30-94 MikeMi Created
  90. //
  91. //-------------------------------------------------------------------
  92. INT AccessOk( HWND hDlg, LONG lrc, BOOL fCPCall )
  93. {
  94. INT nrt = ERR_NONE;
  95. if (ERROR_SUCCESS != lrc)
  96. {
  97. WCHAR szText[TEMPSTR_SIZE];
  98. WCHAR szTitle[TEMPSTR_SIZE];
  99. UINT wId;
  100. UINT wIdTitle;
  101. switch (lrc)
  102. {
  103. case ERROR_ACCESS_DENIED:
  104. wId = IDS_NOACCESS;
  105. nrt = ERR_PERMISSIONDENIED;
  106. break;
  107. case RPC_S_SERVER_UNAVAILABLE:
  108. wId = IDS_NOSERVER;
  109. nrt = ERR_NOREMOTESERVER;
  110. break;
  111. default:
  112. wId = IDS_BADREG;
  113. nrt = ERR_REGISTRYCORRUPT;
  114. break;
  115. }
  116. if (fCPCall)
  117. {
  118. wIdTitle = IDS_CPCAPTION;
  119. }
  120. else
  121. {
  122. wIdTitle = IDS_SETUPCAPTION;
  123. }
  124. LoadString(g_hinst, wIdTitle, szTitle, TEMPSTR_SIZE);
  125. LoadString(g_hinst, wId, szText, TEMPSTR_SIZE);
  126. MessageBox (hDlg, szText, szTitle, MB_OK|MB_ICONSTOP);
  127. }
  128. return( nrt );
  129. }
  130. //-------------------------------------------------------------------
  131. //
  132. // Function: InitUserEdit
  133. //
  134. // Summary;
  135. // Initializes and defines user count edit control behaviour
  136. //
  137. // Arguments;
  138. // hwndDlg [in] - Parent dialog of user count edit dialog
  139. //
  140. // History;
  141. // Nov-30-94 MikeMi Created
  142. //
  143. //-------------------------------------------------------------------
  144. void InitUserEdit( HWND hwndDlg )
  145. {
  146. HWND hwndCount = GetDlgItem( hwndDlg, IDC_USERCOUNT);
  147. SendMessage( hwndCount, EM_LIMITTEXT, cchEDITLIMIT, 0 );
  148. }
  149. //-------------------------------------------------------------------
  150. //
  151. // Function: InitTitleText
  152. //
  153. // Summary;
  154. // Initialize title static text and mode definition static text
  155. //
  156. // Arguments;
  157. // hwndDlg [in] - Parent dialog of description static text
  158. // pServ [in] - Service definition to set static text
  159. //
  160. //
  161. // History;
  162. // Nov-30-94 MikeMi Created
  163. //
  164. //-------------------------------------------------------------------
  165. void InitTitleText( HWND hwndDlg, PSERVICEENTRY pServ )
  166. {
  167. InitStaticWithService( hwndDlg, IDC_STATICTITLE, pServ->pszDisplayName );
  168. InitStaticWithService( hwndDlg, IDC_STATICPERSEAT, pServ->pszDisplayName );
  169. }
  170. //-------------------------------------------------------------------
  171. //
  172. // Function: InitDialogForService
  173. //
  174. // Summary;
  175. // Initialize dialog controls to the service state
  176. //
  177. // Arguments;
  178. // hwndDlg [in] - Parent dialog to init controls in
  179. // pServ [in] - Service definition to set controls
  180. //
  181. // History;
  182. // Nov-30-94 MikeMi Created
  183. //
  184. //-------------------------------------------------------------------
  185. void InitDialogForService( HWND hwndDlg, PSERVICEENTRY pServ )
  186. {
  187. HWND hwndCount = GetDlgItem( hwndDlg, IDC_USERCOUNT );
  188. HWND hwndSpin = GetDlgItem( hwndDlg, IDC_USERCOUNTARROW );
  189. BOOL fIsPerServer = (LICMODE_PERSERVER==pServ->lm);
  190. // set radio button states
  191. CheckDlgButton( hwndDlg, IDC_PERSEAT, !fIsPerServer );
  192. CheckDlgButton( hwndDlg, IDC_PERSERVER, fIsPerServer );
  193. // set user count edit control
  194. if (fIsPerServer)
  195. {
  196. // add text back
  197. SetDlgItemInt( hwndDlg, IDC_USERCOUNT, pServ->dwLimit, FALSE );
  198. SetFocus( hwndCount );
  199. SendMessage( hwndCount, EM_SETSEL, 0, -1 );
  200. }
  201. else
  202. {
  203. // remove all text in item
  204. SetDlgItemText( hwndDlg, IDC_USERCOUNT, L"" );
  205. }
  206. // set state of edit control and arrows
  207. if ( NULL != hwndSpin )
  208. {
  209. EnableWindow( hwndCount, fIsPerServer );
  210. EnableWindow( hwndSpin, fIsPerServer );
  211. }
  212. else
  213. {
  214. UpdatePerServerLicenses( hwndDlg, pServ );
  215. EnableWindow( GetDlgItem( hwndDlg, IDC_ADD_LICENSES ), fIsPerServer );
  216. EnableWindow( GetDlgItem( hwndDlg, IDC_REMOVE_LICENSES ), fIsPerServer );
  217. }
  218. }
  219. //-------------------------------------------------------------------
  220. //
  221. // Function: FreeServiceEntry
  222. //
  223. // Summary;
  224. // Free all allocated memory when a service structure is created
  225. //
  226. // Aruments;
  227. // pServ [in] - The Service structure to free
  228. //
  229. // History;
  230. // Nov-30-94 MikeMi Created
  231. //
  232. //-------------------------------------------------------------------
  233. void FreeServiceEntry( PSERVICEENTRY pServ )
  234. {
  235. GlobalFree( pServ->pszService );
  236. GlobalFree( pServ->pszDisplayName );
  237. if ( NULL != pServ->pszComputer )
  238. {
  239. GlobalFree( pServ->pszComputer );
  240. }
  241. GlobalFree( pServ );
  242. }
  243. //-------------------------------------------------------------------
  244. //
  245. // Function: CreateServiceEntry
  246. //
  247. // Summary;
  248. // Using the Service registry key name, allocate a Service structure
  249. // and setup registry.
  250. //
  251. // Arguments;
  252. // pszComputer [in] - The name of the computer to use (maybe null)
  253. // pszService [in] - The name of the reg key to use to load or create
  254. // service from
  255. // pszDisplayName [in] - The name the user will see, this will only be
  256. // if the registry does not contain a displayname already
  257. //
  258. // Returns: NULL if Error, pointer to allocated Service Structure
  259. //
  260. // History;
  261. // Nov-30-94 MikeMi Created
  262. //
  263. //-------------------------------------------------------------------
  264. PSERVICEENTRY CreateServiceEntry( LPCWSTR pszComputer,
  265. LPCWSTR pszService,
  266. LPCWSTR pszFamilyDisplayName,
  267. LPCWSTR pszDisplayName )
  268. {
  269. CLicRegLicenseService cLicServKey;
  270. PSERVICEENTRY pServ = NULL;
  271. DWORD cchSize = 0;
  272. LONG lrt;
  273. HRESULT hr;
  274. pServ = (PSERVICEENTRY)GlobalAlloc( GPTR, sizeof( SERVICEENTRY ));
  275. if (pServ)
  276. {
  277. cLicServKey.SetService( pszService );
  278. cLicServKey.Open( pszComputer, TRUE );
  279. // load or set defaults
  280. //
  281. if (ERROR_SUCCESS != cLicServKey.GetMode( pServ->lm ))
  282. {
  283. pServ->lm = LICMODE_UNDEFINED;
  284. }
  285. if (ERROR_SUCCESS != cLicServKey.GetUserLimit( pServ->dwLimit ))
  286. {
  287. pServ->dwLimit = PERSERVER_LIMITDEFAULT;
  288. }
  289. //
  290. // get, set DisplayName
  291. //
  292. lrt = cLicServKey.GetDisplayName( NULL, cchSize );
  293. if (ERROR_SUCCESS == lrt)
  294. {
  295. pServ->pszDisplayName = (LPWSTR)GlobalAlloc( GPTR, cchSize * sizeof( WCHAR ) );
  296. if (pServ->pszDisplayName == NULL)
  297. {
  298. goto ErrorCleanup;
  299. }
  300. lrt = cLicServKey.GetDisplayName( pServ->pszDisplayName, cchSize );
  301. }
  302. // the GetDisplayName may fail in both the two cases above
  303. //
  304. if (ERROR_SUCCESS != lrt)
  305. {
  306. GlobalFree( (HGLOBAL)pServ->pszDisplayName );
  307. cchSize = lstrlen( pszDisplayName ) + 1;
  308. pServ->pszDisplayName = (LPWSTR)GlobalAlloc( GPTR, cchSize * sizeof( WCHAR ) );
  309. if (pServ->pszDisplayName == NULL)
  310. {
  311. goto ErrorCleanup;
  312. }
  313. hr = StringCchCopy( pServ->pszDisplayName, cchSize, pszDisplayName );
  314. if (S_OK != hr)
  315. {
  316. goto ErrorCleanup;
  317. }
  318. cLicServKey.SetDisplayName( pServ->pszDisplayName );
  319. pServ->fIsNewProduct = TRUE;
  320. }
  321. else
  322. {
  323. pServ->fIsNewProduct = FALSE;
  324. }
  325. //
  326. // get, set FamilyDisplayName
  327. //
  328. lrt = cLicServKey.GetFamilyDisplayName( NULL, cchSize );
  329. if (ERROR_SUCCESS == lrt)
  330. {
  331. pServ->pszFamilyDisplayName = (LPWSTR)GlobalAlloc( GPTR, cchSize * sizeof( WCHAR ) );
  332. if ( pServ->pszFamilyDisplayName == NULL )
  333. {
  334. goto ErrorCleanup;
  335. }
  336. lrt = cLicServKey.GetFamilyDisplayName( pServ->pszFamilyDisplayName, cchSize );
  337. }
  338. // the GetFamilyDisplayName may fail in both the two cases above
  339. //
  340. if (ERROR_SUCCESS != lrt)
  341. {
  342. GlobalFree( (HGLOBAL)pServ->pszFamilyDisplayName );
  343. cchSize = lstrlen( pszFamilyDisplayName ) + 1;
  344. pServ->pszFamilyDisplayName = (LPWSTR)GlobalAlloc( GPTR, cchSize * sizeof( WCHAR ) );
  345. if ( pServ->pszFamilyDisplayName == NULL )
  346. {
  347. goto ErrorCleanup;
  348. }
  349. hr = StringCchCopy( pServ->pszFamilyDisplayName, cchSize, pszFamilyDisplayName );
  350. if (S_OK != hr)
  351. {
  352. goto ErrorCleanup;
  353. }
  354. }
  355. cchSize = lstrlen( pszService ) + 1;
  356. pServ->pszService = (LPWSTR)GlobalAlloc( GPTR, cchSize * sizeof( WCHAR ) );
  357. if (pServ->pszService == NULL)
  358. {
  359. goto ErrorCleanup;
  360. }
  361. hr = StringCchCopy( pServ->pszService, cchSize, pszService );
  362. if (S_OK != hr)
  363. {
  364. goto ErrorCleanup;
  365. }
  366. cLicServKey.Close();
  367. if ( NULL == pszComputer )
  368. {
  369. pServ->pszComputer = NULL;
  370. }
  371. else
  372. {
  373. cchSize = 1 + lstrlen( pszComputer );
  374. pServ->pszComputer = (LPWSTR)GlobalAlloc( GPTR, sizeof( WCHAR ) * cchSize );
  375. if (pServ->pszComputer == NULL)
  376. {
  377. goto ErrorCleanup;
  378. }
  379. hr = StringCchCopy( pServ->pszComputer, cchSize, pszComputer );
  380. if (S_OK != hr)
  381. {
  382. goto ErrorCleanup;
  383. }
  384. }
  385. }
  386. return( pServ );
  387. ErrorCleanup:
  388. if (pServ) // JonN 5/15/00: PREFIX 112116-112119
  389. {
  390. if (pServ->pszDisplayName)
  391. GlobalFree( (HGLOBAL)pServ->pszDisplayName );
  392. if (pServ->pszFamilyDisplayName)
  393. GlobalFree( (HGLOBAL)pServ->pszFamilyDisplayName );
  394. if (pServ->pszService)
  395. GlobalFree( (HGLOBAL)pServ->pszService );
  396. if (pServ->pszComputer)
  397. GlobalFree( (HGLOBAL)pServ->pszComputer );
  398. GlobalFree( (HGLOBAL)pServ );
  399. }
  400. return ( (PSERVICEENTRY)NULL );
  401. }
  402. //-------------------------------------------------------------------
  403. //
  404. // Function: SaveServiceToReg
  405. //
  406. // Summary;
  407. // Save the given Service structure to the registry
  408. //
  409. // Arguments;
  410. // pServ [in] - Service structure to save
  411. //
  412. // History;
  413. // Nov-30-94 MikeMi Created
  414. //
  415. //-------------------------------------------------------------------
  416. void SaveServiceToReg( LPCWSTR pszComputer, PSERVICEENTRY pServ )
  417. {
  418. CLicRegLicenseService cLicServKey;
  419. LICENSE_MODE lm;
  420. cLicServKey.SetService( pServ->pszService );
  421. cLicServKey.Open( pszComputer );
  422. //
  423. // if no mode in the registry, set to current selected mode
  424. //
  425. if (ERROR_SUCCESS != cLicServKey.GetMode( lm ))
  426. {
  427. lm = pServ->lm;
  428. }
  429. //
  430. // if a mode change was made or perseat mode selected,
  431. // set the change flag so that user is warned on any change
  432. //
  433. if ((pServ->lm != lm) ||
  434. (LICMODE_PERSEAT == pServ->lm) )
  435. {
  436. cLicServKey.SetChangeFlag( TRUE );
  437. }
  438. else
  439. {
  440. // this will not modify change flag if it is
  441. // present, but will set it to false if it is not
  442. // present
  443. cLicServKey.CanChangeMode();
  444. }
  445. DWORD dwLimitInReg;
  446. // user limit should be set by CCFAPI32; set only if it's absent
  447. if ( ERROR_SUCCESS != cLicServKey.GetUserLimit( dwLimitInReg ) )
  448. {
  449. cLicServKey.SetUserLimit( pServ->dwLimit );
  450. }
  451. cLicServKey.SetDisplayName( pServ->pszDisplayName );
  452. cLicServKey.SetFamilyDisplayName( pServ->pszFamilyDisplayName );
  453. cLicServKey.SetMode( pServ->lm );
  454. cLicServKey.Close();
  455. }
  456. //-------------------------------------------------------------------
  457. //
  458. // Function: ServiceLicAgreement
  459. //
  460. // Summary;
  461. // Check the given Service structure for violation
  462. //
  463. // Arguments;
  464. // hwndDlg [in] - hwnd of dialog to use to raise legal voilation dialog
  465. // pServ [in] - Service structure to check
  466. // pszComputer [in] - computer to work with
  467. // pszHelpFile [in] - helpfile for dialogs help button
  468. // pszPerSeatHelpContext [in] - helpcontext for PerSeat dialog help button
  469. // pszPerServerHelpContext [in] - helpcontext for PerServer dialog help button
  470. //
  471. // Return: FALSE if agreement was not acceptable
  472. // TRUE if agreement was accepted
  473. //
  474. // History;
  475. // Nov-30-94 MikeMi Created
  476. //
  477. //-------------------------------------------------------------------
  478. BOOL ServiceLicAgreement( HWND hwndDlg,
  479. PSERVICEENTRY pServ,
  480. LPCWSTR pszComputer,
  481. LPCWSTR pszHelpFile,
  482. DWORD dwPerSeatHelpContext,
  483. DWORD dwPerServerHelpContext )
  484. {
  485. CLicRegLicenseService cLicServKey;
  486. LICENSE_MODE lm;
  487. DWORD dwLimit = pServ->dwLimit;
  488. BOOL frt = TRUE;
  489. BOOL fRaiseAgreement = TRUE;
  490. cLicServKey.SetService( pServ->pszService );
  491. if (ERROR_SUCCESS == cLicServKey.Open( pszComputer, FALSE ))
  492. {
  493. cLicServKey.GetMode( lm );
  494. cLicServKey.GetUserLimit( dwLimit );
  495. // check for changes
  496. if ( !( pServ->lm != lm ||
  497. (LICMODE_PERSERVER == pServ->lm &&
  498. dwLimit != pServ->dwLimit) ) )
  499. {
  500. fRaiseAgreement = FALSE;
  501. }
  502. cLicServKey.Close();
  503. }
  504. if (fRaiseAgreement)
  505. {
  506. if (LICMODE_PERSEAT == pServ->lm)
  507. {
  508. frt = PerSeatAgreementDialog( hwndDlg,
  509. pServ->pszDisplayName,
  510. pszHelpFile,
  511. dwPerSeatHelpContext );
  512. }
  513. else
  514. {
  515. // special case FilePrint and zero concurrent users
  516. //
  517. if ( 0 == lstrcmp( pServ->pszService, FILEPRINT_SERVICE_REG_KEY ) &&
  518. (0 == pServ->dwLimit))
  519. {
  520. frt = ServerAppAgreementDialog( hwndDlg,
  521. pszHelpFile,
  522. LICCPA_HELPCONTEXTSERVERAPP );
  523. }
  524. else
  525. {
  526. // find the limit has changed but was this invoked
  527. // by adding more licenses if so the user was already warned
  528. if( !g_fWarned )
  529. {
  530. frt = PerServerAgreementDialog( hwndDlg,
  531. pServ->pszDisplayName,
  532. dwLimit , //pServ->dwLimit,
  533. pszHelpFile,
  534. dwPerServerHelpContext );
  535. }
  536. }
  537. }
  538. }
  539. return( frt );
  540. }
  541. //-------------------------------------------------------------------
  542. //
  543. // Function: ServiceViolation
  544. //
  545. // Summary;
  546. // Check the given Service structure for violation
  547. //
  548. // Arguments;
  549. // hwndDlg [in] - hwnd of dialog to use to raise legal voilation dialog
  550. // pszComputer [in] - the name of the computer to work on
  551. // pServ [in] - Service structure to check
  552. //
  553. //
  554. // Return: FALSE if violation not made
  555. // TRUE if violation was made
  556. //
  557. // History;
  558. // Nov-30-94 MikeMi Created
  559. //
  560. //-------------------------------------------------------------------
  561. BOOL ServiceViolation( HWND hwndDlg, LPCWSTR pszComputer, PSERVICEENTRY pServ )
  562. {
  563. CLicRegLicenseService cLicServKey;
  564. LICENSE_MODE lm;
  565. BOOL frt = FALSE;
  566. cLicServKey.SetService( pServ->pszService );
  567. if (ERROR_SUCCESS == cLicServKey.Open( pszComputer, FALSE ))
  568. {
  569. cLicServKey.GetMode( lm );
  570. // check for changes
  571. if ( (pServ->lm != lm) && !cLicServKey.CanChangeMode() )
  572. {
  573. frt = LicViolationDialog( hwndDlg );
  574. }
  575. cLicServKey.Close();
  576. }
  577. return( frt );
  578. }
  579. //-------------------------------------------------------------------
  580. //
  581. // Function: EditInvalidDlg
  582. //
  583. // Summary;
  584. // Display Dialog when user count edit control value is invalid
  585. //
  586. // Arguments;
  587. // hwndDlg [in] - hwnd of dialog
  588. //
  589. // History;
  590. // Nov-30-94 MikeMi Created
  591. //
  592. //-------------------------------------------------------------------
  593. void EditInvalidDlg( HWND hwndDlg )
  594. {
  595. HWND hwndCount = GetDlgItem( hwndDlg, IDC_USERCOUNT);
  596. WCHAR szTitle[TEMPSTR_SIZE];
  597. WCHAR szText[LTEMPSTR_SIZE];
  598. WCHAR szTemp[LTEMPSTR_SIZE];
  599. MessageBeep( MB_VALUELIMIT );
  600. LoadString(g_hinst, IDS_CPCAPTION, szTitle, TEMPSTR_SIZE);
  601. LoadString(g_hinst, IDS_INVALIDUSERCOUNT, szTemp, LTEMPSTR_SIZE);
  602. HRESULT hr = StringCbPrintf( szText, sizeof(szText), szTemp, PERSERVER_MIN, PERSERVER_MAX );
  603. if (SUCCEEDED(hr))
  604. MessageBox( hwndDlg, szText, szTitle, MB_OK | MB_ICONINFORMATION );
  605. // also set focus to edit and select all
  606. SetFocus( hwndCount );
  607. SendMessage( hwndCount, EM_SETSEL, 0, -1 );
  608. }
  609. //-------------------------------------------------------------------
  610. //
  611. // Function: EditValidate
  612. //
  613. // Summary;
  614. // Handle when the value within the user count edit control changes
  615. //
  616. // Arguments;
  617. // hwndDlg [in] - hwnd of dialog
  618. // pserv [in] - currently selected service
  619. //
  620. // Return: FALSE if Edit Value is not valid, TRUE if it is
  621. //
  622. // History;
  623. // Nov-30-94 MikeMi Created
  624. //
  625. //-------------------------------------------------------------------
  626. BOOL EditValidate( HWND hwndDlg, PSERVICEENTRY pServ )
  627. {
  628. BOOL fTranslated;
  629. UINT nValue;
  630. BOOL fValid = TRUE;
  631. // only do this if in PerServer mode
  632. //
  633. if (LICMODE_PERSERVER == pServ->lm)
  634. {
  635. fValid = FALSE;
  636. nValue = GetDlgItemInt( hwndDlg, IDC_USERCOUNT, &fTranslated, FALSE );
  637. if (fTranslated)
  638. {
  639. if (VALIDUSERCOUNT( nValue))
  640. {
  641. pServ->dwLimit = nValue;
  642. fValid = TRUE;
  643. }
  644. }
  645. }
  646. return( fValid );
  647. }
  648. //-------------------------------------------------------------------
  649. //
  650. // Function: OnEditChange
  651. //
  652. // Summary;
  653. // Handle when the value within the user count edit control changes
  654. //
  655. // Arguments;
  656. // hwndDlg [in] - hwnd of dialog
  657. // pserv [in] - currently selected service
  658. //
  659. // History;
  660. // Mar-06-94 MikeMi Created
  661. //
  662. //-------------------------------------------------------------------
  663. void OnEditChange( HWND hwndDlg, HWND hwndCount, PSERVICEENTRY pServ )
  664. {
  665. BOOL fTranslated;
  666. UINT nValue;
  667. BOOL fValid = TRUE;
  668. BOOL fModified = FALSE;
  669. // only do this if in PerServer mode
  670. //
  671. if (LICMODE_PERSERVER == pServ->lm)
  672. {
  673. fValid = FALSE;
  674. nValue = GetDlgItemInt( hwndDlg, IDC_USERCOUNT, &fTranslated, FALSE );
  675. if (fTranslated)
  676. {
  677. #pragma warning(push)
  678. #pragma warning(disable: 4296) // C4296: '>' : expression is always false
  679. if (PERSERVER_MIN > nValue)
  680. {
  681. nValue = PERSERVER_MIN;
  682. fModified = TRUE;
  683. }
  684. else if (PERSERVER_MAX < nValue)
  685. {
  686. nValue = PERSERVER_MAX;
  687. fModified = TRUE;
  688. }
  689. #pragma warning(pop)
  690. pServ->dwLimit = nValue;
  691. }
  692. else
  693. {
  694. // reset to last value
  695. nValue = pServ->dwLimit;
  696. fModified = TRUE;
  697. }
  698. if (fModified)
  699. {
  700. SetDlgItemInt( hwndDlg, IDC_USERCOUNT, nValue, FALSE );
  701. SetFocus( hwndCount );
  702. SendMessage( hwndCount, EM_SETSEL, 0, -1 );
  703. MessageBeep( MB_VALUELIMIT );
  704. }
  705. }
  706. }
  707. //-------------------------------------------------------------------
  708. //
  709. // Function: OnCpaClose
  710. //
  711. // Summary;
  712. // Do work needed when the Control Panel applet is closed.
  713. // Free all Service structures alloced and possible save.
  714. //
  715. // Arguments;
  716. // hwndDlg [in] - Dialog close was requested on
  717. // fSave [in] - Save Services to Registry
  718. //
  719. // History;
  720. // Nov-30-94 MikeMi Created
  721. //
  722. //-------------------------------------------------------------------
  723. void OnCpaClose( HWND hwndDlg, BOOL fSave )
  724. {
  725. HWND hwndService = GetDlgItem( hwndDlg, IDC_SERVICES);
  726. LRESULT cItems = SendMessage( hwndService, CB_GETCOUNT, 0, 0 ) - 1;
  727. LONG_PTR iItem = 0; // this wasn't init and it leads using uninit data in the following CB_SETCURSEL call
  728. PSERVICEENTRY pServ;
  729. LRESULT iSel;
  730. iSel = SendMessage( hwndService, CB_GETCURSEL, 0, 0 );
  731. pServ = (PSERVICEENTRY)SendMessage( hwndService, CB_GETITEMDATA, iSel, 0 );
  732. if ( fSave &&
  733. (pServ->lm == LICMODE_PERSERVER) &&
  734. !EditValidate( hwndDlg, pServ ) )
  735. {
  736. EditInvalidDlg( hwndDlg );
  737. }
  738. else
  739. {
  740. BOOL fCompleted = TRUE;
  741. // loop and check for agreement changes (only needed if saving)
  742. //
  743. if (fSave)
  744. {
  745. for (iItem = cItems; iItem >= 0; iItem--)
  746. {
  747. pServ = (PSERVICEENTRY)SendMessage( hwndService, CB_GETITEMDATA, iItem, 0 );
  748. if (ServiceLicAgreement( hwndDlg,
  749. pServ,
  750. NULL,
  751. LICCPA_HELPFILE,
  752. LICCPA_HELPCONTEXTPERSEAT,
  753. LICCPA_HELPCONTEXTPERSERVER ))
  754. {
  755. SaveServiceToReg( NULL, pServ );
  756. }
  757. else
  758. {
  759. fCompleted = FALSE;
  760. break;
  761. }
  762. }
  763. }
  764. if (fCompleted)
  765. {
  766. // loop and free service entries
  767. //
  768. for (iItem = cItems; iItem >= 0; iItem--)
  769. {
  770. pServ = (PSERVICEENTRY)SendMessage( hwndService, CB_GETITEMDATA, iItem, 0 );
  771. FreeServiceEntry( pServ );
  772. }
  773. EndDialog( hwndDlg, fSave );
  774. }
  775. else
  776. {
  777. // set combo box to last canceled entry
  778. SendMessage( hwndService, CB_SETCURSEL, iItem, 0 );
  779. }
  780. }
  781. }
  782. //-------------------------------------------------------------------
  783. //
  784. // Function: OnSetupClose
  785. //
  786. // Summary;
  787. // Do work needed when the Setup Dialog is closed.
  788. // Free the service structure and possible save it
  789. //
  790. // Arguments;
  791. // hwndDlg [in] - hwnd of dialog this close was requested on
  792. // fSave [in] - Save service to registry
  793. // pServ [in] - the service structure to work with
  794. // psdParams [in] - setup dlg params for help contexts and files
  795. //
  796. // History;
  797. // Nov-30-94 MikeMi Created
  798. //
  799. //-------------------------------------------------------------------
  800. void OnSetupClose( HWND hwndDlg,
  801. BOOL fSave,
  802. PSERVICEENTRY pServ,
  803. PSETUPDLGPARAM psdParams )
  804. {
  805. if ( fSave &&
  806. (pServ->lm == LICMODE_PERSERVER) &&
  807. !EditValidate( hwndDlg, pServ ) )
  808. {
  809. EditInvalidDlg( hwndDlg );
  810. }
  811. else
  812. {
  813. BOOL fCompleted = TRUE;
  814. if (fSave)
  815. {
  816. if (ServiceLicAgreement( hwndDlg,
  817. pServ,
  818. psdParams->pszComputer,
  819. psdParams->pszHelpFile,
  820. psdParams->dwHCPerSeat,
  821. psdParams->dwHCPerServer ))
  822. {
  823. SaveServiceToReg( psdParams->pszComputer, pServ );
  824. // register service at enterprise server
  825. ServiceRegister( psdParams->pszComputer,
  826. psdParams->pszFamilyDisplayName,
  827. psdParams->pszDisplayName );
  828. }
  829. else
  830. {
  831. fCompleted = FALSE;
  832. }
  833. }
  834. else if ( pServ->fIsNewProduct )
  835. {
  836. // new product, but we're aborting
  837. // make sure we don't leave any scraps behind
  838. DWORD winError;
  839. HKEY hkeyInfo;
  840. winError = RegOpenKeyEx( HKEY_LOCAL_MACHINE,
  841. TEXT( "System\\CurrentControlSet\\Services\\LicenseInfo" ),
  842. 0,
  843. KEY_ALL_ACCESS,
  844. &hkeyInfo );
  845. if ( ERROR_SUCCESS == winError )
  846. {
  847. RegDeleteKey( hkeyInfo, pServ->pszService );
  848. RegCloseKey( hkeyInfo );
  849. }
  850. }
  851. if (fCompleted)
  852. {
  853. FreeServiceEntry( pServ );
  854. EndDialog( hwndDlg, fSave );
  855. }
  856. }
  857. }
  858. //-------------------------------------------------------------------
  859. //
  860. // Function: OnSetServiceMode
  861. //
  862. // Summary;
  863. // Handle the users request to change service mode
  864. //
  865. // Aruments;
  866. // hwndDlg [in] - hwnd of dialog
  867. // pszComputer [in] - compter to confirm mode change against
  868. // pServ [in] - The service the request was made agianst
  869. // idCtrl [in] - the control id that was pressed to make this request
  870. //
  871. // History;
  872. // Nov-30-94 MikeMi Created
  873. //
  874. //-------------------------------------------------------------------
  875. void OnSetServiceMode( HWND hwndDlg, LPCWSTR pszComputer, PSERVICEENTRY pServ, WORD idCtrl )
  876. {
  877. LICENSE_MODE lmOld = pServ->lm;
  878. BOOL fChanged = FALSE;
  879. BOOL fDisplay = TRUE;
  880. if (idCtrl == IDC_PERSEAT)
  881. {
  882. fChanged = (pServ->lm != LICMODE_PERSEAT);
  883. pServ->lm = LICMODE_PERSEAT;
  884. fDisplay = (IsDlgButtonChecked(hwndDlg, IDC_PERSERVER) == BST_UNCHECKED);
  885. }
  886. if (idCtrl == IDC_PERSERVER)
  887. {
  888. fChanged = (pServ->lm != LICMODE_PERSERVER);
  889. pServ->lm = LICMODE_PERSERVER;
  890. fDisplay = (IsDlgButtonChecked(hwndDlg, IDC_PERSEAT) == BST_UNCHECKED);
  891. }
  892. // only check for violation the first time the user switches
  893. if (fChanged)
  894. {
  895. if (fDisplay)
  896. {
  897. if (!ServiceViolation(hwndDlg, pszComputer, pServ))
  898. return;
  899. else
  900. {
  901. if (idCtrl == IDC_PERSEAT)
  902. SetFocus(GetDlgItem(hwndDlg, IDC_PERSERVER));
  903. if (idCtrl == IDC_PERSERVER)
  904. SetFocus(GetDlgItem(hwndDlg, IDC_PERSEAT));
  905. }
  906. }
  907. pServ->lm = lmOld;
  908. InitDialogForService( hwndDlg, pServ );
  909. }
  910. }
  911. //-------------------------------------------------------------------
  912. //
  913. // Function: OnSpinButton
  914. //
  915. // Summary;
  916. // Handle the events from user interactions with the spin control
  917. //
  918. // Arguments;
  919. // hwndDlg [in] - hwnd of dialog
  920. // wAction [in] - spin control event
  921. // pServ [in] - current service selected
  922. //
  923. // History;
  924. // Nov-30-94 MikeMi Created
  925. //
  926. //-------------------------------------------------------------------
  927. void OnSpinButton( HWND hwndDlg, WORD wAction, PSERVICEENTRY pServ )
  928. {
  929. HWND hwndCount = GetDlgItem( hwndDlg, IDC_USERCOUNT);
  930. INT nValue;
  931. BOOL fValidAction = TRUE;
  932. nValue = pServ->dwLimit;
  933. switch (wAction)
  934. {
  935. case SB_LINEUP:
  936. nValue++;
  937. break;
  938. case SB_LINEDOWN:
  939. nValue--;
  940. break;
  941. case SB_PAGEUP:
  942. nValue += PERSERVER_PAGE;
  943. break;
  944. case SB_PAGEDOWN:
  945. nValue -= PERSERVER_PAGE;
  946. break;
  947. case SB_TOP:
  948. nValue = PERSERVER_MAX;
  949. break;
  950. case SB_BOTTOM:
  951. nValue = PERSERVER_MIN;
  952. break;
  953. default:
  954. fValidAction = FALSE;
  955. break;
  956. }
  957. if (fValidAction)
  958. {
  959. nValue = max( PERSERVER_MIN, nValue );
  960. nValue = min( PERSERVER_MAX, nValue );
  961. if (pServ->dwLimit == (DWORD)nValue)
  962. {
  963. MessageBeep( MB_VALUELIMIT );
  964. }
  965. else
  966. {
  967. pServ->dwLimit = nValue;
  968. SetDlgItemInt( hwndDlg, IDC_USERCOUNT, pServ->dwLimit, FALSE );
  969. }
  970. SetFocus( hwndCount );
  971. SendMessage( hwndCount, EM_SETSEL, 0, -1 );
  972. }
  973. }
  974. //-------------------------------------------------------------------
  975. //
  976. // Function: UpdatePerServerLicenses
  977. //
  978. // Summary;
  979. // Update the number of per server licenses displayed in the
  980. // dialog with the proper value.
  981. //
  982. // Arguments;
  983. // hwndDlg [in] - hwnd of dialog
  984. // pServ [in] - current service selected
  985. //
  986. // History;
  987. // Dec-19-95 JeffParh Created
  988. //
  989. //-------------------------------------------------------------------
  990. static void UpdatePerServerLicenses( HWND hwndDlg, PSERVICEENTRY pServ )
  991. {
  992. LLS_HANDLE hLls;
  993. DWORD dwError;
  994. BOOL fIsSecure;
  995. BOOL fUseRegistry;
  996. fUseRegistry = TRUE;
  997. dwError = LlsConnect( pServ->pszComputer, &hLls );
  998. if ( ERROR_SUCCESS == dwError )
  999. {
  1000. if ( pServ->fIsNewProduct )
  1001. {
  1002. dwError = LlsProductSecurityGet( hLls, pServ->pszDisplayName, &fIsSecure );
  1003. if ( ( ERROR_SUCCESS == dwError )
  1004. && fIsSecure )
  1005. {
  1006. dwError = LlsProductLicensesGet( hLls, pServ->pszDisplayName, LLS_LICENSE_MODE_PER_SERVER, &pServ->dwLimit );
  1007. if ( ERROR_SUCCESS == dwError )
  1008. {
  1009. fUseRegistry = FALSE;
  1010. }
  1011. }
  1012. }
  1013. else
  1014. {
  1015. dwError = LlsProductLicensesGet( hLls, pServ->pszDisplayName, LLS_LICENSE_MODE_PER_SERVER, &pServ->dwLimit );
  1016. if ( ERROR_SUCCESS == dwError )
  1017. {
  1018. fUseRegistry = FALSE;
  1019. }
  1020. }
  1021. LlsClose( hLls );
  1022. }
  1023. if ( fUseRegistry )
  1024. {
  1025. CLicRegLicenseService cLicServKey;
  1026. cLicServKey.SetService( pServ->pszService );
  1027. cLicServKey.Open( NULL, FALSE );
  1028. cLicServKey.GetUserLimit( pServ->dwLimit );
  1029. cLicServKey.Close();
  1030. }
  1031. SetDlgItemInt( hwndDlg, IDC_USERCOUNT, pServ->dwLimit, FALSE );
  1032. UpdateWindow( hwndDlg );
  1033. }
  1034. //-------------------------------------------------------------------
  1035. //
  1036. // Function: OnAddLicenses
  1037. //
  1038. // Summary;
  1039. // Handle the BN_CLICKED message from the Add Licenses button.
  1040. //
  1041. // Arguments;
  1042. // hwndDlg [in] - hwnd of dialog
  1043. // pServ [in] - current service selected
  1044. //
  1045. // History;
  1046. // Dec-19-95 JeffParh Created
  1047. //
  1048. //-------------------------------------------------------------------
  1049. void OnAddLicenses( HWND hwndDlg, PSERVICEENTRY pServ )
  1050. {
  1051. LPSTR pszAscProductName;
  1052. LPSTR pszAscServerName = NULL;
  1053. CHAR szAscServerName[ 3 + MAX_PATH ];
  1054. HRESULT hr;
  1055. size_t cch;
  1056. cch = 1 + lstrlen(pServ->pszDisplayName);
  1057. pszAscProductName = (LPSTR) LocalAlloc( LPTR, cch );
  1058. if ( NULL != pszAscProductName )
  1059. {
  1060. hr = StringCchPrintfA(pszAscProductName, cch, "%ls", pServ->pszDisplayName);
  1061. if (S_OK != hr)
  1062. return;
  1063. if ( NULL != pServ->pszComputer )
  1064. {
  1065. hr = StringCbPrintfA(szAscServerName, sizeof(szAscServerName), "%ls", pServ->pszComputer );
  1066. if (S_OK != hr)
  1067. return;
  1068. pszAscServerName = szAscServerName;
  1069. }
  1070. CCFCertificateEnterUI( hwndDlg, pszAscServerName, pszAscProductName, "Microsoft", CCF_ENTER_FLAG_PER_SERVER_ONLY, NULL );
  1071. UpdatePerServerLicenses( hwndDlg, pServ );
  1072. LocalFree( pszAscProductName );
  1073. g_fWarned = TRUE;
  1074. }
  1075. }
  1076. //-------------------------------------------------------------------
  1077. //
  1078. // Function: OnRemoveLicenses
  1079. //
  1080. // Summary;
  1081. // Handle the BN_CLICKED message from the Remove Licenses button.
  1082. //
  1083. // Arguments;
  1084. // hwndDlg [in] - hwnd of dialog
  1085. // pServ [in] - current service selected
  1086. //
  1087. // History;
  1088. // Dec-19-95 JeffParh Created
  1089. //
  1090. //-------------------------------------------------------------------
  1091. void OnRemoveLicenses( HWND hwndDlg, PSERVICEENTRY pServ )
  1092. {
  1093. LPSTR pszAscProductName;
  1094. LPSTR pszAscServerName = NULL;
  1095. CHAR szAscServerName[ 3 + MAX_PATH ];
  1096. HRESULT hr;
  1097. size_t cch;
  1098. cch = 1 + lstrlen(pServ->pszDisplayName);
  1099. pszAscProductName = (LPSTR) LocalAlloc( LMEM_FIXED, cch );
  1100. if ( NULL != pszAscProductName )
  1101. {
  1102. hr = StringCchPrintfA( pszAscProductName, cch, "%ls", pServ->pszDisplayName );
  1103. if (S_OK != hr)
  1104. return;
  1105. if ( NULL != pServ->pszComputer )
  1106. {
  1107. hr = StringCbPrintfA( szAscServerName, sizeof(szAscServerName), "%ls", pServ->pszComputer );
  1108. if (S_OK != hr)
  1109. return;
  1110. pszAscServerName = szAscServerName;
  1111. }
  1112. CCFCertificateRemoveUI( hwndDlg, pszAscServerName, pszAscProductName, "Microsoft", NULL, NULL );
  1113. UpdatePerServerLicenses( hwndDlg, pServ );
  1114. LocalFree( pszAscProductName );
  1115. }
  1116. }
  1117. //-------------------------------------------------------------------
  1118. //
  1119. // Function: OnSetupInitDialog
  1120. //
  1121. // Summary;
  1122. // Handle the initialization of the Setup Dialog
  1123. //
  1124. // Arguments;
  1125. // hwndDlg [in] - the dialog to initialize
  1126. // pszParams [in] - the dialog params to use to initialize
  1127. // pServ [out] - the current service
  1128. //
  1129. // Return;
  1130. // TRUE if succesful, otherwise false
  1131. //
  1132. // Notes;
  1133. //
  1134. // History;
  1135. // Nov-11-1994 MikeMi Created
  1136. //
  1137. //-------------------------------------------------------------------
  1138. #pragma warning (push)
  1139. #pragma warning (disable : 4127) //avoid warning on while false
  1140. BOOL OnSetupInitDialog( HWND hwndDlg,
  1141. PSETUPDLGPARAM psdParams,
  1142. PSERVICEENTRY& pServ )
  1143. {
  1144. BOOL frt = TRUE;
  1145. CLicRegLicense cLicKey;
  1146. LONG lrt;
  1147. INT nrt;
  1148. BOOL fNew;
  1149. do
  1150. {
  1151. CenterDialogToScreen( hwndDlg );
  1152. lrt = cLicKey.Open( fNew, psdParams->pszComputer );
  1153. nrt = AccessOk( hwndDlg, lrt, FALSE );
  1154. if (ERR_NONE != nrt)
  1155. {
  1156. EndDialog( hwndDlg, nrt );
  1157. frt = FALSE;
  1158. break;
  1159. }
  1160. pServ = CreateServiceEntry( psdParams->pszComputer,
  1161. psdParams->pszService,
  1162. psdParams->pszFamilyDisplayName,
  1163. psdParams->pszDisplayName );
  1164. if (pServ == NULL)
  1165. {
  1166. LowMemoryDlg();
  1167. EndDialog( hwndDlg, -2 );
  1168. break;
  1169. }
  1170. if (NULL == psdParams->pszHelpFile)
  1171. {
  1172. HWND hwndHelp = GetDlgItem( hwndDlg, IDC_BUTTONHELP );
  1173. // remove the help button
  1174. EnableWindow( hwndHelp, FALSE );
  1175. ShowWindow( hwndHelp, SW_HIDE );
  1176. }
  1177. if (psdParams->fNoExit)
  1178. {
  1179. HWND hwndExit = GetDlgItem( hwndDlg, IDCANCEL );
  1180. // remove the ExitSetup button
  1181. EnableWindow( hwndExit, FALSE );
  1182. ShowWindow( hwndExit, SW_HIDE );
  1183. }
  1184. // set char limit on edit box
  1185. InitUserEdit( hwndDlg );
  1186. // make sure title static text is set for this service
  1187. InitTitleText( hwndDlg, pServ );
  1188. // defaul to PerServer with Focus on edit
  1189. pServ->lm = LICMODE_PERSERVER;
  1190. // change default for setup only
  1191. // pServ->dwLimit = 1;
  1192. InitDialogForService( hwndDlg, pServ );
  1193. SetFocus( GetDlgItem( hwndDlg, IDC_PERSERVER ) );
  1194. } while (FALSE); // used to remove gotos
  1195. return( frt );
  1196. }
  1197. #pragma warning (pop) //4127
  1198. //-------------------------------------------------------------------
  1199. //
  1200. // Function: OnCpaInitDialog
  1201. //
  1202. // Summary;
  1203. // Handle the initialization of the Control Panel Applet Dialog
  1204. //
  1205. // Arguments;
  1206. // hwndDlg [in] - the dialog to initialize
  1207. // fEnableReplication [in] -
  1208. // iSel [out] - the current service selected
  1209. // pServ [out] - the current service
  1210. //
  1211. // Return;
  1212. // TRUE if succesful, otherwise false
  1213. //
  1214. // Notes;
  1215. //
  1216. // History;
  1217. // Nov-11-1994 MikeMi Created
  1218. // Mar-08-1995 MikeMi Added removal of Replication button
  1219. //
  1220. //-------------------------------------------------------------------
  1221. BOOL OnCpaInitDialog( HWND hwndDlg,
  1222. BOOL fEnableReplication,
  1223. LONG_PTR& iSel,
  1224. PSERVICEENTRY& pServ )
  1225. {
  1226. BOOL frt = FALSE;
  1227. CLicRegLicense cLicKey;
  1228. LONG lrt;
  1229. INT nrt;
  1230. BOOL fNew;
  1231. lrt = cLicKey.Open( fNew );
  1232. nrt = AccessOk( hwndDlg, lrt, TRUE );
  1233. if (ERR_NONE == nrt)
  1234. {
  1235. DWORD i = 0;
  1236. WCHAR szText[TEMPSTR_SIZE];
  1237. DWORD cchText = TEMPSTR_SIZE;
  1238. HWND hwndService = GetDlgItem( hwndDlg, IDC_SERVICES);
  1239. LONG_PTR lIndex;
  1240. CenterDialogToScreen( hwndDlg );
  1241. //
  1242. // remove replication button if product used on pre 3.51
  1243. //
  1244. if (!fEnableReplication)
  1245. {
  1246. HWND hwndRep = GetDlgItem( hwndDlg, IDC_CONFIGURE );
  1247. EnableWindow( hwndRep, FALSE );
  1248. ShowWindow( hwndRep, SW_HIDE );
  1249. }
  1250. // load the service names from the registry into combo box
  1251. // Create service local state structures as we go
  1252. //
  1253. while (ERROR_SUCCESS == cLicKey.EnumService(i, szText, cchText ))
  1254. {
  1255. pServ = CreateServiceEntry( NULL, szText, L"<unknown>", L"<undefined>" );
  1256. if (pServ == NULL)
  1257. {
  1258. LowMemoryDlg();
  1259. EndDialog( hwndDlg, -2 );
  1260. return( TRUE );
  1261. }
  1262. lIndex = SendMessage( hwndService, CB_ADDSTRING, 0, (LPARAM)pServ->pszDisplayName );
  1263. SendMessage( hwndService, CB_SETITEMDATA, lIndex, (LPARAM)pServ );
  1264. i++;
  1265. cchText = TEMPSTR_SIZE;
  1266. }
  1267. cLicKey.Close();
  1268. if (0 == i)
  1269. {
  1270. // no services installed
  1271. //
  1272. WCHAR szTitle[TEMPSTR_SIZE];
  1273. LoadString(g_hinst, IDS_CPCAPTION, szTitle, TEMPSTR_SIZE);
  1274. LoadString(g_hinst, IDS_NOSERVICES, szText, TEMPSTR_SIZE);
  1275. MessageBox(hwndDlg, szText, szTitle, MB_OK|MB_ICONINFORMATION);
  1276. frt = FALSE;
  1277. }
  1278. else
  1279. {
  1280. // make sure a service is selected and update dialog
  1281. iSel = SendMessage( hwndService, CB_GETCURSEL, 0, 0 );
  1282. if (CB_ERR == iSel)
  1283. {
  1284. iSel = 0;
  1285. SendMessage( hwndService, CB_SETCURSEL, iSel, 0 );
  1286. }
  1287. pServ = (PSERVICEENTRY)SendMessage( hwndService, CB_GETITEMDATA, iSel, 0 );
  1288. // Set edit text chars limit
  1289. InitUserEdit( hwndDlg );
  1290. InitDialogForService( hwndDlg, pServ );
  1291. frt = TRUE;
  1292. }
  1293. }
  1294. if (!frt)
  1295. {
  1296. EndDialog( hwndDlg, -1 );
  1297. }
  1298. return( frt );
  1299. }
  1300. //-------------------------------------------------------------------
  1301. //
  1302. // Function: dlgprocLICCPA
  1303. //
  1304. // Summary;
  1305. // The dialog procedure for the main Control Panel Applet Dialog
  1306. //
  1307. // Arguments;
  1308. // hwndDlg [in] - handle of Dialog window
  1309. // uMsg [in] - message
  1310. // lParam1 [in] - first message parameter
  1311. // lParam2 [in] - second message parameter
  1312. //
  1313. // Return;
  1314. // message dependant
  1315. //
  1316. // Notes;
  1317. //
  1318. // History;
  1319. // Nov-11-1994 MikeMi Created
  1320. // Mar-08-1995 MikeMi Added removal of Replication button
  1321. // from WM_INITDIALOG
  1322. // Mar-14-95 MikeMi Added F1 PWM_HELP message
  1323. //
  1324. //-------------------------------------------------------------------
  1325. INT_PTR CALLBACK dlgprocLICCPA( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  1326. {
  1327. BOOL frt = FALSE;
  1328. static PSERVICEENTRY pServ = NULL;
  1329. static LONG_PTR iSel = 0;
  1330. switch (uMsg)
  1331. {
  1332. case WM_INITDIALOG:
  1333. OnCpaInitDialog( hwndDlg, (BOOL)lParam , iSel, pServ );
  1334. return( TRUE ); // use default keyboard focus
  1335. break;
  1336. case WM_COMMAND:
  1337. switch (HIWORD( wParam ))
  1338. {
  1339. case BN_CLICKED:
  1340. switch (LOWORD( wParam ))
  1341. {
  1342. case IDOK:
  1343. frt = TRUE; // use as save flag
  1344. // intentional no break
  1345. case IDCANCEL:
  1346. OnCpaClose( hwndDlg, frt );
  1347. frt = FALSE;
  1348. break;
  1349. case IDC_PERSEAT:
  1350. case IDC_PERSERVER:
  1351. OnSetServiceMode( hwndDlg, NULL, pServ, LOWORD(wParam) );
  1352. break;
  1353. case IDC_CONFIGURE:
  1354. DialogBox(g_hinst,
  1355. MAKEINTRESOURCE(IDD_CPADLG_LCACONF),
  1356. hwndDlg,
  1357. dlgprocLICCPACONFIG );
  1358. break;
  1359. case IDC_BUTTONHELP:
  1360. PostMessage( hwndDlg, PWM_HELP, 0, 0 );
  1361. break;
  1362. case IDC_ADD_LICENSES:
  1363. OnAddLicenses( hwndDlg, pServ );
  1364. break;
  1365. case IDC_REMOVE_LICENSES:
  1366. OnRemoveLicenses( hwndDlg, pServ );
  1367. break;
  1368. default:
  1369. break;
  1370. }
  1371. break;
  1372. case CBN_SELENDOK:
  1373. if ((LICMODE_PERSERVER == pServ->lm) &&
  1374. !EditValidate( hwndDlg, pServ ))
  1375. {
  1376. // reset back to original
  1377. SendMessage( (HWND)lParam, CB_SETCURSEL, iSel, 0 );
  1378. EditInvalidDlg( hwndDlg );
  1379. }
  1380. else
  1381. {
  1382. iSel = SendMessage( (HWND)lParam, CB_GETCURSEL, 0, 0 );
  1383. pServ = (PSERVICEENTRY)SendMessage( (HWND)lParam, CB_GETITEMDATA, iSel, 0 );
  1384. InitDialogForService( hwndDlg, pServ );
  1385. }
  1386. break;
  1387. case EN_UPDATE:
  1388. if (IDC_USERCOUNT == LOWORD(wParam))
  1389. {
  1390. OnEditChange( hwndDlg, (HWND)(lParam), pServ );
  1391. }
  1392. break;
  1393. default:
  1394. break;
  1395. }
  1396. break;
  1397. case WM_VSCROLL:
  1398. OnSpinButton( hwndDlg, LOWORD( wParam ), pServ );
  1399. break;
  1400. default:
  1401. if (PWM_HELP == uMsg)
  1402. HtmlHelp(hwndDlg, LICCPA_HTMLHELPFILE, HH_DISPLAY_TOPIC, (DWORD_PTR)LICCPA_CHOOSEMODE_HELPFILE);
  1403. break;
  1404. }
  1405. return( frt );
  1406. }
  1407. //-------------------------------------------------------------------
  1408. //
  1409. // Function: dlgprocLICSETUP
  1410. //
  1411. // Summary;
  1412. // The dialog procedure for the Setup entry point Dialog
  1413. //
  1414. // Arguments;
  1415. // hwndDlg [in] - handle of Dialog window
  1416. // uMsg [in] - message
  1417. // lParam1 [in] - first message parameter
  1418. // lParam2 [in] - second message parameter
  1419. //
  1420. // Return;
  1421. // message dependant
  1422. //
  1423. // Notes;
  1424. //
  1425. // History;
  1426. // Nov-11-1994 MikeMi Created
  1427. // Mar-14-95 MikeMi Added F1 PWM_HELP message
  1428. //
  1429. //-------------------------------------------------------------------
  1430. INT_PTR CALLBACK dlgprocLICSETUP( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  1431. {
  1432. BOOL frt = FALSE;
  1433. static PSERVICEENTRY pServ;
  1434. static PSETUPDLGPARAM psdParams;
  1435. switch (uMsg)
  1436. {
  1437. case WM_INITDIALOG:
  1438. psdParams = (PSETUPDLGPARAM)lParam;
  1439. OnSetupInitDialog( hwndDlg, psdParams, pServ );
  1440. frt = FALSE; // we set the focus
  1441. break;
  1442. case WM_COMMAND:
  1443. switch (HIWORD( wParam ))
  1444. {
  1445. case BN_CLICKED:
  1446. switch (LOWORD( wParam ))
  1447. {
  1448. case IDOK:
  1449. frt = TRUE; // use as save flag
  1450. // intentional no break
  1451. case IDCANCEL:
  1452. OnSetupClose( hwndDlg, frt, pServ, psdParams );
  1453. frt = FALSE;
  1454. break;
  1455. case IDC_PERSEAT:
  1456. case IDC_PERSERVER:
  1457. OnSetServiceMode( hwndDlg, psdParams->pszComputer, pServ, LOWORD(wParam) );
  1458. break;
  1459. case IDC_BUTTONHELP:
  1460. PostMessage( hwndDlg, PWM_HELP, 0, 0 );
  1461. break;
  1462. case IDC_ADD_LICENSES:
  1463. OnAddLicenses( hwndDlg, pServ );
  1464. break;
  1465. case IDC_REMOVE_LICENSES:
  1466. OnRemoveLicenses( hwndDlg, pServ );
  1467. break;
  1468. default:
  1469. break;
  1470. }
  1471. break;
  1472. case EN_UPDATE:
  1473. if (IDC_USERCOUNT == LOWORD(wParam))
  1474. {
  1475. OnEditChange( hwndDlg, (HWND)(lParam), pServ );
  1476. }
  1477. break;
  1478. default:
  1479. break;
  1480. }
  1481. break;
  1482. case WM_VSCROLL:
  1483. OnSpinButton( hwndDlg, LOWORD( wParam ), pServ );
  1484. break;
  1485. default:
  1486. if (PWM_HELP == uMsg)
  1487. {
  1488. ::HtmlHelp( hwndDlg, LICCPA_HTMLHELPFILE, HH_DISPLAY_TOPIC,0);
  1489. }
  1490. break;
  1491. }
  1492. return( frt );
  1493. }
  1494. //-------------------------------------------------------------------
  1495. //
  1496. // Function: OnPerSeatInitDialog
  1497. //
  1498. // Summary;
  1499. // Handle the initialization of the PerSeat only Setup Dialog
  1500. //
  1501. // Arguments;
  1502. // hwndDlg [in] - the dialog to initialize
  1503. // psdParams [in] - used for the displayname and service name
  1504. //
  1505. // Notes;
  1506. //
  1507. // History;
  1508. // Dec-08-1994 MikeMi Created
  1509. //
  1510. //-------------------------------------------------------------------
  1511. void OnPerSeatInitDialog( HWND hwndDlg, PSETUPDLGPARAM psdParams )
  1512. {
  1513. HWND hwndOK = GetDlgItem( hwndDlg, IDOK );
  1514. CLicRegLicense cLicKey;
  1515. BOOL fNew;
  1516. LONG lrt;
  1517. INT nrt;
  1518. lrt = cLicKey.Open( fNew, psdParams->pszComputer );
  1519. nrt = AccessOk( NULL, lrt, FALSE );
  1520. if (ERR_NONE == nrt)
  1521. {
  1522. CenterDialogToScreen( hwndDlg );
  1523. InitStaticWithService( hwndDlg, IDC_STATICTITLE, psdParams->pszDisplayName );
  1524. InitStaticWithService2( hwndDlg, IDC_STATICINFO, psdParams->pszDisplayName );
  1525. // disable OK button at start!
  1526. EnableWindow( hwndOK, FALSE );
  1527. // if help is not defined, remove the button
  1528. if (NULL == psdParams->pszHelpFile)
  1529. {
  1530. HWND hwndHelp = GetDlgItem( hwndDlg, IDC_BUTTONHELP );
  1531. EnableWindow( hwndHelp, FALSE );
  1532. ShowWindow( hwndHelp, SW_HIDE );
  1533. }
  1534. }
  1535. else
  1536. {
  1537. EndDialog( hwndDlg, nrt );
  1538. }
  1539. }
  1540. //-------------------------------------------------------------------
  1541. //
  1542. // Function: OnPerSeatSetupClose
  1543. //
  1544. // Summary;
  1545. // Do work needed when the Setup Dialog is closed.
  1546. // Save to Reg the Service entry.
  1547. //
  1548. // Arguments;
  1549. // hwndDlg [in] - hwnd of dialog this close was requested on
  1550. // fSave [in] - Save service to registry
  1551. // psdParams [in] - used for the service name and displayname
  1552. //
  1553. // History;
  1554. // Nov-30-94 MikeMi Created
  1555. //
  1556. //-------------------------------------------------------------------
  1557. void OnPerSeatSetupClose( HWND hwndDlg, BOOL fSave, PSETUPDLGPARAM psdParams )
  1558. {
  1559. int nrt = fSave;
  1560. if (fSave)
  1561. {
  1562. CLicRegLicenseService cLicServKey;
  1563. cLicServKey.SetService( psdParams->pszService );
  1564. cLicServKey.Open( psdParams->pszComputer );
  1565. // configure license rule of one change from PerServer to PerSeat
  1566. //
  1567. cLicServKey.SetChangeFlag( TRUE );
  1568. cLicServKey.SetUserLimit( 0 );
  1569. cLicServKey.SetDisplayName( psdParams->pszDisplayName );
  1570. cLicServKey.SetFamilyDisplayName( psdParams->pszFamilyDisplayName );
  1571. cLicServKey.SetMode( LICMODE_PERSEAT );
  1572. cLicServKey.Close();
  1573. // register service at enterprise server
  1574. ServiceRegister( psdParams->pszComputer,
  1575. psdParams->pszFamilyDisplayName,
  1576. psdParams->pszDisplayName );
  1577. }
  1578. EndDialog( hwndDlg, nrt );
  1579. }
  1580. //-------------------------------------------------------------------
  1581. //
  1582. // Function: OnPerSeatAgree
  1583. //
  1584. // Summary;
  1585. // Handle the user interaction with the Agree Check box
  1586. //
  1587. // Arguments;
  1588. // hwndDlg [in] - the dialog to initialize
  1589. //
  1590. // Return;
  1591. // TRUE if succesful, otherwise false
  1592. //
  1593. // Notes;
  1594. //
  1595. // History;
  1596. // Nov-11-1994 MikeMi Created
  1597. //
  1598. //-------------------------------------------------------------------
  1599. void OnPerSeatAgree( HWND hwndDlg )
  1600. {
  1601. HWND hwndOK = GetDlgItem( hwndDlg, IDOK );
  1602. BOOL fChecked = !IsDlgButtonChecked( hwndDlg, IDC_AGREE );
  1603. CheckDlgButton( hwndDlg, IDC_AGREE, fChecked );
  1604. EnableWindow( hwndOK, fChecked );
  1605. }
  1606. //-------------------------------------------------------------------
  1607. //
  1608. // Function: dlgprocPERSEATSETUP
  1609. //
  1610. // Summary;
  1611. // The dialog procedure for the PerSeat only Setup Dialog
  1612. //
  1613. // Arguments;
  1614. // hwndDlg [in] - handle of Dialog window
  1615. // uMsg [in] - message
  1616. // lParam1 [in] - first message parameter
  1617. // lParam2 [in] - second message parameter
  1618. //
  1619. // Return;
  1620. // message dependant
  1621. //
  1622. // Notes;
  1623. //
  1624. // History;
  1625. // Nov-11-1994 MikeMi Created
  1626. // Mar-14-95 MikeMi Added F1 PWM_HELP message
  1627. //
  1628. //-------------------------------------------------------------------
  1629. INT_PTR CALLBACK dlgprocPERSEATSETUP( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  1630. {
  1631. BOOL frt = FALSE;
  1632. static PSETUPDLGPARAM psdParams;
  1633. switch (uMsg)
  1634. {
  1635. case WM_INITDIALOG:
  1636. psdParams = (PSETUPDLGPARAM)lParam;
  1637. OnPerSeatInitDialog( hwndDlg, psdParams );
  1638. frt = TRUE; // we use the default focus
  1639. break;
  1640. case WM_COMMAND:
  1641. switch (HIWORD( wParam ))
  1642. {
  1643. case BN_CLICKED:
  1644. switch (LOWORD( wParam ))
  1645. {
  1646. case IDOK:
  1647. frt = TRUE; // use as save flag
  1648. // intentional no break
  1649. case IDCANCEL:
  1650. OnPerSeatSetupClose( hwndDlg, frt, psdParams );
  1651. frt = FALSE;
  1652. break;
  1653. case IDC_BUTTONHELP:
  1654. PostMessage( hwndDlg, PWM_HELP, 0, 0 );
  1655. break;
  1656. case IDC_AGREE:
  1657. OnPerSeatAgree( hwndDlg );
  1658. break;
  1659. default:
  1660. break;
  1661. }
  1662. break;
  1663. default:
  1664. break;
  1665. }
  1666. break;
  1667. default:
  1668. if (PWM_HELP == uMsg)
  1669. {
  1670. ::HtmlHelp( hwndDlg, LICCPA_HTMLHELPFILE, HH_DISPLAY_TOPIC,0);
  1671. }
  1672. break;
  1673. }
  1674. return( frt );
  1675. }
  1676. //-------------------------------------------------------------------
  1677. //
  1678. // Function: SetupDialog
  1679. //
  1680. // Summary;
  1681. // Init and raises main setup dialog.
  1682. //
  1683. // Arguments;
  1684. // hwndDlg [in] - handle of Dialog window
  1685. // dlgParem [in] - Setup params
  1686. //
  1687. // Return;
  1688. // 1 - OK button was used to exit
  1689. // 0 - Cancel button was used to exit
  1690. // -1 - General Dialog error
  1691. //
  1692. // Notes;
  1693. //
  1694. // History;
  1695. // Dec-05-1994 MikeMi Created
  1696. //
  1697. //-------------------------------------------------------------------
  1698. INT_PTR SetupDialog( HWND hwndParent, SETUPDLGPARAM& dlgParam )
  1699. {
  1700. INT_PTR nError;
  1701. nError = DialogBoxParam( g_hinst,
  1702. MAKEINTRESOURCE(IDD_SETUPDLG),
  1703. hwndParent,
  1704. dlgprocLICSETUP,
  1705. (LPARAM)&dlgParam );
  1706. return( nError );
  1707. }
  1708. //-------------------------------------------------------------------
  1709. //
  1710. // Function: PerSeatSetupDialog
  1711. //
  1712. // Summary;
  1713. // Init and raises Per Seat only setup dialog.
  1714. //
  1715. // Arguments;
  1716. // hwndDlg [in] - handle of Dialog window
  1717. // dlgParem [in] - Setup params
  1718. //
  1719. // Return;
  1720. // 1 - OK button was used to exit
  1721. // 0 - Cancel button was used to exit
  1722. // -1 - General Dialog error
  1723. //
  1724. // Notes;
  1725. //
  1726. // History;
  1727. // Dec-05-1994 MikeMi Created
  1728. //
  1729. //-------------------------------------------------------------------
  1730. INT_PTR PerSeatSetupDialog( HWND hwndParent, SETUPDLGPARAM& dlgParam )
  1731. {
  1732. return( DialogBoxParam( g_hinst,
  1733. MAKEINTRESOURCE(IDD_SETUP2DLG),
  1734. hwndParent,
  1735. dlgprocPERSEATSETUP,
  1736. (LPARAM)&dlgParam ) );
  1737. }
  1738. //-------------------------------------------------------------------
  1739. //
  1740. // Function: CpaDialog
  1741. //
  1742. // Summary;
  1743. // Init and Raise the main control panel applet dialog
  1744. //
  1745. // Arguments;
  1746. // hwndParent [in] - handle of parent window (CONTROL.EXE window)
  1747. //
  1748. // Return;
  1749. // 1 - OK button was used to exit
  1750. // 0 - Cancel button was used to exit
  1751. // -1 - General Dialog error
  1752. //
  1753. // Notes;
  1754. //
  1755. // History;
  1756. // Dec-05-1994 MikeMi Created
  1757. // Mar-08-1995 MikeMi Changed to only one Dialog Resource, Replication Button
  1758. //
  1759. //-------------------------------------------------------------------
  1760. INT_PTR CpaDialog( HWND hwndParent )
  1761. {
  1762. INT_PTR nError;
  1763. OSVERSIONINFO version;
  1764. version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  1765. GetVersionEx( &version );
  1766. BOOL fReplicationEnabled;
  1767. //
  1768. // Only allow Replication Button on 3.51 and above
  1769. //
  1770. fReplicationEnabled = ( (version.dwMajorVersion > 3)
  1771. || (version.dwMajorVersion == 3 && version.dwMinorVersion >= 51) );
  1772. nError = DialogBoxParam( g_hinst,
  1773. MAKEINTRESOURCE(IDD_CPADLG_CONFIGURE),
  1774. hwndParent,
  1775. dlgprocLICCPA,
  1776. (LPARAM)fReplicationEnabled );
  1777. return( nError );
  1778. }
  1779. //-------------------------------------------------------------------
  1780. //
  1781. // Function: UpdateReg
  1782. //
  1783. // Summary;
  1784. // This function is used in unatteneded setup modes, it will
  1785. // configure the registry with the values passed.
  1786. //
  1787. // Arguments;
  1788. // pszComputer [in] - computer name (maybe null for local)
  1789. // pszService [in] - service key name
  1790. // pszFamilyDisplayName [in] - family display name
  1791. // pszDisplayName [in] - displayname
  1792. // lm [in] - license mode
  1793. // dwUsers [in] - number of conncurrent users
  1794. //
  1795. // Return;
  1796. // ERR_NONE - Successful
  1797. // ERR_USERSPARAM - invalid users count
  1798. // ERR_PERMISSIONDENIED - invalid access rights
  1799. //
  1800. // Notes;
  1801. //
  1802. // History;
  1803. // Dec-09-1994 MikeMi Created
  1804. // Apr-26-95 MikeMi Added Computer name and remoting
  1805. //
  1806. //-------------------------------------------------------------------
  1807. int UpdateReg( LPCWSTR pszComputer,
  1808. LPCWSTR pszService,
  1809. LPCWSTR pszFamilyDisplayName,
  1810. LPCWSTR pszDisplayName,
  1811. LICENSE_MODE lm,
  1812. DWORD dwUsers )
  1813. {
  1814. int nrt = ERR_NONE;
  1815. if (VALIDUSERCOUNT( dwUsers ))
  1816. {
  1817. CLicRegLicense cLicKey;
  1818. LONG lrt;
  1819. BOOL fNew;
  1820. lrt = cLicKey.Open( fNew, pszComputer );
  1821. nrt = AccessOk( NULL, lrt, FALSE );
  1822. if (ERR_NONE == nrt)
  1823. {
  1824. CLicRegLicenseService cLicServKey;
  1825. cLicServKey.SetService( pszService );
  1826. cLicServKey.Open( pszComputer );
  1827. // configure license rule of one change from PerServer to PerSeat
  1828. //
  1829. cLicServKey.SetChangeFlag( (LICMODE_PERSEAT == lm ) );
  1830. cLicServKey.SetUserLimit( dwUsers );
  1831. cLicServKey.SetDisplayName( pszDisplayName );
  1832. cLicServKey.SetFamilyDisplayName( pszFamilyDisplayName );
  1833. cLicServKey.SetMode( lm );
  1834. cLicServKey.Close();
  1835. }
  1836. }
  1837. else
  1838. {
  1839. nrt = ERR_USERSPARAM;
  1840. }
  1841. return( nrt );
  1842. }
  1843. //-------------------------------------------------------------------
  1844. //
  1845. // Function: ServiceSecuritySet
  1846. //
  1847. // Summary;
  1848. // Set security on a given product such that it requires a
  1849. // secure certificate for license entry.
  1850. //
  1851. // Arguments;
  1852. // pszComputer [in] - computer on which the license server resides
  1853. // pszDisplayName [in] - display name for the service
  1854. //
  1855. // History;
  1856. // Dec-19-95 JeffParh Created
  1857. //
  1858. //-------------------------------------------------------------------
  1859. int ServiceSecuritySet( LPWSTR pszComputer, LPWSTR pszDisplayName )
  1860. {
  1861. int nError;
  1862. NTSTATUS nt;
  1863. LLS_HANDLE hLls;
  1864. // register the product as secure on the target server
  1865. nt = LlsConnect( pszComputer, &hLls );
  1866. if ( STATUS_SUCCESS != nt )
  1867. {
  1868. nError = ERR_NOREMOTESERVER;
  1869. }
  1870. else
  1871. {
  1872. if ( !LlsCapabilityIsSupported( hLls, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  1873. {
  1874. nError = ERR_DOWNLEVEL;
  1875. }
  1876. else
  1877. {
  1878. nt = LlsProductSecuritySetW( hLls, pszDisplayName );
  1879. if ( STATUS_SUCCESS != nt )
  1880. {
  1881. nError = ERR_CERTREQFAILED;
  1882. }
  1883. else
  1884. {
  1885. nError = ERR_NONE;
  1886. }
  1887. }
  1888. LlsClose( hLls );
  1889. }
  1890. // register the product as secure on the enterprise server
  1891. // it is acceptable for this to fail (the enterprise server may
  1892. // be downlevel)
  1893. if ( ERR_NONE == nError )
  1894. {
  1895. PLLS_CONNECT_INFO_0 pConnectInfo = NULL;
  1896. nt = LlsConnectEnterprise( pszComputer, &hLls, 0, (LPBYTE *) &pConnectInfo );
  1897. if ( STATUS_SUCCESS == nt )
  1898. {
  1899. LlsFreeMemory( pConnectInfo );
  1900. if ( LlsCapabilityIsSupported( hLls, LLS_CAPABILITY_SECURE_CERTIFICATES ) )
  1901. {
  1902. LlsProductSecuritySetW( hLls, pszDisplayName );
  1903. }
  1904. LlsClose( hLls );
  1905. }
  1906. }
  1907. return nError;
  1908. }
  1909. //-------------------------------------------------------------------
  1910. //
  1911. // Function: ServiceRegister
  1912. //
  1913. // Summary;
  1914. // Register a service at the enterprise server corresponding to
  1915. // the given server so that per seat licenses may be added
  1916. // immediately, rather than it taking up until the next
  1917. // replication cycle for the product to be listed.
  1918. //
  1919. // Arguments;
  1920. // pszComputer [in] - computer for which to register the service
  1921. // pszFamilyDisplayName [in] - family display name of the service
  1922. // pszDisplayName [in] - display name of the service
  1923. //
  1924. // History;
  1925. // Dec-19-95 JeffParh Created
  1926. //
  1927. //-------------------------------------------------------------------
  1928. static int ServiceRegister( LPWSTR pszComputer,
  1929. LPWSTR pszFamilyDisplayName,
  1930. LPWSTR pszDisplayName )
  1931. {
  1932. int nError;
  1933. NTSTATUS nt;
  1934. LLS_HANDLE hLls;
  1935. PLLS_CONNECT_INFO_0 pConnectInfo = NULL;
  1936. // register the product as secure on the enterprise server
  1937. nt = LlsConnectEnterprise( pszComputer, &hLls, 0, (LPBYTE *) &pConnectInfo );
  1938. if ( STATUS_SUCCESS != nt )
  1939. {
  1940. nError = ERR_NOREMOTESERVER;
  1941. }
  1942. else
  1943. {
  1944. LlsFreeMemory( pConnectInfo );
  1945. nt = LlsProductAdd( hLls, pszFamilyDisplayName, pszDisplayName, TEXT( "" ) );
  1946. LlsClose( hLls );
  1947. if ( STATUS_SUCCESS != nt )
  1948. {
  1949. nError = ERR_NOREMOTESERVER;
  1950. }
  1951. else
  1952. {
  1953. nError = ERR_NONE;
  1954. }
  1955. }
  1956. return nError;
  1957. }