winecfg.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*
  2. * WineCfg configuration management
  3. *
  4. * Copyright 2002 Jaco Greeff
  5. * Copyright 2003 Dimitrie O. Paun
  6. * Copyright 2004 Mike Hearn
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  21. *
  22. */
  23. #ifndef WINE_CFG_H
  24. #define WINE_CFG_H
  25. #include <stdarg.h>
  26. #include "windef.h"
  27. #include "winbase.h"
  28. #include "wingdi.h"
  29. #include "winuser.h"
  30. #include "winnls.h"
  31. #include "commctrl.h"
  32. #define IS_OPTION_TRUE(ch) \
  33. ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
  34. #define IS_OPTION_FALSE(ch) \
  35. ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
  36. extern WCHAR* current_app; /* NULL means editing global settings */
  37. /* Use get_reg_key and set_reg_key to alter registry settings. The changes made through
  38. set_reg_key won't be committed to the registry until process_all_settings is called,
  39. however get_reg_key will still return accurate information.
  40. The root HKEY has to be non-ambiguous. So only the registry roots (HKCU, HKLM, ...) or
  41. the global config_key are allowed here.
  42. You are expected to HeapFree the result of get_reg_key. The parameters to set_reg_key will
  43. be copied, so free them too when necessary.
  44. */
  45. void set_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value);
  46. void set_reg_key_dword(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value);
  47. WCHAR *get_reg_key(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def);
  48. BOOL reg_key_exists(HKEY root, const WCHAR *path, const WCHAR *name);
  49. void apply(void);
  50. WCHAR **enumerate_values(HKEY root, const WCHAR *path);
  51. /* Load a string from the resources. Allocated with HeapAlloc (GetProcessHeap()) */
  52. WCHAR* load_string (UINT id);
  53. /* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
  54. the user is editing the global settings.
  55. no explicit free is needed of the string returned by this function
  56. */
  57. WCHAR *keypath(const WCHAR *section);
  58. BOOL initialize(HINSTANCE hInstance);
  59. extern HKEY config_key;
  60. /* hack for the property sheet control */
  61. void set_window_title(HWND dialog);
  62. /* Window procedures */
  63. INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  64. INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  65. INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  66. INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  67. INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  68. INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  69. INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  70. INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  71. /* Windows version management */
  72. BOOL set_winver_from_string(const WCHAR *version);
  73. void print_current_winver(void);
  74. void print_windows_versions(void);
  75. /* Drive management */
  76. BOOL load_drives(void);
  77. struct drive
  78. {
  79. char letter;
  80. char *unixpath;
  81. char *device;
  82. WCHAR *label;
  83. DWORD serial;
  84. DWORD type; /* one of the DRIVE_ constants from winbase.h */
  85. BOOL in_use;
  86. BOOL modified;
  87. };
  88. #define DRIVE_MASK_BIT(B) (1 << (toupper(B) - 'A'))
  89. ULONG drive_available_mask(char letter);
  90. BOOL add_drive(char letter, const char *targetpath, const char *device,
  91. const WCHAR *label, DWORD serial, DWORD type);
  92. void delete_drive(struct drive *pDrive);
  93. void apply_drive_changes(void);
  94. void query_shell_folder( const WCHAR *path, char *dest, unsigned int len );
  95. void set_shell_folder( const WCHAR *path, const char *dest );
  96. BOOL browse_for_unix_folder(HWND dialog, WCHAR *pszPath);
  97. extern struct drive drives[26]; /* one for each drive letter */
  98. /* Some basic utilities to make win32 suck less */
  99. #define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
  100. #define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
  101. void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
  102. /* returns a string in the win32 heap */
  103. static inline char *strdupA(const char *s)
  104. {
  105. char *r = HeapAlloc(GetProcessHeap(), 0, strlen(s)+1);
  106. return strcpy(r, s);
  107. }
  108. static inline WCHAR *strdupW(const WCHAR *s)
  109. {
  110. WCHAR *r = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(s)+1)*sizeof(WCHAR));
  111. return lstrcpyW(r, s);
  112. }
  113. /* create a unicode string from a string in Unix locale */
  114. static inline WCHAR *strdupU2W(const char *unix_str)
  115. {
  116. WCHAR *unicode_str;
  117. int lenW;
  118. lenW = MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, NULL, 0);
  119. unicode_str = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
  120. if (unicode_str)
  121. MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, unicode_str, lenW);
  122. return unicode_str;
  123. }
  124. static inline WCHAR *get_text(HWND dialog, WORD id)
  125. {
  126. HWND item = GetDlgItem(dialog, id);
  127. int len = GetWindowTextLengthW(item) + 1;
  128. WCHAR *result = len ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL;
  129. if (!result) return NULL;
  130. if(GetWindowTextW(item, result, len) == 0) {
  131. HeapFree (GetProcessHeap(), 0, result);
  132. return NULL;
  133. }
  134. return result;
  135. }
  136. static inline void set_text(HWND dialog, WORD id, const char *text)
  137. {
  138. SetWindowTextA(GetDlgItem(dialog, id), text);
  139. }
  140. static inline void set_textW(HWND dialog, WORD id, const WCHAR *text)
  141. {
  142. SetWindowTextW(GetDlgItem(dialog, id), text);
  143. }
  144. #define WINE_KEY_ROOT L"Software\\Wine"
  145. #define MAXBUFLEN 256
  146. extern HMENU hPopupMenus;
  147. #endif