platform-windows.cpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /******************************************************************************
  2. Copyright (C) 2013 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #include <sstream>
  15. #include "platform.hpp"
  16. using namespace std;
  17. #include <util/platform.h>
  18. #define WIN32_LEAN_AND_MEAN
  19. #include <windows.h>
  20. #include <shellapi.h>
  21. #include <shlobj.h>
  22. static inline bool check_path(const char* data, const char *path,
  23. string &output)
  24. {
  25. ostringstream str;
  26. str << path << data;
  27. output = str.str();
  28. printf("Attempted path: %s\n", output.c_str());
  29. return os_file_exists(output.c_str());
  30. }
  31. bool GetDataFilePath(const char *data, string &output)
  32. {
  33. if (check_path(data, "data/obs-studio/", output))
  34. return true;
  35. return check_path(data, OBS_DATA_PATH "/obs-studio/", output);
  36. }
  37. static BOOL CALLBACK OBSMonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor,
  38. LPRECT rect, LPARAM param)
  39. {
  40. vector<MonitorInfo> &monitors = *(vector<MonitorInfo> *)param;
  41. monitors.emplace_back(
  42. rect->left,
  43. rect->top,
  44. rect->right - rect->left,
  45. rect->bottom - rect->top);
  46. return true;
  47. }
  48. void GetMonitors(vector<MonitorInfo> &monitors)
  49. {
  50. monitors.clear();
  51. EnumDisplayMonitors(NULL, NULL, OBSMonitorEnumProc, (LPARAM)&monitors);
  52. }
  53. bool InitApplicationBundle()
  54. {
  55. return true;
  56. }
  57. string GetDefaultVideoSavePath()
  58. {
  59. wchar_t path_utf16[MAX_PATH];
  60. char path_utf8[MAX_PATH] = {};
  61. SHGetFolderPathW(NULL, CSIDL_MYVIDEO, NULL, SHGFP_TYPE_CURRENT,
  62. path_utf16);
  63. os_wcs_to_utf8(path_utf16, wcslen(path_utf16), path_utf8, MAX_PATH);
  64. return string(path_utf8);
  65. }