annotate src/VisVim/Reg.cpp @ 14247:381b01f77461 v8.1.0140

patch 8.1.0140: recording into a register has focus events commit https://github.com/vim/vim/commit/972bfddc6b3f52ae0865ad8c0bf6089bc8a9883a Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jul 3 14:48:15 2018 +0200 patch 8.1.0140: recording into a register has focus events Problem: Recording into a register has focus events. (Michael Naumann) Solution: Don't record K_FOCUSGAINED and K_FOCUSLOST. (closes https://github.com/vim/vim/issues/3143)
author Christian Brabandt <cb@256bit.org>
date Tue, 03 Jul 2018 15:00:09 +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