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.

179 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // File: desktops.c
  4. //
  5. // Contents:
  6. //
  7. // Classes:
  8. //
  9. // Functions:
  10. //
  11. // History: 6-02-96 RichardW Created
  12. //
  13. //----------------------------------------------------------------------------
  14. #include "testgina.h"
  15. BOOL
  16. AddDesktop(
  17. DWORD Index,
  18. PWSTR Name)
  19. {
  20. PWLX_DESKTOP pDesk;
  21. pDesk = LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT,
  22. sizeof( WLX_DESKTOP ) +
  23. ( wcslen(Name) + 1 ) * sizeof(WCHAR) );
  24. if ( pDesk )
  25. {
  26. pDesk->Size = sizeof( WLX_DESKTOP );
  27. pDesk->Flags = WLX_DESKTOP_NAME;
  28. pDesk->pszDesktopName = (PWSTR) ( pDesk + 1 );
  29. wcscpy( pDesk->pszDesktopName, Name );
  30. Desktops[ Index ] = pDesk;
  31. return( TRUE );
  32. }
  33. return( FALSE );
  34. }
  35. PWLX_DESKTOP
  36. CopyDesktop(
  37. PWLX_DESKTOP pOrig)
  38. {
  39. PWLX_DESKTOP pDesk;
  40. if ( pOrig->pszDesktopName )
  41. {
  42. pDesk = LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT,
  43. sizeof( WLX_DESKTOP ) +
  44. ( wcslen( pOrig->pszDesktopName ) + 1 ) * 2 );
  45. }
  46. else
  47. {
  48. pDesk = LocalAlloc( LMEM_FIXED | LMEM_ZEROINIT,
  49. sizeof( WLX_DESKTOP ) );
  50. }
  51. if ( pDesk )
  52. {
  53. *pDesk = *pOrig;
  54. if ( pOrig->pszDesktopName )
  55. {
  56. pDesk->pszDesktopName = (PWSTR) (pDesk + 1);
  57. wcscpy( pDesk->pszDesktopName, pOrig->pszDesktopName );
  58. }
  59. }
  60. return( pDesk );
  61. }
  62. BOOL
  63. InitializeDesktops( VOID )
  64. {
  65. ZeroMemory( Desktops, sizeof( PWLX_DESKTOP ) * MAX_DESKTOPS );
  66. AddDesktop( WINLOGON_DESKTOP, TEXT("Winlogon") );
  67. AddDesktop( DEFAULT_DESKTOP, TEXT("Default") );
  68. AddDesktop( SCREENSAVER_DESKTOP, TEXT("Screen-Saver") );
  69. CurrentDesktop = WINLOGON_DESKTOP;
  70. OtherDesktop = WINLOGON_DESKTOP;
  71. DesktopCount = 3;
  72. return( TRUE );
  73. }
  74. int
  75. WINAPI
  76. WlxGetSourceDesktop(
  77. HANDLE hWlx,
  78. PWLX_DESKTOP * ppDesktop)
  79. {
  80. if ( !VerifyHandle( hWlx ) )
  81. {
  82. TestGinaError( GINAERR_INVALID_HANDLE, TEXT("WlxGetSourceDesktop"));
  83. }
  84. *ppDesktop = CopyDesktop( Desktops[ OtherDesktop ] );
  85. return( 0 );
  86. }
  87. int
  88. WINAPI
  89. WlxSetReturnDesktop(
  90. HANDLE hWlx,
  91. PWLX_DESKTOP pDesktop)
  92. {
  93. DWORD i;
  94. if ( !VerifyHandle( hWlx ) )
  95. {
  96. TestGinaError( GINAERR_INVALID_HANDLE, TEXT("WlxSetReturnDesktop"));
  97. }
  98. for ( i = 0 ; i < DesktopCount ; i++ )
  99. {
  100. if ( _wcsicmp( pDesktop->pszDesktopName, Desktops[ i ]->pszDesktopName ) == 0 )
  101. {
  102. break;
  103. }
  104. }
  105. if ( i == WINLOGON_DESKTOP )
  106. {
  107. TestGinaError( GINAERR_INVALID_HANDLE, TEXT("WlxSetReturnDesktop"));
  108. }
  109. if ( i == DesktopCount )
  110. {
  111. AddDesktop( DesktopCount, pDesktop->pszDesktopName );
  112. DesktopCount ++ ;
  113. }
  114. OtherDesktop = i;
  115. return( 0 );
  116. }
  117. int
  118. WINAPI
  119. WlxCreateUserDesktop(
  120. HANDLE hWlx,
  121. HANDLE hToken,
  122. DWORD Flags,
  123. PWSTR pszDesktopName,
  124. PWLX_DESKTOP * ppDesktop )
  125. {
  126. if ( !VerifyHandle( hWlx ) )
  127. {
  128. TestGinaError( GINAERR_INVALID_HANDLE, TEXT("WlxCreateUserDesktop"));
  129. }
  130. AddDesktop( DesktopCount, pszDesktopName );
  131. *ppDesktop = CopyDesktop( Desktops[ DesktopCount ] );
  132. DesktopCount++;
  133. return( 0 );
  134. }
  135. BOOL
  136. WINAPI
  137. WlxCloseUserDesktop(
  138. HANDLE hWlx,
  139. PWLX_DESKTOP Desktop,
  140. HANDLE Token
  141. )
  142. {
  143. return TRUE ;
  144. }