msvcrt: Add explicit 32- and 64-bit versions of the utime functions.
[wine] / programs / winecfg / winecfg.h
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
24 #ifndef WINE_CFG_H
25 #define WINE_CFG_H
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winnls.h"
34 #include "commctrl.h"
35
36 #define IS_OPTION_TRUE(ch) \
37     ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
38 #define IS_OPTION_FALSE(ch) \
39     ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
40
41 extern WCHAR* current_app; /* NULL means editing global settings  */
42
43 /* Use get_reg_key and set_reg_key to alter registry settings. The changes made through
44    set_reg_key won't be committed to the registry until process_all_settings is called,
45    however get_reg_key will still return accurate information.
46
47    The root HKEY has to be non-ambiguous. So only the registry roots (HKCU, HKLM, ...) or
48    the global config_key are allowed here.
49    
50    You are expected to HeapFree the result of get_reg_key. The parameters to set_reg_key will
51    be copied, so free them too when necessary.
52  */
53
54 void set_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value);
55 void set_reg_key_dwordW(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value);
56 WCHAR *get_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def);
57
58 void set_reg_key(HKEY root, const char *path, const char *name, const char *value);
59 void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value);
60 char *get_reg_key(HKEY root, const char *path, const char *name, const char *def);
61 BOOL reg_key_exists(HKEY root, const char *path, const char *name);
62 void apply(void);
63 char **enumerate_values(HKEY root, char *path);
64
65 /* Load a string from the resources. Allocated with HeapAlloc (GetProcessHeap()) */
66 WCHAR* load_string (UINT id);
67
68 /* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
69    the user is editing the global settings.
70  
71    no explicit free is needed of the string returned by this function
72  */
73 char *keypath(const char *section);
74 WCHAR *keypathW(const WCHAR *section);
75
76 int initialize(HINSTANCE hInstance);
77 extern HKEY config_key;
78
79 /* hack for the property sheet control  */
80 void set_window_title(HWND dialog);
81
82 /* Window procedures */
83 INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
84 INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
85 INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
86 INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
87 INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
88 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
89 INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
90
91 /* Drive management  */
92 BOOL load_drives(void);
93 int autodetect_drives(void);
94
95 struct drive
96 {
97     char letter;
98     char *unixpath;
99     char *device;
100     WCHAR *label;
101     DWORD serial;
102     DWORD type; /* one of the DRIVE_ constants from winbase.h  */
103
104     BOOL in_use;
105     BOOL modified;
106 };
107
108 #define DRIVE_MASK_BIT(B) (1 << (toupper(B) - 'A'))
109
110 ULONG drive_available_mask(char letter);
111 BOOL add_drive(char letter, const char *targetpath, const char *device,
112                const WCHAR *label, DWORD serial, DWORD type);
113 void delete_drive(struct drive *pDrive);
114 void apply_drive_changes(void);
115 BOOL browse_for_unix_folder(HWND dialog, WCHAR *pszPath);
116 extern struct drive drives[26]; /* one for each drive letter */
117
118 BOOL gui_mode;
119
120 /* Some basic utilities to make win32 suck less */
121 #define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
122 #define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
123 void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
124
125 /* returns a string in the win32 heap  */
126 static inline char *strdupA(const char *s)
127 {
128     char *r = HeapAlloc(GetProcessHeap(), 0, strlen(s)+1);
129     return strcpy(r, s);
130 }
131
132 static inline WCHAR *strdupW(const WCHAR *s)
133 {
134     WCHAR *r = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(s)+1)*sizeof(WCHAR));
135     return lstrcpyW(r, s);
136 }
137
138 /* create a unicode string from a string in Unix locale */
139 static inline WCHAR *strdupU2W(const char *unix_str)
140 {
141     WCHAR *unicode_str;
142     int lenW;
143
144     lenW = MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, NULL, 0);
145     unicode_str = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
146     if (unicode_str)
147         MultiByteToWideChar(CP_UNIXCP, 0, unix_str, -1, unicode_str, lenW);
148     return unicode_str;
149 }
150
151 static inline char *get_text(HWND dialog, WORD id)
152 {
153     HWND item = GetDlgItem(dialog, id);
154     int len = GetWindowTextLength(item) + 1;
155     char *result = len ? HeapAlloc(GetProcessHeap(), 0, len) : NULL;
156     if (!result || GetWindowText(item, result, len) == 0) return NULL;
157     return result;
158 }
159
160 static inline WCHAR *get_textW(HWND dialog, WORD id)
161 {
162     HWND item = GetDlgItem(dialog, id);
163     int len = GetWindowTextLengthW(item) + 1;
164     WCHAR *result = len ? HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)) : NULL;
165     if (!result || GetWindowTextW(item, result, len) == 0) return NULL;
166     return result;
167 }
168
169 static inline void set_text(HWND dialog, WORD id, const char *text)
170 {
171     SetWindowText(GetDlgItem(dialog, id), text);
172 }
173
174 static inline void set_textW(HWND dialog, WORD id, const WCHAR *text)
175 {
176     SetWindowTextW(GetDlgItem(dialog, id), text);
177 }
178
179 #define WINE_KEY_ROOT "Software\\Wine"
180 #define MAXBUFLEN 256
181
182 extern HMENU     hPopupMenus;
183
184 #endif