Mercurial > emacs
comparison src/w32reg.c @ 13434:53ba95a88cf2
Initial revision
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Tue, 07 Nov 1995 07:52:28 +0000 |
parents | |
children | ee40177f6c68 |
comparison
equal
deleted
inserted
replaced
13433:21a9f15132d7 | 13434:53ba95a88cf2 |
---|---|
1 /* Emulate the X Resource Manager through the registry. | |
2 Copyright (C) 1990, 1993, 1994 Free Software Foundation. | |
3 | |
4 This program is free software; you can redistribute it and/or modify | |
5 it under the terms of the GNU General Public License as published by | |
6 the Free Software Foundation; either version 2, or (at your option) | |
7 any later version. | |
8 | |
9 This program is distributed in the hope that it will be useful, | |
10 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 GNU General Public License for more details. | |
13 | |
14 You should have received a copy of the GNU General Public License | |
15 along with this program; see the file COPYING. If not, write to | |
16 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
17 | |
18 /* Written by Kevin Gallo */ | |
19 | |
20 #include <config.h> | |
21 #include "lisp.h" | |
22 #include "w32term.h" | |
23 #include "blockinput.h" | |
24 | |
25 #include <stdio.h> | |
26 #include <string.h> | |
27 | |
28 #define REG_ROOT "SOFTWARE\\GNU\\Emacs\\" | |
29 | |
30 LPBYTE | |
31 win32_get_string_resource (name, class, dwexptype) | |
32 char *name, *class; | |
33 DWORD dwexptype; | |
34 { | |
35 LPBYTE lpvalue = NULL; | |
36 HKEY hrootkey = NULL; | |
37 DWORD dwType; | |
38 DWORD cbData; | |
39 BOOL ok = FALSE; | |
40 | |
41 BLOCK_INPUT; | |
42 | |
43 /* Check both the current user and the local machine to see if we have any resources */ | |
44 | |
45 if (RegOpenKeyEx (HKEY_CURRENT_USER, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS | |
46 || RegOpenKeyEx (HKEY_LOCAL_MACHINE, REG_ROOT, 0, KEY_READ, &hrootkey) == ERROR_SUCCESS) | |
47 { | |
48 char *keyname; | |
49 | |
50 if (RegQueryValueEx (hrootkey, name, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS | |
51 && dwType == dwexptype) | |
52 { | |
53 keyname = name; | |
54 } | |
55 else if (RegQueryValueEx (hrootkey, class, NULL, &dwType, NULL, &cbData) == ERROR_SUCCESS | |
56 && dwType == dwexptype) | |
57 { | |
58 keyname = class; | |
59 } | |
60 else | |
61 { | |
62 keyname = NULL; | |
63 } | |
64 | |
65 ok = (keyname | |
66 && (lpvalue = (LPBYTE) xmalloc (cbData)) != NULL | |
67 && RegQueryValueEx (hrootkey, keyname, NULL, NULL, lpvalue, &cbData) == ERROR_SUCCESS); | |
68 | |
69 RegCloseKey (hrootkey); | |
70 } | |
71 | |
72 UNBLOCK_INPUT; | |
73 | |
74 if (!ok) | |
75 { | |
76 if (lpvalue) xfree (lpvalue); | |
77 return (NULL); | |
78 } | |
79 else | |
80 { | |
81 return (lpvalue); | |
82 } | |
83 } | |
84 | |
85 /* Retrieve the string resource specified by NAME with CLASS from | |
86 database RDB. */ | |
87 | |
88 char * | |
89 x_get_string_resource (rdb, name, class) | |
90 int rdb; | |
91 char *name, *class; | |
92 { | |
93 return (win32_get_string_resource (name, class, REG_SZ)); | |
94 } |