annotate src/VisVim/Reg.cpp @ 9900:daecffbd0322 v7.4.2224

commit https://github.com/vim/vim/commit/af9c4c9b5761c4c074237d87e2c95713bf721eab Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 17 21:51:56 2016 +0200 patch 7.4.2224 Problem: Compiler warnings with older compiler and 64 bit numbers. Solution: Add "LL" to large values. (Mike Williams)
author Christian Brabandt <cb@256bit.org>
date Wed, 17 Aug 2016 22:00:07 +0200
parents 3fc0f57ecb91
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 #include "stdafx.h"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 // Returns key for HKEY_CURRENT_USER\"Software"\Company\AppName
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 // creating it if it doesn't exist
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 // responsibility of the caller to call RegCloseKey() on the returned HKEY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 //
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 HKEY GetAppKey (char* AppName)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 HKEY hAppKey = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 HKEY hSoftKey = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 if (RegOpenKeyEx (HKEY_CURRENT_USER, "Software", 0, KEY_WRITE | KEY_READ,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 &hSoftKey) == ERROR_SUCCESS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 DWORD Dummy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 RegCreateKeyEx (hSoftKey, AppName, 0, REG_NONE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 &hAppKey, &Dummy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 if (hSoftKey)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 RegCloseKey (hSoftKey);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 return hAppKey;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 // Returns key for
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 // HKEY_CURRENT_USER\"Software"\RegistryKey\AppName\Section
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 // creating it if it doesn't exist.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 // responsibility of the caller to call RegCloseKey () on the returned HKEY
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 //
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 HKEY GetSectionKey (HKEY hAppKey, LPCTSTR Section)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 HKEY hSectionKey = NULL;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 DWORD Dummy;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 RegCreateKeyEx (hAppKey, Section, 0, REG_NONE,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 REG_OPTION_NON_VOLATILE, KEY_WRITE|KEY_READ, NULL,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 &hSectionKey, &Dummy);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 return hSectionKey;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 int GetRegistryInt (HKEY hSectionKey, LPCTSTR Entry, int Default)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 DWORD Value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 DWORD Type;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 DWORD Count = sizeof (DWORD);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 if (RegQueryValueEx (hSectionKey, (LPTSTR) Entry, NULL, &Type,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 (LPBYTE) &Value, &Count) == ERROR_SUCCESS)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 return Value;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 return Default;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 bool WriteRegistryInt (HKEY hSectionKey, char* Entry, int nValue)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 return RegSetValueEx (hSectionKey, Entry, NULL, REG_DWORD,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 (LPBYTE) &nValue, sizeof (nValue)) == ERROR_SUCCESS;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56