winecfg.h 5.36 KB
Newer Older
1 2 3 4 5
/*
 * WineCfg configuration management
 *
 * Copyright 2002 Jaco Greeff
 * Copyright 2003 Dimitrie O. Paun
6
 * Copyright 2004 Mike Hearn
7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * 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 25 26
 *
 */

#ifndef WINE_CFG_H
#define WINE_CFG_H

27 28 29 30 31 32 33
#include <stdarg.h>

#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winnls.h"
34 35
#include "properties.h"

36 37 38 39 40
#define IS_OPTION_TRUE(ch) \
    ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
#define IS_OPTION_FALSE(ch) \
    ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')

41
extern WCHAR* current_app; /* NULL means editing global settings  */
42

43 44 45
/* Use get_reg_key and set_reg_key to alter registry settings. The changes made through
   set_reg_key won't be committed to the registry until process_all_settings is called,
   however get_reg_key will still return accurate information.
46

47 48 49
   The root HKEY has to be non-ambiguous. So only the registry roots (HKCU, HKLM, ...) or
   the global config_key are allowed here.
   
50 51
   You are expected to HeapFree the result of get_reg_key. The parameters to set_reg_key will
   be copied, so free them too when necessary.
52
 */
Mike Hearn's avatar
Mike Hearn committed
53

54 55 56 57 58
void set_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *value);
void set_reg_key_dwordW(HKEY root, const WCHAR *path, const WCHAR *name, DWORD value);
WCHAR *get_reg_keyW(HKEY root, const WCHAR *path, const WCHAR *name, const WCHAR *def);
WCHAR **enumerate_valuesW(HKEY root, WCHAR *path);

59
void set_reg_key(HKEY root, const char *path, const char *name, const char *value);
60
void set_reg_key_dword(HKEY root, const char *path, const char *name, DWORD value);
61 62
char *get_reg_key(HKEY root, const char *path, const char *name, const char *def);
BOOL reg_key_exists(HKEY root, const char *path, const char *name);
63
void apply(void);
64
char **enumerate_values(HKEY root, char *path);
65

66 67 68
/* Load a string from the resources. Allocated with HeapAlloc (GetProcessHeap()) */
WCHAR* load_string (UINT id);

69
/* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
Mike Hearn's avatar
Mike Hearn committed
70 71 72
   the user is editing the global settings.
 
   no explicit free is needed of the string returned by this function
73
 */
74
char *keypath(const char *section); 
75

76
int initialize(HINSTANCE hInstance);
77
extern HKEY config_key;
78

Mike Hearn's avatar
Mike Hearn committed
79
/* hack for the property sheet control  */
80
void set_window_title(HWND dialog);
81

Mike Hearn's avatar
Mike Hearn committed
82
/* Window procedures */
83
INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
84 85
INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
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

Mike Hearn's avatar
Mike Hearn committed
91
/* Drive management  */
92 93
void load_drives(void);
int autodetect_drives(void);
Mike Hearn's avatar
Mike Hearn committed
94 95 96 97 98 99 100 101 102 103 104 105

struct drive
{
    char letter;
    char *unixpath;
    char *label;
    char *serial;
    DWORD type; /* one of the DRIVE_ constants from winbase.h  */

    BOOL in_use;
};

106
#define DRIVE_MASK_BIT(B) (1 << (toupper(B) - 'A'))
Mike Hearn's avatar
Mike Hearn committed
107 108

long drive_available_mask(char letter);
109
BOOL add_drive(const char letter, const char *targetpath, const char *label, const char *serial, unsigned int type);
Mike Hearn's avatar
Mike Hearn committed
110
void delete_drive(struct drive *pDrive);
111
void apply_drive_changes(void);
112
BOOL browse_for_unix_folder(HWND dialog, char *pszPath);
Mike Hearn's avatar
Mike Hearn committed
113 114 115 116 117
extern struct drive drives[26]; /* one for each drive letter */

BOOL gui_mode;

/* Some basic utilities to make win32 suck less */
118 119
#define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
#define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
120
void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
121

122
/* returns a string in the win32 heap  */
123
static inline char *strdupA(const char *s)
124
{
125
    char *r = HeapAlloc(GetProcessHeap(), 0, strlen(s)+1);
126 127 128
    return strcpy(r, s);
}

129 130 131 132 133 134
static inline WCHAR *strdupW(const WCHAR *s)
{
    WCHAR *r = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(s)+1)*sizeof(WCHAR));
    return lstrcpyW(r, s);
}

Mike Hearn's avatar
Mike Hearn committed
135
static inline char *get_text(HWND dialog, WORD id)
136 137 138
{
    HWND item = GetDlgItem(dialog, id);
    int len = GetWindowTextLength(item) + 1;
Mike Hearn's avatar
Mike Hearn committed
139 140
    char *result = len ? HeapAlloc(GetProcessHeap(), 0, len) : NULL;
    if (!result || GetWindowText(item, result, len) == 0) return NULL;
141 142
    return result;
}
143

144
static inline void set_text(HWND dialog, WORD id, const char *text)
Mike Hearn's avatar
Mike Hearn committed
145 146 147 148
{
    SetWindowText(GetDlgItem(dialog, id), text);
}

149
#define WINE_KEY_ROOT "Software\\Wine"
150
#define MAXBUFLEN 256
151

152 153
extern HMENU     hPopupMenus;

154
#endif