1
0

Defaults.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #include "main.h"
  2. #include "Defaults.h"
  3. #include <shlobj.h>
  4. wchar_t defaultDownloadPath[MAX_PATH] = {0};
  5. bool needToMakePodcastsView=true;
  6. static BOOL UtilGetSpecialFolderPath( HWND hwnd, wchar_t *path, int folder )
  7. {
  8. ITEMIDLIST *pidl; // Shell Item ID List ptr
  9. IMalloc *imalloc; // Shell IMalloc interface ptr
  10. BOOL result; // Return value
  11. if ( SHGetSpecialFolderLocation( hwnd, folder, &pidl ) != NOERROR )
  12. return FALSE;
  13. result = SHGetPathFromIDList( pidl, path );
  14. if ( SHGetMalloc( &imalloc ) == NOERROR )
  15. {
  16. imalloc->Free( pidl );
  17. imalloc->Release();
  18. }
  19. return result;
  20. }
  21. static void BuildDefaultDownloadPath( HWND hwnd )
  22. {
  23. wchar_t defaultPath[ MAX_PATH ] = L"";
  24. if ( !UtilGetSpecialFolderPath( hwnd, defaultPath, CSIDL_MYMUSIC ) )
  25. UtilGetSpecialFolderPath( hwnd, defaultPath, CSIDL_PERSONAL );
  26. lstrcpyn( defaultDownloadPath, defaultPath, MAX_PATH );
  27. }
  28. /*
  29. Requires an HWND because some of the shell functions require one. Theoretically it could be NULL
  30. */
  31. void BuildDefaults( HWND hwnd )
  32. {
  33. BuildDefaultDownloadPath( hwnd );
  34. }