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.

46 lines
1005 B

  1. // this file should not be needed anymore as we now compile for versions of NT > 500
  2. #include "shellprv.h"
  3. #include <appmgmt.h>
  4. #include <userenv.h>
  5. #include <devguid.h>
  6. #include <dbt.h>
  7. LPTSTR GetEnvBlock(HANDLE hUserToken)
  8. {
  9. LPTSTR pszRet = NULL;
  10. if (hUserToken)
  11. CreateEnvironmentBlock(&pszRet, hUserToken, TRUE);
  12. else
  13. pszRet = (LPTSTR) GetEnvironmentStrings();
  14. return pszRet;
  15. }
  16. void FreeEnvBlock(HANDLE hUserToken, LPTSTR pszEnv)
  17. {
  18. if (pszEnv)
  19. {
  20. if (hUserToken)
  21. DestroyEnvironmentBlock(pszEnv);
  22. else
  23. FreeEnvironmentStrings(pszEnv);
  24. }
  25. }
  26. STDAPI_(BOOL) GetAllUsersDirectory(LPTSTR pszPath)
  27. {
  28. DWORD cbData = MAX_PATH;
  29. BOOL fRet = FALSE;
  30. // This is delay loaded. It can fail.
  31. __try
  32. {
  33. fRet = GetAllUsersProfileDirectoryW(pszPath, &cbData);
  34. }
  35. __except(EXCEPTION_EXECUTE_HANDLER)
  36. {
  37. pszPath[0] = 0;
  38. }
  39. return fRet;
  40. }