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.

866 lines
23 KiB

  1. /*************************************************************************
  2. *
  3. * Create.c
  4. *
  5. * Create Register APIs
  6. *
  7. * Copyright (c) 1998 Microsoft Corporation
  8. *
  9. * $Author:
  10. *
  11. *
  12. *************************************************************************/
  13. /*
  14. * Includes
  15. */
  16. #include <nt.h>
  17. #include <ntrtl.h>
  18. #include <nturtl.h>
  19. #include <stdio.h>
  20. #include <string.h>
  21. #include <windows.h>
  22. #include <ntddkbd.h>
  23. #include <ntddmou.h>
  24. #include <winstaw.h>
  25. #include <regapi.h>
  26. /*
  27. * Procedures defined
  28. */
  29. VOID CreateWinStaCreate( HKEY, PWINSTATIONCREATE );
  30. VOID CreateUserConfig( HKEY, PUSERCONFIG );
  31. VOID CreateConfig( HKEY, PWINSTATIONCONFIG );
  32. VOID CreateNetwork( BOOLEAN, HKEY, PNETWORKCONFIG );
  33. VOID CreateNasi( BOOLEAN, HKEY, PNASICONFIG );
  34. VOID CreateAsync( BOOLEAN, HKEY, PASYNCCONFIG );
  35. VOID CreateOemTd( BOOLEAN, HKEY, POEMTDCONFIG );
  36. VOID CreateFlow( BOOLEAN, HKEY, PFLOWCONTROLCONFIG );
  37. VOID CreateConnect( BOOLEAN, HKEY, PCONNECTCONFIG );
  38. VOID CreateCd( HKEY, PCDCONFIG );
  39. VOID CreateWd( HKEY, PWDCONFIG );
  40. VOID CreatePdConfig( BOOLEAN, HKEY, PPDCONFIG, ULONG );
  41. VOID CreatePdConfig2( BOOLEAN, HKEY, PPDCONFIG2, ULONG );
  42. VOID CreatePdConfig3( HKEY, PPDCONFIG3, ULONG );
  43. VOID CreatePdParams( BOOLEAN, HKEY, SDCLASS, PPDPARAMS );
  44. VOID SetWallPaperDisabled( HKEY, BOOLEAN );
  45. /*
  46. * procedures used
  47. */
  48. LONG SetNumValue( BOOLEAN, HKEY, LPWSTR, DWORD );
  49. LONG SetNumValueEx( BOOLEAN, HKEY, LPWSTR, DWORD, DWORD );
  50. LONG SetStringValue( BOOLEAN, HKEY, LPWSTR, LPWSTR );
  51. LONG SetStringValueEx( BOOLEAN, HKEY, LPWSTR, DWORD, LPWSTR );
  52. /*******************************************************************************
  53. *
  54. * CreateWinStaCreate
  55. *
  56. * Create WINSTATIONCREATE structure
  57. *
  58. * ENTRY:
  59. *
  60. * Handle (input)
  61. * registry handle
  62. * pCreate (input)
  63. * pointer to WINSTATIONCREATE structure
  64. *
  65. * EXIT:
  66. * nothing
  67. *
  68. ******************************************************************************/
  69. VOID
  70. CreateWinStaCreate( HKEY Handle,
  71. PWINSTATIONCREATE pCreate )
  72. {
  73. SetNumValue( TRUE, Handle,
  74. WIN_ENABLEWINSTATION, pCreate->fEnableWinStation );
  75. SetNumValue( TRUE, Handle,
  76. WIN_MAXINSTANCECOUNT, pCreate->MaxInstanceCount );
  77. }
  78. /*******************************************************************************
  79. *
  80. * CreateUserConfig
  81. *
  82. * Create USERCONFIG structure
  83. *
  84. * ENTRY:
  85. *
  86. * Handle (input)
  87. * registry handle
  88. * pUser (input)
  89. * pointer to USERCONFIG structure
  90. *
  91. * EXIT:
  92. * nothing
  93. *
  94. ******************************************************************************/
  95. VOID
  96. CreateUserConfig( HKEY Handle,
  97. PUSERCONFIG pUser )
  98. {
  99. UCHAR seed;
  100. UNICODE_STRING UnicodePassword;
  101. WCHAR encPassword[ PASSWORD_LENGTH + 2 ];
  102. SetNumValue( TRUE, Handle,
  103. WIN_INHERITAUTOLOGON, pUser->fInheritAutoLogon );
  104. SetNumValue( TRUE, Handle,
  105. WIN_INHERITRESETBROKEN, pUser->fInheritResetBroken );
  106. SetNumValue( TRUE, Handle,
  107. WIN_INHERITRECONNECTSAME, pUser->fInheritReconnectSame );
  108. SetNumValue( TRUE, Handle,
  109. WIN_INHERITINITIALPROGRAM, pUser->fInheritInitialProgram );
  110. SetNumValue( TRUE, Handle, WIN_INHERITCALLBACK, pUser->fInheritCallback );
  111. SetNumValue( TRUE, Handle,
  112. WIN_INHERITCALLBACKNUMBER, pUser->fInheritCallbackNumber );
  113. SetNumValue( TRUE, Handle, WIN_INHERITSHADOW, pUser->fInheritShadow );
  114. SetNumValue( TRUE, Handle,
  115. WIN_INHERITMAXSESSIONTIME, pUser->fInheritMaxSessionTime );
  116. SetNumValue( TRUE, Handle,
  117. WIN_INHERITMAXDISCONNECTIONTIME, pUser->fInheritMaxDisconnectionTime );
  118. SetNumValue( TRUE, Handle,
  119. WIN_INHERITMAXIDLETIME, pUser->fInheritMaxIdleTime );
  120. SetNumValue( TRUE, Handle,
  121. WIN_INHERITAUTOCLIENT, pUser->fInheritAutoClient );
  122. SetNumValue( TRUE, Handle,
  123. WIN_INHERITSECURITY, pUser->fInheritSecurity );
  124. SetNumValue( TRUE, Handle,
  125. WIN_PROMPTFORPASSWORD, pUser->fPromptForPassword );
  126. //NA 2/23/01
  127. SetNumValue( TRUE, Handle,
  128. WIN_INHERITCOLORDEPTH, pUser->fInheritColorDepth );
  129. SetNumValue( TRUE, Handle, WIN_RESETBROKEN, pUser->fResetBroken );
  130. SetNumValue( TRUE, Handle, WIN_RECONNECTSAME, pUser->fReconnectSame );
  131. SetNumValue( TRUE, Handle, WIN_LOGONDISABLED, pUser->fLogonDisabled );
  132. SetNumValue( TRUE, Handle, WIN_AUTOCLIENTDRIVES, pUser->fAutoClientDrives );
  133. SetNumValue( TRUE, Handle, WIN_AUTOCLIENTLPTS, pUser->fAutoClientLpts );
  134. SetNumValue( TRUE, Handle, WIN_FORCECLIENTLPTDEF, pUser->fForceClientLptDef );
  135. SetNumValue( TRUE, Handle, WIN_DISABLEENCRYPTION, pUser->fDisableEncryption );
  136. SetNumValue( TRUE, Handle, WIN_HOMEDIRECTORYMAPROOT, pUser->fHomeDirectoryMapRoot );
  137. SetNumValue( TRUE, Handle, WIN_USEDEFAULTGINA, pUser->fUseDefaultGina );
  138. SetNumValue( TRUE, Handle, WIN_DISABLECPM, pUser->fDisableCpm );
  139. SetNumValue( TRUE, Handle, WIN_DISABLECDM, pUser->fDisableCdm );
  140. SetNumValue( TRUE, Handle, WIN_DISABLECCM, pUser->fDisableCcm );
  141. SetNumValue( TRUE, Handle, WIN_DISABLELPT, pUser->fDisableLPT );
  142. SetNumValue( TRUE, Handle, WIN_DISABLECLIP, pUser->fDisableClip );
  143. SetNumValue( TRUE, Handle, WIN_DISABLEEXE, pUser->fDisableExe );
  144. SetNumValue( TRUE, Handle, WIN_DISABLECAM, pUser->fDisableCam );
  145. SetStringValue( TRUE, Handle, WIN_USERNAME, pUser->UserName );
  146. SetStringValue( TRUE, Handle, WIN_DOMAIN, pUser->Domain );
  147. // check for password if there is one then encrypt it
  148. if ( wcslen( pUser->Password ) ) {
  149. // generate unicode string
  150. RtlInitUnicodeString( &UnicodePassword, pUser->Password );
  151. // encrypt password in place
  152. seed = 0;
  153. RtlRunEncodeUnicodeString( &seed, &UnicodePassword );
  154. // pack seed and encrypted password
  155. encPassword[0] = seed;
  156. RtlMoveMemory( &encPassword[1], pUser->Password, sizeof(pUser->Password) );
  157. // store encrypted password
  158. SetStringValue( TRUE, Handle, WIN_PASSWORD, encPassword );
  159. }
  160. else {
  161. // store empty password
  162. SetStringValue( TRUE, Handle, WIN_PASSWORD, pUser->Password );
  163. }
  164. SetStringValue( TRUE, Handle, WIN_WORKDIRECTORY, pUser->WorkDirectory );
  165. SetStringValue( TRUE, Handle, WIN_INITIALPROGRAM, pUser->InitialProgram );
  166. SetStringValue( TRUE, Handle, WIN_CALLBACKNUMBER, pUser->CallbackNumber );
  167. SetNumValue( TRUE, Handle, WIN_CALLBACK, pUser->Callback );
  168. SetNumValue( TRUE, Handle, WIN_SHADOW, pUser->Shadow );
  169. SetNumValue( TRUE, Handle, WIN_MAXCONNECTIONTIME, pUser->MaxConnectionTime );
  170. SetNumValue( TRUE, Handle,
  171. WIN_MAXDISCONNECTIONTIME, pUser->MaxDisconnectionTime );
  172. SetNumValue( TRUE, Handle, WIN_MAXIDLETIME, pUser->MaxIdleTime );
  173. SetNumValue( TRUE, Handle, WIN_KEYBOARDLAYOUT, pUser->KeyboardLayout );
  174. SetNumValue( TRUE, Handle, WIN_MINENCRYPTIONLEVEL, pUser->MinEncryptionLevel );
  175. //NA 2/23/01
  176. SetNumValue( TRUE, Handle,
  177. POLICY_TS_COLOR_DEPTH, pUser->ColorDepth );
  178. if ( pUser->fWallPaperDisabled )
  179. SetWallPaperDisabled( Handle, TRUE );
  180. else
  181. SetWallPaperDisabled( Handle, FALSE );
  182. SetStringValue( TRUE, Handle, WIN_NWLOGONSERVER, pUser->NWLogonServer);
  183. SetStringValue( TRUE, Handle, WIN_WFPROFILEPATH, pUser->WFProfilePath);
  184. }
  185. /*******************************************************************************
  186. *
  187. * CreateConfig
  188. *
  189. * Create WINSTATIONCONFIG structure
  190. *
  191. * ENTRY:
  192. *
  193. * Handle (input)
  194. * registry handle
  195. * pConfig (input)
  196. * pointer to WINSTATIONCONFIG structure
  197. *
  198. * EXIT:
  199. * nothing
  200. *
  201. ******************************************************************************/
  202. VOID
  203. CreateConfig( HKEY Handle,
  204. PWINSTATIONCONFIG pConfig )
  205. {
  206. SetStringValue( TRUE, Handle, WIN_COMMENT, pConfig->Comment );
  207. CreateUserConfig( Handle, &pConfig->User );
  208. }
  209. /*******************************************************************************
  210. *
  211. * CreateNetwork
  212. *
  213. * Create NETWORKCONFIG structure
  214. *
  215. * ENTRY:
  216. *
  217. * bSetValue (input)
  218. * TRUE to set value; FALSE to delete from registry
  219. * Handle (input)
  220. * registry handle
  221. * pNetwork (input)
  222. * pointer to NETWORKCONFIG structure
  223. *
  224. * EXIT:
  225. * nothing
  226. *
  227. ******************************************************************************/
  228. VOID
  229. CreateNetwork( BOOLEAN bSetValue,
  230. HKEY Handle,
  231. PNETWORKCONFIG pNetwork )
  232. {
  233. SetNumValue( bSetValue, Handle, WIN_LANADAPTER, pNetwork->LanAdapter );
  234. }
  235. /*******************************************************************************
  236. *
  237. * CreateNasi
  238. *
  239. * Create NASICONFIG structure
  240. *
  241. * ENTRY:
  242. *
  243. * bSetValue (input)
  244. * TRUE to set value; FALSE to delete from registry
  245. * Handle (input)
  246. * registry handle
  247. * pNetwork (input)
  248. * pointer to NETWORKCONFIG structure
  249. *
  250. * EXIT:
  251. * nothing
  252. *
  253. ******************************************************************************/
  254. VOID
  255. CreateNasi( BOOLEAN bSetValue,
  256. HKEY Handle,
  257. PNASICONFIG pNasi )
  258. {
  259. UCHAR seed;
  260. UNICODE_STRING UnicodePassword;
  261. WCHAR encPassword[ NASIPASSWORD_LENGTH + 2 ];
  262. // check for password if there is one then encrypt it
  263. if ( wcslen( pNasi->PassWord ) ) {
  264. // generate unicode string
  265. RtlInitUnicodeString( &UnicodePassword, pNasi->PassWord );
  266. // encrypt password in place
  267. seed = 0;
  268. RtlRunEncodeUnicodeString( &seed, &UnicodePassword );
  269. // pack seed and encrypted password
  270. encPassword[0] = seed;
  271. RtlMoveMemory( &encPassword[1], pNasi->PassWord, sizeof(pNasi->PassWord) );
  272. // store encrypted password
  273. SetStringValue( TRUE, Handle, WIN_NASIPASSWORD, encPassword );
  274. }
  275. else {
  276. // store empty password
  277. SetStringValue( TRUE, Handle, WIN_NASIPASSWORD, pNasi->PassWord );
  278. }
  279. SetStringValue( bSetValue, Handle, WIN_NASISPECIFICNAME, pNasi->SpecificName );
  280. SetStringValue( bSetValue, Handle, WIN_NASIUSERNAME, pNasi->UserName );
  281. SetStringValue( bSetValue, Handle, WIN_NASISESSIONNAME, pNasi->SessionName );
  282. SetStringValue( bSetValue, Handle, WIN_NASIFILESERVER, pNasi->FileServer );
  283. SetNumValue( bSetValue, Handle, WIN_NASIGLOBALSESSION, pNasi->GlobalSession );
  284. }
  285. /*******************************************************************************
  286. *
  287. * CreateAsync
  288. *
  289. * Create ASYNCCONFIG structure
  290. *
  291. * ENTRY:
  292. *
  293. * bSetValue (input)
  294. * TRUE to set value; FALSE to delete from registry
  295. * Handle (input)
  296. * registry handle
  297. * pAsync (input)
  298. * pointer to ASYNCCONFIG structure
  299. *
  300. * EXIT:
  301. * nothing
  302. *
  303. ******************************************************************************/
  304. VOID
  305. CreateAsync( BOOLEAN bSetValue,
  306. HKEY Handle,
  307. PASYNCCONFIG pAsync )
  308. {
  309. SetStringValue( bSetValue, Handle, WIN_DEVICENAME, pAsync->DeviceName );
  310. SetStringValue( bSetValue, Handle, WIN_MODEMNAME, pAsync->ModemName );
  311. SetNumValue( bSetValue, Handle, WIN_BAUDRATE, pAsync->BaudRate );
  312. SetNumValue( bSetValue, Handle, WIN_PARITY, pAsync->Parity );
  313. SetNumValue( bSetValue, Handle, WIN_STOPBITS, pAsync->StopBits );
  314. SetNumValue( bSetValue, Handle, WIN_BYTESIZE, pAsync->ByteSize );
  315. SetNumValue( bSetValue, Handle, WIN_ENABLEDSRSENSITIVITY, pAsync->fEnableDsrSensitivity );
  316. SetNumValue( bSetValue, Handle, WIN_CONNECTIONDRIVER, pAsync->fConnectionDriver );
  317. CreateFlow( bSetValue, Handle, &pAsync->FlowControl );
  318. CreateConnect( bSetValue, Handle, &pAsync->Connect );
  319. }
  320. /*******************************************************************************
  321. *
  322. * CreateOemTd
  323. *
  324. * Create OEMTDCONFIG structure
  325. *
  326. * ENTRY:
  327. *
  328. * bSetValue (input)
  329. * TRUE to set value; FALSE to delete from registry
  330. * Handle (input)
  331. * registry handle
  332. * pOemTd (input)
  333. * pointer to OEMTDCONFIG structure
  334. *
  335. * EXIT:
  336. * nothing
  337. *
  338. ******************************************************************************/
  339. VOID
  340. CreateOemTd( BOOLEAN bSetValue,
  341. HKEY Handle,
  342. POEMTDCONFIG pOemTd )
  343. {
  344. SetNumValue( bSetValue, Handle, WIN_OEMTDADAPTER, pOemTd->Adapter );
  345. SetStringValue( bSetValue, Handle, WIN_OEMTDDEVICENAME, pOemTd->DeviceName );
  346. SetNumValue( bSetValue, Handle, WIN_OEMTDFLAGS, pOemTd->Flags );
  347. }
  348. /*******************************************************************************
  349. *
  350. * CreateFlow
  351. *
  352. * Create FLOWCONTROLCONFIG structure
  353. *
  354. * ENTRY:
  355. *
  356. * bSetValue (input)
  357. * TRUE to set value; FALSE to delete from registry
  358. * Handle (input)
  359. * registry handle
  360. * pFlow (input)
  361. * pointer to FLOWCONTROLCONFIG structure
  362. *
  363. * EXIT:
  364. * nothing
  365. *
  366. ******************************************************************************/
  367. VOID
  368. CreateFlow( BOOLEAN bSetValue,
  369. HKEY Handle,
  370. PFLOWCONTROLCONFIG pFlow )
  371. {
  372. SetNumValue( bSetValue, Handle, WIN_FLOWSOFTWARERX, pFlow->fEnableSoftwareRx );
  373. SetNumValue( bSetValue, Handle, WIN_FLOWSOFTWARETX, pFlow->fEnableSoftwareTx );
  374. SetNumValue( bSetValue, Handle, WIN_ENABLEDTR, pFlow->fEnableDTR );
  375. SetNumValue( bSetValue, Handle, WIN_ENABLERTS, pFlow->fEnableRTS );
  376. SetNumValue( bSetValue, Handle, WIN_XONCHAR, pFlow->XonChar );
  377. SetNumValue( bSetValue, Handle, WIN_XOFFCHAR, pFlow->XoffChar );
  378. SetNumValue( bSetValue, Handle, WIN_FLOWTYPE, pFlow->Type );
  379. SetNumValue( bSetValue, Handle, WIN_FLOWHARDWARERX, pFlow->HardwareReceive );
  380. SetNumValue( bSetValue, Handle, WIN_FLOWHARDWARETX, pFlow->HardwareTransmit );
  381. }
  382. /*******************************************************************************
  383. *
  384. * CreateConnect
  385. *
  386. * Create CONNECTCONFIG structure
  387. *
  388. * ENTRY:
  389. *
  390. * bSetValue (input)
  391. * TRUE to set value; FALSE to delete from registry
  392. * Handle (input)
  393. * registry handle
  394. * pConnect (input)
  395. * pointer to CONNECTCONFIG structure
  396. *
  397. * EXIT:
  398. * nothing
  399. *
  400. ******************************************************************************/
  401. VOID
  402. CreateConnect( BOOLEAN bSetValue,
  403. HKEY Handle,
  404. PCONNECTCONFIG pConnect )
  405. {
  406. SetNumValue( bSetValue, Handle, WIN_CONNECTTYPE, pConnect->Type );
  407. SetNumValue( bSetValue, Handle, WIN_ENABLEBREAKDISCONNECT, pConnect->fEnableBreakDisconnect );
  408. }
  409. /*******************************************************************************
  410. *
  411. * CreateCd
  412. *
  413. * Create CDCONFIG structure
  414. *
  415. * ENTRY:
  416. *
  417. * Handle (input)
  418. * registry handle
  419. * pCdConfig (input)
  420. * pointer to CDCONFIG structure
  421. *
  422. * EXIT:
  423. * nothing
  424. *
  425. ******************************************************************************/
  426. VOID
  427. CreateCd( HKEY Handle,
  428. PCDCONFIG pCdConfig )
  429. {
  430. SetNumValue( TRUE, Handle, WIN_CDCLASS, pCdConfig->CdClass );
  431. SetStringValue( TRUE, Handle, WIN_CDNAME, pCdConfig->CdName );
  432. SetStringValue( TRUE, Handle, WIN_CDDLL, pCdConfig->CdDLL );
  433. SetNumValue( TRUE, Handle, WIN_CDFLAG, pCdConfig->CdFlag );
  434. }
  435. /*******************************************************************************
  436. *
  437. * CreateWd
  438. *
  439. * Create WDCONFIG structure
  440. *
  441. * ENTRY:
  442. *
  443. * Handle (input)
  444. * registry handle
  445. * pWd (input)
  446. * pointer to WDCONFIG structure
  447. *
  448. * EXIT:
  449. * nothing
  450. *
  451. ******************************************************************************/
  452. VOID
  453. CreateWd( HKEY Handle,
  454. PWDCONFIG pWd )
  455. {
  456. SetStringValue( TRUE, Handle, WIN_WDNAME, pWd->WdName );
  457. SetStringValue( TRUE, Handle, WIN_WDDLL, pWd->WdDLL );
  458. SetStringValue( TRUE, Handle, WIN_WSXDLL, pWd->WsxDLL );
  459. SetNumValue( TRUE, Handle, WIN_WDFLAG, pWd->WdFlag );
  460. SetNumValue( TRUE, Handle, WIN_INPUTBUFFERLENGTH, pWd->WdInputBufferLength );
  461. SetStringValue( TRUE, Handle, WIN_CFGDLL, pWd->CfgDLL );
  462. SetStringValue( TRUE, Handle, WIN_WDPREFIX, pWd->WdPrefix );
  463. }
  464. /*******************************************************************************
  465. *
  466. * CreatePdConfig
  467. *
  468. * Create PDCONFIG structure
  469. *
  470. * ENTRY:
  471. *
  472. * bCreate (input)
  473. * TRUE for create; FALSE for update.
  474. * Handle (input)
  475. * registry handle
  476. * pConfig (input)
  477. * pointer to array of PDCONFIG structures
  478. * Count (input)
  479. * number of elements in PDCONFIG array
  480. *
  481. * EXIT:
  482. * nothing
  483. *
  484. ******************************************************************************/
  485. VOID
  486. CreatePdConfig( BOOLEAN bCreate,
  487. HKEY Handle,
  488. PPDCONFIG pConfig,
  489. ULONG Count )
  490. {
  491. ULONG i;
  492. for ( i=0; i<Count; i++ ) {
  493. if ( !bCreate || (pConfig[i].Create.SdClass != SdNone) ) {
  494. CreatePdConfig2( bCreate, Handle, &pConfig[i].Create, i );
  495. CreatePdParams( bCreate, Handle,
  496. pConfig[i].Create.SdClass,
  497. &pConfig[i].Params );
  498. }
  499. }
  500. }
  501. /*******************************************************************************
  502. *
  503. * CreatePdConfig2
  504. *
  505. * Create PDCONFIG2 structure
  506. *
  507. * ENTRY:
  508. *
  509. * bCreate (input)
  510. * TRUE for create; FALSE for update.
  511. * Handle (input)
  512. * registry handle
  513. * pPd (input)
  514. * pointer to PDCONFIG2 structure
  515. * Index (input)
  516. * Index (array index)
  517. *
  518. * EXIT:
  519. * nothing
  520. *
  521. ******************************************************************************/
  522. VOID
  523. CreatePdConfig2( BOOLEAN bCreate,
  524. HKEY Handle,
  525. PPDCONFIG2 pPd2,
  526. ULONG Index )
  527. {
  528. BOOLEAN bSetValue = bCreate ?
  529. TRUE :
  530. ((pPd2->SdClass == SdNone) ?
  531. FALSE : TRUE);
  532. SetStringValueEx( bSetValue, Handle, WIN_PDNAME, Index, pPd2->PdName );
  533. SetNumValueEx( bSetValue, Handle, WIN_PDCLASS, Index, pPd2->SdClass );
  534. SetStringValueEx( bSetValue, Handle, WIN_PDDLL, Index, pPd2->PdDLL );
  535. SetNumValueEx( bSetValue, Handle, WIN_PDFLAG, Index, pPd2->PdFlag );
  536. if ( Index == 0 ) {
  537. SetNumValue( bSetValue, Handle, WIN_OUTBUFLENGTH, pPd2->OutBufLength );
  538. SetNumValue( bSetValue, Handle, WIN_OUTBUFCOUNT, pPd2->OutBufCount );
  539. SetNumValue( bSetValue, Handle, WIN_OUTBUFDELAY, pPd2->OutBufDelay );
  540. SetNumValue( bSetValue, Handle, WIN_INTERACTIVEDELAY, pPd2->InteractiveDelay );
  541. SetNumValue( bSetValue, Handle, WIN_PORTNUMBER, pPd2->PortNumber );
  542. SetNumValue( bSetValue, Handle, WIN_KEEPALIVETIMEOUT, pPd2->KeepAliveTimeout );
  543. }
  544. }
  545. /*******************************************************************************
  546. *
  547. * CreatePdConfig3
  548. *
  549. * Create PDCONFIG3 structure
  550. *
  551. * ENTRY:
  552. *
  553. * Handle (input)
  554. * registry handle
  555. * pPd (input)
  556. * pointer to PDCONFIG3 structure
  557. * Index (input)
  558. * Index (array index)
  559. *
  560. * EXIT:
  561. * nothing
  562. *
  563. ******************************************************************************/
  564. VOID
  565. CreatePdConfig3( HKEY Handle,
  566. PPDCONFIG3 pPd3,
  567. ULONG Index )
  568. {
  569. CreatePdConfig2( TRUE, Handle, &pPd3->Data, Index );
  570. SetStringValue( TRUE, Handle, WIN_SERVICENAME,
  571. pPd3->ServiceName );
  572. SetStringValue( TRUE, Handle, WIN_CONFIGDLL,
  573. pPd3->ConfigDLL );
  574. }
  575. /*******************************************************************************
  576. *
  577. * CreatePdParams
  578. *
  579. * create PDPARAMS structure
  580. *
  581. * ENTRY:
  582. *
  583. * bCreate (input)
  584. * TRUE for create; FALSE for update.
  585. * Handle (input)
  586. * registry handle
  587. * SdClass (input)
  588. * type of PD
  589. * pParams (input)
  590. * pointer to PDPARAMS structure
  591. *
  592. * EXIT:
  593. * nothing
  594. *
  595. ******************************************************************************/
  596. VOID
  597. CreatePdParams( BOOLEAN bCreate,
  598. HKEY Handle,
  599. SDCLASS SdClass,
  600. PPDPARAMS pParams )
  601. {
  602. BOOLEAN bSetValue = bCreate ?
  603. TRUE :
  604. ((SdClass == SdNone) ?
  605. FALSE : TRUE);
  606. switch ( SdClass ) {
  607. case SdNetwork :
  608. CreateNetwork( bSetValue, Handle, &pParams->Network );
  609. break;
  610. case SdNasi :
  611. CreateNasi( bSetValue, Handle, &pParams->Nasi );
  612. break;
  613. case SdAsync :
  614. CreateAsync( bSetValue, Handle, &pParams->Async );
  615. break;
  616. case SdOemTransport :
  617. CreateOemTd( bSetValue, Handle, &pParams->OemTd );
  618. break;
  619. }
  620. }
  621. #define CONTROL_PANEL L"Control Panel"
  622. #define DESKTOP L"Desktop"
  623. #define WALLPAPER L"Wallpaper"
  624. #define NONE L"(None)"
  625. /*******************************************************************************
  626. *
  627. * SetWallPaperDisabled
  628. *
  629. * Disable desktop wallpaper
  630. *
  631. * ENTRY:
  632. *
  633. * Handle (input)
  634. * registry handle
  635. * DisableWallPaper (input)
  636. * flag to disable wall paper
  637. *
  638. * EXIT:
  639. * nothing
  640. *
  641. ******************************************************************************/
  642. void
  643. SetWallPaperDisabled( HKEY Handle, BOOLEAN bDisableWallPaper ) {
  644. HKEY Handle1;
  645. HKEY Handle2;
  646. HKEY Handle3;
  647. DWORD Disp;
  648. if ( bDisableWallPaper ) {
  649. if ( RegCreateKeyEx( Handle, WIN_USEROVERRIDE, 0, NULL,
  650. REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  651. NULL, &Handle1, &Disp ) != ERROR_SUCCESS ) {
  652. goto error;
  653. }
  654. if ( RegCreateKeyEx( Handle1, CONTROL_PANEL, 0, NULL,
  655. REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  656. NULL, &Handle2, &Disp ) != ERROR_SUCCESS ) {
  657. RegCloseKey( Handle1 );
  658. goto error;
  659. }
  660. RegCloseKey( Handle1 );
  661. if ( RegCreateKeyEx( Handle2, DESKTOP, 0, NULL,
  662. REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
  663. NULL, &Handle3, &Disp ) != ERROR_SUCCESS ) {
  664. RegCloseKey( Handle2 );
  665. goto error;
  666. }
  667. RegCloseKey( Handle2 );
  668. (void)RegSetValueEx( Handle3, WALLPAPER, 0, REG_SZ,
  669. (BYTE *)NONE, (wcslen(NONE) + 1 ) << 1);
  670. RegCloseKey( Handle3 );
  671. }
  672. else {
  673. if ( RegOpenKeyEx( Handle, WIN_USEROVERRIDE, 0, KEY_ALL_ACCESS,
  674. &Handle1 ) != ERROR_SUCCESS ) {
  675. goto error;
  676. }
  677. if ( RegOpenKeyEx( Handle1, CONTROL_PANEL, 0, KEY_ALL_ACCESS,
  678. &Handle2 ) != ERROR_SUCCESS ) {
  679. RegCloseKey( Handle1 );
  680. goto error;
  681. }
  682. if ( RegDeleteKey( Handle2, DESKTOP ) != ERROR_SUCCESS ) {
  683. RegCloseKey( Handle2 );
  684. RegCloseKey( Handle1 );
  685. goto error;
  686. }
  687. RegCloseKey( Handle2 );
  688. if ( RegDeleteKey( Handle1, CONTROL_PANEL ) != ERROR_SUCCESS ) {
  689. RegCloseKey( Handle1 );
  690. goto error;
  691. }
  692. RegCloseKey( Handle1 );
  693. if ( RegDeleteKey( Handle, WIN_USEROVERRIDE ) != ERROR_SUCCESS ) {
  694. goto error;
  695. }
  696. }
  697. error:
  698. return;
  699. }