OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
registry.h
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1994, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// General Registry access & registration implementation
7/// TRegKey, TRegValue, TRegKeyIterator, TRegValueIterator
8/// TXRegistry
9/// TRegItem, TRegList, TRegLink - associative array of localizable string parameters
10/// OC registry functions
11//----------------------------------------------------------------------------
12
13#if !defined(OWL_REGISTRY_H)
14#define OWL_REGISTRY_H
15
16#include <owl/private/defs.h>
17#if defined(BI_HAS_PRAGMA_ONCE)
18# pragma once
19#endif
20
21#include <owl/private/checks.h>
22#include <owl/except.h>
23#include <owl/wsysinc.h>
24#include <owl/lclstrng.h>
25#include <owl/private/memory.h>
27#include <vector>
28#include <optional>
29#include <type_traits>
30#include <cstddef>
31
32namespace owl {
33
34#include <owl/preclass.h>
35
36/// \addtogroup winsys
37/// @{
38
39//----------------------------------------------------------------------------
40// Direct registry access classes. Can read & iterate as well as create and
41// write keys and value-data pairs
42//
43
44class _OWLCLASS TRegKey;
45class _OWLCLASS TRegValueIterator;
46
47//
48/// Encapsulates a value-data entry within one registration key.
49//
51{
52public:
53 TRegValue(const TRegKey& key, LPCTSTR name);
54 TRegValue(const TRegKey& key, const tstring& name);
55 explicit TRegValue(const TRegValueIterator& iter);
56
57#if defined(BI_COMP_BORLANDC)
58
59 // Circumvent bug in std::optional (requires default constructor for the contained object type).
60 // TODO: Remove this when the library is standard compliant.
61 //
62 TRegValue();
63
64#endif
65
66 /// \name Accessors
67 /// @{
68
69 LPCTSTR GetName() const;
70 uint32 GetDataType() const;
71 uint32 GetDataSize() const;
72 const uint8* GetData() const;
73
74 operator uint32() const;
75 operator uint64() const;
76 operator LPCTSTR() const;
77
78 /// @}
79 /// \name Mutators
80 /// @{
81
82 long Set(uint32 type, const uint8* data, uint32 dataSize);
83 long Set(uint32 value);
84 long Set(uint64 value);
85 long Set(LPCTSTR value);
86 long Set(const tstring& value);
87
92
93 long Delete();
94
95 /// @}
96
97private:
98 const TRegKey& Key; ///< Key that this value lives in
99 tstring Name; ///< Value name; if empty, this object represents the default value for the associated key.
100
101 uint32 DataType; ///< Type code for value data
102 mutable std::vector<uint8> Data; ///< Value data; mutable to support lazy retrieval (see RetrieveOnDemand).
103 uint32 DataSize; ///< Size in bytes of Data
104
105 long QueryTypeAndSize();
106 void RetrieveOnDemand() const;
107};
108
110
111//
112/// Encapsulates a registration key in the Windows Registry.
113//
115{
116public:
117 typedef HKEY THandle;
118
119 //
120 /// Enumeration used to specify whether a key should be created (or simply opened).
121 //
123 {
124 CreateOK, ///< Create key if it does not exist.
125 NoCreate ///< Don't create, simply open.
126 };
127
128 /// \name Accessors to system predefined registry keys
129 /// @{
130
131 static auto GetClassesRoot() -> TRegKey&;
132 static auto GetClassesRootClsid() -> TRegKey&;
133 static auto GetCurrentConfig() -> TRegKey&;
134 static auto GetCurrentUser() -> TRegKey&;
135 static auto GetLocalMachine() -> TRegKey&;
136 static auto GetPerformanceData() -> TRegKey&;
137 static auto GetUsers() -> TRegKey&;
138
139 /// @}
140
141#if defined(OWL5_COMPAT)
142
143 /// \name Deprecated alternative accessors to system predefined registry keys
144 /// @{
145
146 static auto ClassesRoot() -> TRegKey& { return GetClassesRoot(); }
147 static auto ClassesRootClsid() -> TRegKey& { return GetClassesRootClsid(); }
148 static auto CurrentConfig() -> TRegKey& { return GetCurrentConfig(); }
149 static auto CurrentUser() -> TRegKey& { return GetCurrentUser(); }
150 static auto LocalMachine() -> TRegKey& { return GetLocalMachine(); }
151 static auto PerformanceData() -> TRegKey& { return GetPerformanceData(); }
152 static auto Users() -> TRegKey& { return GetUsers(); }
153
154 /// @}
155
156#endif
157
158 TRegKey(THandle baseKey, tstring keyName, REGSAM samDesired = KEY_ALL_ACCESS, TCreateOK createOK = CreateOK);
159 TRegKey(THandle baseKey, LPCTSTR keyName, REGSAM samDesired = KEY_ALL_ACCESS, TCreateOK createOK = CreateOK);
160 explicit TRegKey(const TRegKeyIterator& iter, REGSAM samDesired = KEY_ALL_ACCESS);
161 TRegKey(THandle aliasKey, bool shouldClose, tstring keyName);
162 explicit TRegKey(THandle aliasKey, bool shouldClose = false, LPCTSTR keyName = nullptr);
163
164 TRegKey(TRegKey&&) noexcept;
167
168#if defined(BI_COMP_BORLANDC)
169
170 // Circumvent bug in std::optional (requires default constructor for the contained object type).
171 // TODO: Remove this when the library is standard compliant.
172 //
173 TRegKey() = default;
174
175#endif
176
177 ~TRegKey();
178
179 operator THandle() const;
180 auto GetHandle() const -> THandle { return Key; }
181
182 long DeleteKey(LPCTSTR subKeyName);
184 { return DeleteKey(subKeyName.c_str()); }
185
186 long NukeKey(LPCTSTR subKeyName);
188 { return NukeKey(subKeyName.c_str()); }
189
190 long Flush() const;
191
192 /// \name Security attributes
193 /// @{
194
195 //
196 /// Encapsulates a SECURITY_DESCRIPTOR.
197 ///
198 /// This class is used by TRegKey::GetSecurity(SECURITY_INFORMATION) const and
199 /// TRegKey::SetSecurity(SECURITY_INFORMATION, const TSecurityDescriptor&) const.
200 ///
201 /// \sa <a href="https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-security_descriptor">
202 /// SECURITY_DESCRIPTOR</a> in the Windows API.
203 ///
205 {
206 public:
208
209 auto IsValid() const noexcept -> bool;
210
211 auto GetControl() const -> SECURITY_DESCRIPTOR_CONTROL;
212 auto GetLength() const -> DWORD;
213 auto GetDacl() const -> std::optional<PACL>;
214 auto GetGroup() const -> PSID;
215 auto GetOwner() const -> PSID;
216 auto GetRevision() const -> DWORD;
217 auto GetRmControl() const -> std::optional<UCHAR>;
218 auto GetSacl() const -> std::optional<PACL>;
219
221 void RemoveDacl();
222 void RemoveGroup();
223 void RemoveOwner();
224 void RemoveRmControl();
225 void RemoveSacl();
226 void SetDacl(PACL dacl, bool daclDefaulted = false);
227 void SetGroup(PSID group, bool groupDefaulted = false);
228 void SetOwner(PSID owner, bool ownerDefaulted = false);
229 void SetRmControl(UCHAR rmControl);
230 void SetSacl(PACL sacl, bool saclDefaulted = false);
231
232 /// \name Security descriptor buffer access
233 /// @{
234
235 auto GetData() noexcept -> SECURITY_DESCRIPTOR* { return reinterpret_cast<SECURITY_DESCRIPTOR*>(Data.data()); }
236 auto GetData() const noexcept -> const SECURITY_DESCRIPTOR* { return reinterpret_cast<const SECURITY_DESCRIPTOR*>(Data.data()); }
237 auto GetDataSize() const noexcept -> int { return static_cast<int>(Data.size()); }
238
239 /// @}
240 /// \name SECURITY_DESCRIPTOR_CONTROL queries
241 /// @{
242
243 auto IsFlagSet(SECURITY_DESCRIPTOR_CONTROL mask) const { return (GetControl() & mask) == mask; } ///< Returns true if all the set bits in the given mask are set in the SECURITY_DESCRIPTOR_CONTROL structure.
244
245 auto IsAbsolute() const { return !IsFlagSet(SE_SELF_RELATIVE); } ///< Returns the inverse of the SE_SELF_RELATIVE flag in the SECURITY_DESCRIPTOR_CONTROL structure.
246 auto IsDaclAutoInheritRequired() const { return IsFlagSet(SE_DACL_AUTO_INHERIT_REQ); } ///< Returns the SE_DACL_AUTO_INHERIT_REQ flag in the SECURITY_DESCRIPTOR_CONTROL structure.
247 auto IsDaclAutoInherited() const { return IsFlagSet(SE_DACL_AUTO_INHERITED); } ///< Returns the SE_DACL_AUTO_INHERITED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
248 auto IsDaclDefaulted() const { return IsFlagSet(SE_DACL_DEFAULTED); } ///< Returns the SE_DACL_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
249 auto IsDaclPresent() const { return IsFlagSet(SE_DACL_PRESENT); } ///< Returns the SE_DACL_PRESENT flag in the SECURITY_DESCRIPTOR_CONTROL structure.
250 auto IsDaclProtected() const { return IsFlagSet(SE_DACL_PROTECTED); } ///< Returns the SE_DACL_PROTECTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
251 auto IsGroupDefaulted() const { return IsFlagSet(SE_GROUP_DEFAULTED); } ///< Returns the SE_GROUP_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
252 auto IsOwnerDefaulted() const { return IsFlagSet(SE_OWNER_DEFAULTED); } ///< Returns the SE_OWNER_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
253 auto IsRmControlValid() const { return IsFlagSet(SE_RM_CONTROL_VALID); } ///< Returns the SE_RM_CONTROL_VALID flag in the SECURITY_DESCRIPTOR_CONTROL structure.
254 auto IsSaclAutoInheritRequired() const { return IsFlagSet(SE_SACL_AUTO_INHERIT_REQ); } ///< Returns the SE_SACL_AUTO_INHERIT_REQ flag in the SECURITY_DESCRIPTOR_CONTROL structure.
255 auto IsSaclAutoInherited() const { return IsFlagSet(SE_SACL_AUTO_INHERITED); } ///< Returns the SE_SACL_AUTO_INHERITED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
256 auto IsSaclDefaulted() const { return IsFlagSet(SE_SACL_DEFAULTED); } ///< Returns the SE_SACL_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
257 auto IsSaclPresent() const { return IsFlagSet(SE_SACL_PRESENT); } ///< Returns the SE_SACL_PRESENT flag in the SECURITY_DESCRIPTOR_CONTROL structure.
258 auto IsSaclProtected() const { return IsFlagSet(SE_SACL_PROTECTED); } ///< Returns the SE_SACL_PROTECTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
259 auto IsSelfRelative() const { return IsFlagSet(SE_SELF_RELATIVE); } ///< Returns the SE_SELF_RELATIVE flag in the SECURITY_DESCRIPTOR_CONTROL structure.
260
261 /// @}
262
263 private:
264 std::vector<std::byte> Data;
265 };
266
268 auto GetSecurity(SECURITY_INFORMATION infoRequested) const -> TSecurityDescriptor;
270 void SetSecurity(SECURITY_INFORMATION infoToSet, const TSecurityDescriptor& s) const;
271
272 /// @}
273
274 // Saving & loading of this key & subKeys
275 //
276 long Save(LPCTSTR fileName);
277 long Save(const tstring& fileName)
278 { return Save(fileName.c_str()); }
279
280 long LoadKey(LPCTSTR subKeyName, LPCTSTR fileName);
282 { return LoadKey(subKeyName.c_str(), fileName.c_str()); }
283
286 { return ReplaceKey(subKeyName.c_str(), newFileName.c_str(), oldFileName.c_str()); }
287
288 long Restore(LPCTSTR fileName, uint32 options = 0);
290 { return Restore(fileName.c_str(), options); }
291
292 long UnLoadKey(LPCTSTR subKeyName);
294 { return UnLoadKey(subKeyName.c_str()); }
295
296 long QueryInfo(LPTSTR class_, DWORD* classSize,
300
301 //
302 /// Data structure returned by QueryInfo.
303 //
316
317 auto QueryInfo() const -> TInfo;
318
319 LPCTSTR GetName() const;
320 auto HasSubkey(const tstring& keyName) const -> bool;
321 auto GetSubkey(const tstring& keyName, REGSAM samDesired = KEY_READ) const->std::optional<TRegKey>;
322 uint32 GetSubkeyCount() const;
323 auto HasValue(const tstring& valueName) const -> bool;
324 auto GetValue(const tstring& valueName) const->std::optional<TRegValue>;
325 uint32 GetValueCount() const;
326
327 //
328 /// Returns the value of the given name, if it exists, or the given default value, otherwise.
329 /// A conversion of the TRegValue to type T is attempted. The provided default value must be
330 /// convertible to T. The types supported for T are owl::uint32, owl::uint64 and owl::tstring.
331 ///
332 /// \note T can not be LPCTSTR, because that would return a pointer to a dead object (the
333 /// TRegValue object looked up is local to the function). Use owl::tstring instead.
334 //
336 auto GetValueOrDefault(const tstring& valueName, T defaultValue) const
337 {
338 static_assert(!std::is_pointer_v<T>, "Return type can not be pointer.");
339 const auto v = GetValue(valueName);
340 return v ? static_cast<T>(*v) : defaultValue;
341 }
342
343 // Friend iterators only...?
344 // TODO: Provide string-returning overload.
345 //
346 long EnumKey(int index, LPTSTR subKeyName, int subKeyNameSize) const;
347
348#if defined(OWL5_COMPAT)
349
350 // Older, nameless subkey+(Default) value access
351 //
355 { return SetDefValue(subkeyName.c_str(), type, data.c_str(), dataSize); }
356
358 uint32* dataSize) const;
359 long QueryDefValue(const tstring& subkeyName, LPTSTR data, uint32* dataSize) const
360 { return QueryDefValue(subkeyName.c_str(), data, dataSize); }
361
362#endif
363
364 // Newer, named value set & get functions. Subkeys must be opened
365 //
366 long SetValue(LPCTSTR valName, uint32 type, const uint8* data, uint32 dataSize) const;
368 { return SetValue(valName.c_str(), type, data, dataSize); }
369
370 long SetValue(LPCTSTR valName, uint32 data) const;
371 long SetValue(const tstring& valName, uint32 data) const
372 { return SetValue(valName.c_str(), data); }
373
374 long SetValue(LPCTSTR valName, const tstring& value) const;
375 long SetValue(const tstring& valName, const tstring& value) const
376 { return SetValue(valName.c_str(), value); }
377
378 long QueryValue(LPCTSTR valName, uint32* type, uint8* data, uint32* dataSize) const;
380 { return QueryValue(valName.c_str(), type, data, dataSize); }
381
382 long DeleteValue(LPCTSTR valName) const;
383 long DeleteValue(const tstring& valName) const
384 { return DeleteValue(valName.c_str()); }
385
386 // Friend iterators only...?
387 // TODO: Provide value-returning overload.
388 //
389 long EnumValue(int index, LPTSTR valueName, uint32& valueNameSize, uint32* type = nullptr, uint8* data = nullptr, uint32* dataSize = nullptr) const;
390
391protected:
392 THandle Key; ///< This Key's Handle.
393 tstring Name; ///< This Key's Name.
394 DWORD SubkeyCount; ///< Number of subkeys.
395 DWORD ValueCount; ///< Number of value entries.
396 bool ShouldClose; ///< Should this key be closed on destruction.
397};
398
399//
400/// Iterator for walking thru the subkeys of a key.
401//
403{
404public:
405 TRegKeyIterator(const TRegKey& key);
406
407 operator bool();
408
410 uint32 operator ++(int);
412 uint32 operator --(int);
413 uint32 operator [](int index);
414
415 int Current() const;
416 const TRegKey& BaseKey() const;
417
418 void Reset();
419
420private:
421 const TRegKey& Key;
422 int Index;
423};
424
425//
426/// Iterator for walking through the values of a key.
427//
429{
430public:
432
433 operator bool();
434
436 uint32 operator ++(int);
438 uint32 operator --(int);
439 uint32 operator [](int index);
440
441 int Current() const;
442 const TRegKey& BaseKey() const;
443
444 void Reset();
445
446private:
447 const TRegKey& Key;
448 int Index;
449};
450
451//----------------------------------------------------------------------------
452
453//
454/// Thrown for errors within the Registry classes.
455//
457{
458public:
459 TXRegistry(const tstring& context, const TRegKey& key, long errorCode = 0)
460 : TXOwl{context}, KeyName{key.GetName()}, ErrorCode{errorCode}
461 {}
462
464 : TXOwl{context}, KeyName{std::move(keyName)}, ErrorCode{errorCode}
465 {}
466
467 auto GetKeyName() const -> const tstring& { return KeyName; }
468 auto GetErrorCode() const -> long { return ErrorCode; }
469
470private:
471 tstring KeyName;
472 long ErrorCode;
473};
474
475
476//----------------------------------------------------------------------------
477// Registration parameter structures and formatting functions
478//
479
480//
481/// Used internally to provide buffers for formating registration strings.
482//
484{
485public:
488 tchar* Alloc(int spaceNeeded);
489
490private:
491 struct TBlock
492 {
493 TBlock* Next; ///< Next heap in chain.
494 tchar Data[1]; ///< Allocated memory starts here.
495 };
496 TBlock* Head;
497};
498
499//
500/// A single registration list entry.
501///
502/// TRegItem defines localizable values for parameters or subkeys. These values can
503/// be passed to TLocaleString, which defines a localizable substitute for char*.
504/// TRegItem contains several undocumented functions that are used privately by the
505/// registration macros REGFORMAT and REGSTATUS.
506//
508{
509 const char* Key; ///< Non-localized parameter or registry subkey
510 TLocaleString Value; ///< Localizable value for parameter or subkey
511
512 // Used privately by REGFORMAT, REGSTATUS macros.
513 //
514 static tchar* RegFormat(int f, int a, int t, int d, TRegFormatHeap& heap);
515 static tchar* RegFormat(LPCTSTR f, int a, int t, int d, TRegFormatHeap& heap);
516 static tchar* RegFormat(const tstring& f, int a, int t, int d, TRegFormatHeap& heap) { return RegFormat(f.c_str(), a, t, d, heap); }
517 static tchar* RegFlags(long flags, TRegFormatHeap& heap);
518 static tchar* RegVerbOpt(int mf, int sf, TRegFormatHeap& heap);
519 static void OverflowCheck();
520};
521
522//
523/// A registration parameter table, composed of a list of TRegItems.
524//
525/// Holds an array of items of type TRegItem. Provides functionality that lets you
526/// access each item in the array and return the name of the item. Instead of
527/// creating a TRegList directly, you can use ObjectWindows' registration macros to
528/// build a TRegList for you.
529//
531{
532public:
534
535 LPCTSTR Lookup(LPCSTR key, TLangId lang = TLocaleString::UserDefaultLangId);
536 LPCTSTR Lookup(const std::string& key, TLangId lang = TLocaleString::UserDefaultLangId)
537 { return Lookup(key.c_str(), lang); }
538
539 TLocaleString& LookupRef(LPCSTR key);
540 TLocaleString& LookupRef(const std::string& key)
541 { return LookupRef(key.c_str()); }
542
543 LPCTSTR operator[](LPCSTR key);
544 LPCTSTR operator[](const std::string& key)
545 { return operator[](key.c_str()); }
546
548};
549
550//
551/// A linked structure in which each node points to a list of TRegList
552/// objects (or TRegList-derived objects) or TDocTemplate objects.
553///
554/// Each object has an item name and a string value associated with the item name. The structure
555/// forms a typical linked list as the following diagram illustrates:
556/// \image html bm251.BMP
557///
558/// A TDocTemplate object uses the following variation of the TRegLink structure:
559/// \image html bm252.BMP
560//
562{
563public:
565 virtual ~TRegLink();
566
567 TRegLink* GetNext() const;
568 void SetNext(TRegLink* link);
569 TRegList& GetRegList() const;
570
571 static void AddLink(TRegLink** head, TRegLink* newLink);
572 static bool RemoveLink(TRegLink** head, TRegLink* remLink);
573
574protected:
575 TRegLink(); ///< Derived class must fill in ptrs
576 TRegLink* Next; ///< Next RegLink
577 TRegList* RegList; ///< Pointer to registration parameter table
578};
579
580//
581// Registration parameter table macro definitions
582//
583#define BEGIN_REGISTRATION(regname) \
584 extern TRegItem regname##_list[];\
585 extern TRegFormatHeap __regHeap;\
586 TRegList regname(regname##_list);\
587 TRegItem regname##_list[] = {
588
589#define END_REGISTRATION {0,{0}} };
590
591#define REGDATA(var,val) {#var, {val}},
592#define REGXLAT(var,val) {#var, {AUTOLANG_XLAT val}},
593#define REGITEM(key,val) {" " key, {val}},
594#define REGFORMAT(i,f,a,t,d) {"format" #i,{TRegItem::RegFormat(f,a,t,d,__regHeap)}},
595#define REGSTATUS(a,f) {"aspect" #a, {TRegItem::RegFlags(f,__regHeap)}},
596#define REGVERBOPT(v,mf,sf) {#v "opt",{TRegItem::RegVerbOpt(mf,sf,__regHeap)}},
597#define REGICON(i) {"iconindex",{TRegItem::RegFlags(i,__regHeap)}},
598#define REGDOCFLAGS(i) {"docflags",{TRegItem::RegFlags(i,__regHeap)}},
599
600//
601// Buffer size is no longer needed, use the macro below
602//
603#define REGISTRATION_FORMAT_BUFFER(n) \
604 TRegFormatHeap __regHeap;
605
606#define REGISTRATION_FORMAT_HEAP \
607 TRegFormatHeap __regHeap;
608
609//----------------------------------------------------------------------------
610// Clipboard and registry data transfer format definitions
611//
612
613const int ocrVerbLimit = 8; ///< Maximum number of verbs registered per class.
614const int ocrFormatLimit = 8; ///< Maximum number of data formats per class.
615
616//
617/// Format: standard clipboard numeric format, or name of custom format.
618//
620{
621 ocrText = 1, ///< CF_TEXT
622 ocrBitmap = 2, ///< CF_BITMAP
623 ocrMetafilePict = 3, ///< CF_METAFILEPICT
624 ocrSylk = 4, ///< CF_SYLK
625 ocrDif = 5, ///< CF_DIF
626 ocrTiff = 6, ///< CF_TIFF
627 ocrOemText = 7, ///< CF_OEMTEXT
628 ocrDib = 8, ///< CF_DIB
629 ocrPalette = 9, ///< CF_PALETTE
630 ocrPenData = 10, ///< CF_PENDATA
631 ocrRiff = 11, ///< CF_RIFF
632 ocrWave = 12, ///< CF_WAVE
633 ocrUnicodeText = 13, ///< CF_UNICODETEXT Win32 only
634 ocrEnhMetafile = 14, ///< CF_ENHMETAFILE Win32 only
635};
636
637#define ocrRichText _T("Rich Text Format")
638#define ocrEmbedSource _T("Embed Source")
639#define ocrEmbeddedObject _T("Embedded Object")
640#define ocrLinkSource _T("Link Source")
641#define ocrObjectDescriptor _T("Object Descriptor")
642#define ocrLinkSrcDescriptor _T("Link Source Descriptor")
643
644//
645/// Aspect: view types supported by transfer.
646//
648{
649 ocrContent = 1, ///< DVASPECT_CONTENT - normal display representation.
650 ocrThumbnail = 2, ///< DVASPECT_THUMBNAIL - picture appropriate for browser.
651 ocrIcon = 4, ///< DVASPECT_ICON - iconized representation of object.
652 ocrDocPrint = 8, ///< DVASPECT_DOCPRINT - print preview representation.
653};
654
655//
656/// Medium: means of data transfer.
657//
659{
661 ocrHGlobal = 1, ///< TYMED_HGLOBAL - global memory handle.
662 ocrFile = 2, ///< TYMED_FILE - data as contents of file.
663 ocrIStream = 4, ///< TYMED_ISTREAM - instance of an IStream object.
664 ocrIStorage = 8, ///< TYMED_ISTORAGE - streams within an instance of IStorage.
665 ocrGDI = 16, ///< TYMED_GDI - GDI object in global handle.
666 ocrMfPict = 32, ///< TYMED_MFPICT - CF_METAFILEPICT containing global handle.
667 ocrStaticMed = 1024 ///< OLE 2 static object.
669
670//
671/// Direction: transfer directions supported.
672//
674{
678};
679
680//----------------------------------------------------------------------------
681// Miscellaneous registry definitions
682//
683
684//
685/// IOleObject miscellaneous status flags, defined for each or all aspects.
686//
688{
689 ocrRecomposeOnResize = 1, ///< Request redraw on container resize.
690 ocrOnlyIconic = 2, ///< Only useful context view is Icon.
691 ocrInsertNotReplace = 4, ///< Should not replace current select.
692 ocrStatic = 8, ///< Object is an OLE static object.
693 ocrCantLinkInside = 16, ///< Should not be the link source.
694 ocrCanLinkByOle1 = 32, ///< Only used in OBJECTDESCRIPTOR.
695 ocrIsLinkObject = 64, ///< Set by OLE2 link for OLE1 compat.
696 ocrInsideOut = 128, ///< Can be activated concurrently.
697 ocrActivateWhenVisible = 256, ///< Hint to cntnr when ocrInsideOut set.
698 ocrRenderingIsDeviceIndependent = 512, ///< No decisions made based on target.
699 ocrNoSpecialRendering = 512, ///< Older enum for previous entry.
700};
701
702//
703/// IOleObject verb menu flags.
704//
706{
707 ocrGrayed = 1, ///< MF_GRAYED
708 ocrDisabled = 2, ///< MF_DISABLED
709 ocrChecked = 8, ///< MF_CHECKED
710 ocrMenuBarBreak = 32, ///< MF_MENUBARBREAK
711 ocrMenuBreak = 64, ///< MF_MENUBAR
712};
713
714//
715/// IOleObject verb attribute flags.
716//
718{
719 ocrNeverDirties = 1, ///< Verb can never cause object to become dirty.
720 ocrOnContainerMenu = 2, ///< Only useful context view is Icon.
721};
722
723//
724// Entries for <usage> registration parameter, class factory registration mode
725//
726#define ocrSingleUse _T("1") ///< Single client per instance.
727#define ocrMultipleUse _T("2") ///< Multiple clients per instance.
728#define ocrMultipleLocal _T("3") ///< Multiple clients, separate inproc server.
729
730//----------------------------------------------------------------------------
731// High-level table based registration support
732//
733
734//
735/// List of parameterized template strings that represent the actual entries to be registered.
736///
737/// List is indexed from 1 for used with param-list template activation strings. See TRegParamList below.
738//
739// TODO: Add string-class support in constructor.
740//
742{
743public:
746
747 int GetCount() const;
748 TRegKey& GetBaseKey();
749
750 LPCTSTR operator [](int i);
751
752 // Enable/Disable and activate templates
753 //
754 void DisableAll();
755 void EnableAll();
756 void Enable(int i);
757 void Enable(LPCTSTR set);
758 void Enable(const tstring& set) { Enable(set.c_str()); }
759
760 void Activate(int i);
761 void Activate(LPCTSTR set);
762 void Activate(const tstring& set) { Activate(set.c_str()); }
763
764 bool IsActive(int i) const;
765
766private:
767 TRegKey& BaseKey; ///< Registry key on which these templates are based.
768 const tchar** List; ///< List of templates.
769 int Count; ///< Number of templates in list.
770 int8* EnabledFlags; // Which templates are currently enabled/active.
771};
772
773//
774/// A list of param entries for use as an intermediate between a TRegList and
775/// the actual template list used to generate the registration.
776///
777/// Provides default values in 'Default', and tags required templates using octal char entries in
778/// 'TemplatesNeeded'.
779//
781{
782public:
783 struct TEntry
784 {
785 LPCTSTR Param; ///< Substituted parameter name.
786 LPCTSTR Default; ///< Default value, 0 if no default & param is required.
787 LPCTSTR TemplatesNeeded; ///< Octal string list of template indices to activate.
788 };
789
790 TRegParamList(const TEntry*);
792
793 int Find(LPCTSTR param);
794 int Find(const tstring& param) { return Find(param.c_str()); }
795 int GetCount() const;
796 const tchar*& Value(int i);
797 void ResetDefaultValues();
798
799 const TEntry& operator [](int i) const;
800
801private:
802 const TEntry* List;
803 int Count;
804 const tchar** Values;
805};
806
807//
808/// High level symbol-based registry entry manipulation.
809///
810//
811// TODO: Add string-class support in constructor.
812//
814{
815public:
817
818 void Init(LPCTSTR filter);
819 void UpdateParams(TLangId lang, TRegItem* item);
820 void StreamOut(TRegItem* item, tostream& out);
821
825};
826
827//
828/// TRegistry provides high level stream and list access to the registry.
829//
831{
832public:
833 static int Validate(TRegKey& baseKey, tistream& in); ///< Returns number of mismatched entries
834 static void Update(TRegKey& baseKey, tistream& in); ///< Writes lines to registry
835
836#pragma pack(push,4)
837
839 {
840 tchar Prepend; ///< Optional tchar to prepend to key before removing.
841 LPCTSTR Name; ///< Name of param.
842 TRegKey* BaseKey; ///< Key that that the param is based upon.
843 };
844
845#pragma pack(pop)
846
847 static int Unregister(TRegList& regInfo, const TUnregParams* params, const TRegItem* overrides = nullptr);
848};
849
850/// @}
851
852#include <owl/posclass.h>
853
854//----------------------------------------------------------------------------
855// TRegKey inlines
856//
857
858//
859/// Returns the HANDLE identifying this registry key.
860//
861inline TRegKey::operator THandle() const
862{
863 return Key;
864}
865
866//
867/// Enumerates the subkeys of this registry key.
868//
869inline long TRegKey::EnumKey(int index, LPTSTR subKeyName, int subKeyNameSize) const
870{
871 return ::RegEnumKey(Key, index, subKeyName, subKeyNameSize);
872 //::RegEnumKeyEx(); ??
873}
874
875//
876/// Deletes the specified subkey of this registry key.
877//
879{
880 return ::RegDeleteKey(Key, subKeyName);
881}
882
883//
884/// Writes the attribute of this key in the registry
885//
886inline long TRegKey::Flush() const
887{
888 return ::RegFlushKey(Key);
889}
890
891//
892/// Retrieves a copy of the security descriptor protecting this registry key.
893///
894/// \sa <a href="https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetkeysecurity">
895/// RegGetKeySecurity</a> in the Windows API.
896//
898{
899 return ::RegGetKeySecurity(Key, infoRequested, secDesc, secDescSize);
900}
901
902//
903/// Retrieves a copy of the security descriptor protecting this registry key.
904/// \param infoRequested indicates the requested security information.
905/// \returns If successful, a TRegKey::TSecurityDescriptor is returned.
906/// \exception TXRegistry is thrown on failure.
907///
908/// \sa <a href="https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetkeysecurity">
909/// RegGetKeySecurity</a> in the Windows API.
910//
915
916//
917/// Sets the security descriptor of this key.
918///
919/// \sa <a href="https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetkeysecurity">
920/// RegSetKeySecurity</a> in the Windows API.
921//
923{
924 return ::RegSetKeySecurity(Key, infoToSet, secDesc);
925}
926
927//
928/// Sets the security descriptor of this key.
929/// \param infoToSet indicates the security information to set.
930/// \exception TXRegistry is thrown on failure.
931///
932/// \sa <a href="https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regsetkeysecurity">
933/// RegSetKeySecurity</a> in the Windows API.
934//
936{
937 const auto r = SetSecurity(infoToSet, const_cast<SECURITY_DESCRIPTOR*>(s.GetData()));
938 if (r != ERROR_SUCCESS) throw TXRegistry{_T("TRegKey::SetSecurity failed"), *this, r};
939}
940
941//
942/// Saves this key and all of its subkeys and values to the specified file.
943//
945{
946 return ::RegSaveKey(Key, fileName, nullptr/*Security*/);
947}
948
949//
950/// Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores registration
951/// information from a specified file into that subkey. This registration
952/// information is in the form of a hive. A hive is a discrete body of keys,
953/// subkeys, and values that is rooted at the top of the registry hierarchy. A hive
954/// is backed by a single file and a .LOG file.
955//
957{
958 return ::RegLoadKey(Key, subKeyName, fileName);
959}
960
961//
962/// Replaces the file backing this key and all of its subkeys with another file, so
963/// that when the system is next started, the key and subkeys will have the values
964/// stored in the new file.
965//
970
971//
972/// Reads the registry information in a specified file and copies it over this key.
973/// This registry information may be in the form of a key and multiple levels of
974/// subkeys.
975//
977{
978 return ::RegRestoreKey(Key, fileName, options);
979}
980
981//
982/// Unloads this key and its subkeys from the registry.
983//
985{
986 return ::RegUnLoadKey(Key, subKeyName);
987}
988
989//
990/// Returns the number of subkeys attached to this key.
991//
993{
994 return SubkeyCount;
995}
996
997//
998/// Returns the number of values attached to this key.
999//
1001{
1002 return ValueCount;
1003}
1004
1005//
1006/// Returns a string identifying this key.
1007//
1009{
1010 return Name.c_str();
1011}
1012
1013//
1014/// Associates a value with this key.
1015//
1017{
1018 return ::RegSetValueEx(Key, valName, 0, type, data, dataSize);
1019}
1020
1021//
1022/// Associates a 4-byte value with this key.
1023//
1025{
1026 return SetValue(valName, REG_DWORD, (uint8*) &data, sizeof data);
1027}
1028
1029//
1030/// Associates a string value with this key.
1031//
1033{
1034 const auto data = reinterpret_cast<const uint8*>(value.data());
1035 const auto dataSize = static_cast<uint32>((value.size() + 1) * sizeof(tchar));
1036 return SetValue(valName, REG_SZ, data, dataSize);
1037}
1038
1039//
1040/// Retrieves the value associated with the unnamed value for this key in the registry.
1041//
1043{
1044#if defined WINELIB //it seems that Winlib SDK declares a 'unsigned int*' instead of DWORD* and GCC it's tooo strict
1045 return ::RegQueryValueEx(Key, valName, nullptr, (unsigned int*) type, data, (unsigned int*) dataSize);
1046#else
1047 return ::RegQueryValueEx(Key, valName, nullptr, type, data, dataSize);
1048#endif//WINELIB
1049}
1050
1051//
1052/// Removes a named value from this registry key.
1053//
1055{
1056 return ::RegDeleteValue(Key, valName);
1057}
1058
1059#if defined(OWL5_COMPAT)
1060
1061//
1062/// Sets the default [unnamed] value associated with this key.
1063//
1064inline long TRegKey::SetDefValue(LPCTSTR subkeyName, uint32 type, LPCTSTR data, uint32 dataSize)
1065{
1066 return ::RegSetValue(Key, subkeyName, type, data, dataSize);
1067}
1068
1069//
1070/// Retrieves the default [unnamed] value associated with this key.
1071//
1072inline long TRegKey::QueryDefValue(LPCTSTR subkeyName, LPTSTR data, uint32* dataSize) const
1073{
1074#if defined WINELIB // It seems that Winlib SDK declares a 'int*' instead of DWORD*, and GCC is too strict.
1075 return ::RegQueryValue(Key, subkeyName, data, (int*) dataSize);
1076#else
1077 return ::RegQueryValue(Key, subkeyName, data, (long*) dataSize);
1078#endif
1079}
1080
1081#endif
1082
1083//
1084/// Enumerates the values associated with this key.
1085/// Copy the value name and data block associated with the passed index.
1086//
1087inline long TRegKey::EnumValue(int index, LPTSTR valueName, uint32& valueNameSize, uint32* type, uint8* data, uint32* dataSize) const
1088{
1089#if defined WINELIB // It seems that Winlib SDK declares a 'int*' instead of DWORD*, and GCC is too strict.
1090 return ::RegEnumValue(Key, index, valueName, (unsigned int*) &valueNameSize, 0, (unsigned int*) type, data, (unsigned int*) dataSize);
1091#else
1092 return ::RegEnumValue(Key, index, valueName, &valueNameSize, 0, type, data, dataSize);
1093#endif
1094}
1095
1096//----------------------------------------------------------------------------
1097// TRegValue inlines
1098//
1099
1100//
1101/// Returns a string identifying this value.
1102//
1104{
1105 return Name.c_str();
1106}
1107
1108//
1109/// Returns the type code for the data associated with this value
1110//
1112{
1113 return DataType;
1114}
1115
1116//
1117/// Returns the size in bytes of the data associated with this value.
1118//
1120{
1121 return DataSize;
1122}
1123
1124//----------------------------------------------------------------------------
1125// TRegKeyIterator inlines
1126//
1127
1128//
1129/// Creates a subkey iterator for a registration key.
1130//
1132 :
1133 Key(key),
1134 Index(0)
1135{
1136}
1137
1138//
1139/// Tests the validity of this iterator.
1140/// \return True if the iterator's index is greater than or equal to 0 and less than the number of subkeys.
1141//
1142inline TRegKeyIterator::operator bool()
1143{
1144 return Index >= 0 && Index < int(Key.GetSubkeyCount());
1145}
1146
1147//
1148/// Preincrements to the next subkey.
1149//
1151{
1152 return ++Index;
1153}
1154
1155//
1156/// Postincrements to the next subkey.
1157//
1159{
1160 return Index++;
1161}
1162
1163//
1164/// Predecrements to the previous subkey.
1165//
1167{
1168 return --Index;
1169}
1170
1171//
1172/// Postdecrements to the previous subkey.
1173//
1175{
1176 return Index--;
1177}
1178
1179//
1180/// Sets the index of the iterator to the passed value.
1181/// \return The new index.
1182//
1184{
1185 PRECONDITION((index >= 0) && (index < int(Key.GetSubkeyCount())));
1186 return Index = index;
1187}
1188
1189//
1190/// Returns the index to the current subkey.
1191//
1193{
1194 return Index;
1195}
1196
1197//
1198/// Returns the registration key this iterator is bound to.
1199//
1201{
1202 return Key;
1203}
1204
1205//
1206/// Resets the subkey index to zero.
1207//
1209{
1210 Index = 0;
1211}
1212
1213//----------------------------------------------------------------------------
1214// TRegValueIterator inlines
1215//
1216
1217//
1218/// Creates a value iterator for a registration key.
1219//
1221 : Key(regKey), Index(0)
1222{}
1223
1224//
1225/// Tests the validity of this iterator.
1226/// \return True if the iterator's index is greater than or equal to 0 and less than the number of values.
1227//
1228inline TRegValueIterator::operator bool()
1229{
1230 return Index >= 0 && Index < int(Key.GetValueCount());
1231}
1232
1233//
1234/// Preincrements to the next value.
1235//
1237{
1238 return ++Index;
1239}
1240
1241//
1242/// Postincrements to the next value.
1243//
1245{
1246 return Index++;
1247}
1248
1249//
1250/// Predecrements to the previous value.
1251//
1253{
1254 return --Index;
1255}
1256
1257//
1258/// Postdecrements to the previous value.
1259//
1261{
1262 return Index--;
1263}
1264
1265//
1266/// Sets the index of the iterator to the passed value.
1267/// \return The new index.
1268//
1270{
1271 PRECONDITION((index >= 0) && (index < int(Key.GetValueCount())));
1272 return Index = index;
1273}
1274
1275//
1276/// Returns the index to the current value.
1277//
1279{
1280 return Index;
1281}
1282
1283//
1284/// Returns the registration key that this iterator is bound to.
1285//
1287{
1288 return Key;
1289}
1290
1291//
1292/// Resets the value index to zero
1293//
1295{
1296 Index = 0;
1297}
1298
1299
1300//----------------------------------------------------------------------------
1301// TRegList inlines
1302//
1303
1304//
1305/// Constructs a TRegList object from an array of TRegItems terminated by a NULL item name.
1306//
1308 : Items(_list)
1309{
1311}
1312
1313//
1314/// The array operator uses an item name (key) to locate an item in the array.
1315/// Returns the value of the passed key as a const tchar*.
1316//
1318{
1319 PRECONDITION(key);
1320 return Lookup(key);
1321}
1322
1323
1324//----------------------------------------------------------------------------
1325// TRegLink inlines
1326//
1327
1328//
1329/// Registration link node destructor.
1330//
1332{}
1333
1334//
1335/// Returns a pointer to the next link.
1336//
1338{
1339 return Next;
1340}
1341
1343{
1344 Next = link;
1345}
1346
1347//
1348/// Returns a pointer to the registration parameter table (reglist).
1349//
1351{
1352 return *RegList;
1353}
1354
1355//
1356/// Protected constructor where the derived class must initialize all pointers.
1357//
1359 : Next(nullptr), RegList(nullptr)
1360{}
1361
1362//----------------------------------------------------------------------------
1363// TRegTemplateList
1364//
1365
1366//
1367/// Returns the number of templates in this list.
1368//
1370{
1371 return Count;
1372}
1373
1374//
1375/// Returns the registry key upon which these templates are based.
1376//
1378{
1379 return BaseKey;
1380}
1381
1382//
1383/// Returns the template string at the passed index.
1384/// \note The list is indexed beginning with 1 not 0.
1385//
1387{
1388 PRECONDITION(i > 0 && i <= Count);
1389 if (i <= 0 || i > Count)
1390 return nullptr;
1391 else
1392 return List[i - 1];
1393}
1394
1395//
1396/// Disables all templates in this list.
1397//
1399{
1400 memset(EnabledFlags, 0x80, Count);
1401}
1402
1403//
1404/// Enables all templates in this list.
1405//
1407{
1408 memset(EnabledFlags, 0x00, Count);
1409}
1410
1411//
1412/// Enables the template at the passed index.
1413/// \note The list is indexed beginning with 1 not 0.
1414//
1416{
1417 PRECONDITION(i > 0 && i <= Count);
1418 if (i > 0 && i <= Count)
1419 EnabledFlags[i - 1] = 0;
1420}
1421
1422//
1423/// Activates the template at the passed index.
1424/// \note The list is indexed beginning with 1 not 0.
1425//
1427{
1428 PRECONDITION(i > 0 && i <= Count);
1429 if (i > 0 && i <= Count)
1430 EnabledFlags[i - 1]++;
1431}
1432
1433//
1434/// Returns true if the template at the passed index is active, false otherwise.
1435/// \note The list is indexed beginning with 1 not 0.
1436//
1437inline bool TRegTemplateList::IsActive(int i) const
1438{
1439 PRECONDITION(i > 0 && i <= Count);
1440 if (i > 0 && i <= Count)
1441 return EnabledFlags[i - 1] > 0;
1442 else
1443 return false;
1444}
1445
1446//----------------------------------------------------------------------------
1447// TRegParamList
1448//
1449
1450//
1451/// Return the number of param entries in this list.
1452//
1453inline int TRegParamList::GetCount() const
1454{
1455 return Count;
1456}
1457
1458//
1459/// Return the template string at the passed index.
1460//
1462{
1463 PRECONDITION(i >= 0 && i < Count);
1464 return List[i];
1465}
1466
1467//
1468/// Return the value of the param entry at the passed index.
1469//
1470inline const tchar*& TRegParamList::Value(int i)
1471{
1472 PRECONDITION(i >= 0 && i < Count);
1473 return Values[i];
1474}
1475
1476} // OWL namespace
1477
1478#endif // OWL_REGISTRY_H
Diagnostic macros for assertions and tracing.
#define PRECONDITION(condition)
Definition checks.h:227
Used internally to provide buffers for formating registration strings.
Definition registry.h:484
Encapsulates a SECURITY_DESCRIPTOR.
Definition registry.h:205
auto IsDaclPresent() const
Returns the SE_DACL_PRESENT flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:249
auto IsAbsolute() const
Returns the inverse of the SE_SELF_RELATIVE flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:245
auto IsSaclPresent() const
Returns the SE_SACL_PRESENT flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:257
auto IsSaclProtected() const
Returns the SE_SACL_PROTECTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:258
auto GetData() const noexcept -> const SECURITY_DESCRIPTOR *
Definition registry.h:236
auto GetData() noexcept -> SECURITY_DESCRIPTOR *
Definition registry.h:235
auto IsDaclDefaulted() const
Returns the SE_DACL_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:248
auto GetDataSize() const noexcept -> int
Definition registry.h:237
auto IsSaclAutoInheritRequired() const
Returns the SE_SACL_AUTO_INHERIT_REQ flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:254
auto IsDaclAutoInheritRequired() const
Returns the SE_DACL_AUTO_INHERIT_REQ flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:246
auto IsSelfRelative() const
Returns the SE_SELF_RELATIVE flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:259
auto IsSaclAutoInherited() const
Returns the SE_SACL_AUTO_INHERITED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:255
auto IsOwnerDefaulted() const
Returns the SE_OWNER_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:252
auto IsSaclDefaulted() const
Returns the SE_SACL_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:256
auto IsDaclAutoInherited() const
Returns the SE_DACL_AUTO_INHERITED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:247
auto IsGroupDefaulted() const
Returns the SE_GROUP_DEFAULTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:251
auto IsFlagSet(SECURITY_DESCRIPTOR_CONTROL mask) const
Returns true if all the set bits in the given mask are set in the SECURITY_DESCRIPTOR_CONTROL structu...
Definition registry.h:243
auto IsRmControlValid() const
Returns the SE_RM_CONTROL_VALID flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:253
auto IsDaclProtected() const
Returns the SE_DACL_PROTECTED flag in the SECURITY_DESCRIPTOR_CONTROL structure.
Definition registry.h:250
Encapsulates a registration key in the Windows Registry.
Definition registry.h:115
long EnumValue(int index, TCHAR *valueName, uint32 &valueNameSize, uint32 *type=nullptr, uint8 *data=nullptr, uint32 *dataSize=nullptr) const
Enumerates the values associated with this key.
Definition registry.h:1087
long UnLoadKey(LPCTSTR subKeyName)
Unloads this key and its subkeys from the registry.
Definition registry.h:984
long Save(const tstring &fileName)
Definition registry.h:277
auto SetSecurity(SECURITY_INFORMATION infoToSet, PSECURITY_DESCRIPTOR secDesc) const -> long
Sets the security descriptor of this key.
Definition registry.h:922
long ReplaceKey(LPCTSTR subKeyName, LPCTSTR newFileName, LPCTSTR oldFileName)
Replaces the file backing this key and all of its subkeys with another file, so that when the system ...
Definition registry.h:966
LPCTSTR GetName() const
Returns a string identifying this key.
Definition registry.h:1008
long SetValue(const tstring &valName, const tstring &value) const
Definition registry.h:375
auto GetHandle() const -> THandle
Definition registry.h:180
DWORD SubkeyCount
Number of subkeys.
Definition registry.h:394
long DeleteKey(LPCTSTR subKeyName)
Deletes the specified subkey of this registry key.
Definition registry.h:878
long Save(LPCTSTR fileName)
Saves this key and all of its subkeys and values to the specified file.
Definition registry.h:944
tstring Name
This Key's Name.
Definition registry.h:393
THandle Key
This Key's Handle.
Definition registry.h:392
long Restore(const tstring &fileName, uint32 options=0)
Definition registry.h:289
long Flush() const
Writes the attribute of this key in the registry.
Definition registry.h:886
long Restore(LPCTSTR fileName, uint32 options=0)
Reads the registry information in a specified file and copies it over this key.
Definition registry.h:976
long SetValue(const tstring &valName, uint32 type, const uint8 *data, uint32 dataSize) const
Definition registry.h:367
long DeleteValue(const tstring &valName) const
Definition registry.h:383
long SetValue(LPCTSTR valName, uint32 type, const uint8 *data, uint32 dataSize) const
Associates a value with this key.
Definition registry.h:1016
long LoadKey(LPCTSTR subKeyName, LPCTSTR fileName)
Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores registration information from a spe...
Definition registry.h:956
long DeleteKey(const tstring &subKeyName)
Definition registry.h:183
long DeleteValue(LPCTSTR valName) const
Removes a named value from this registry key.
Definition registry.h:1054
auto GetSecurity(SECURITY_INFORMATION infoRequested, PSECURITY_DESCRIPTOR secDesc, DWORD *secDescSize) const -> long
Retrieves a copy of the security descriptor protecting this registry key.
Definition registry.h:897
long UnLoadKey(const tstring &subKeyName)
Definition registry.h:293
long NukeKey(const tstring &subKeyName)
Definition registry.h:187
long QueryValue(const tstring &valName, uint32 *type, uint8 *data, uint32 *dataSize) const
Definition registry.h:379
long ReplaceKey(const tstring &subKeyName, const tstring &newFileName, const tstring &oldFileName)
Definition registry.h:285
bool ShouldClose
Should this key be closed on destruction.
Definition registry.h:396
long QueryValue(LPCTSTR valName, uint32 *type, uint8 *data, uint32 *dataSize) const
Retrieves the value associated with the unnamed value for this key in the registry.
Definition registry.h:1042
uint32 GetSubkeyCount() const
Returns the number of subkeys attached to this key.
Definition registry.h:992
long EnumKey(int index, TCHAR *subKeyName, int subKeyNameSize) const
Enumerates the subkeys of this registry key.
Definition registry.h:869
long LoadKey(const tstring &subKeyName, const tstring &fileName)
Definition registry.h:281
uint32 GetValueCount() const
Returns the number of values attached to this key.
Definition registry.h:1000
long SetValue(const tstring &valName, uint32 data) const
Definition registry.h:371
DWORD ValueCount
Number of value entries.
Definition registry.h:395
TCreateOK
Enumeration used to specify whether a key should be created (or simply opened).
Definition registry.h:123
@ CreateOK
Create key if it does not exist.
Definition registry.h:124
Iterator for walking thru the subkeys of a key.
Definition registry.h:403
uint32 operator[](int index)
Sets the index of the iterator to the passed value.
Definition registry.h:1183
uint32 operator++()
Preincrements to the next subkey.
Definition registry.h:1150
uint32 operator--()
Predecrements to the previous subkey.
Definition registry.h:1166
const TRegKey & BaseKey() const
Returns the registration key this iterator is bound to.
Definition registry.h:1200
TRegKeyIterator(const TRegKey &key)
Creates a subkey iterator for a registration key.
Definition registry.h:1131
void Reset()
Resets the subkey index to zero.
Definition registry.h:1208
int Current() const
Returns the index to the current subkey.
Definition registry.h:1192
A registration parameter table, composed of a list of TRegItems.
Definition registry.h:531
TRegItem * Items
Definition registry.h:547
TRegList(TRegItem *_list)
Constructs a TRegList object from an array of TRegItems terminated by a NULL item name.
Definition registry.h:1307
LPCTSTR Lookup(LPCSTR key, TLangId lang=TLocaleString::UserDefaultLangId)
Performs the lookup of the TRegItems using a key (an item name such as progid) and returns the value ...
Definition regheap.cpp:58
TLocaleString & LookupRef(const std::string &key)
Definition registry.h:540
LPCTSTR operator[](LPCSTR key)
The array operator uses an item name (key) to locate an item in the array.
Definition registry.h:1317
LPCTSTR operator[](const std::string &key)
Definition registry.h:544
LPCTSTR Lookup(const std::string &key, TLangId lang=TLocaleString::UserDefaultLangId)
Definition registry.h:536
A list of param entries for use as an intermediate between a TRegList and the actual template list us...
Definition registry.h:781
const tchar *& Value(int i)
Return the value of the param entry at the passed index.
Definition registry.h:1470
int Find(const tstring &param)
Definition registry.h:794
const TEntry & operator[](int i) const
Return the template string at the passed index.
Definition registry.h:1461
int GetCount() const
Return the number of param entries in this list.
Definition registry.h:1453
High level symbol-based registry entry manipulation.
Definition registry.h:814
TRegTemplateList Templates
Definition registry.h:822
TRegParamList Params
Definition registry.h:823
List of parameterized template strings that represent the actual entries to be registered.
Definition registry.h:742
LPCTSTR operator[](int i)
Returns the template string at the passed index.
Definition registry.h:1386
void DisableAll()
Disables all templates in this list.
Definition registry.h:1398
bool IsActive(int i) const
Returns true if the template at the passed index is active, false otherwise.
Definition registry.h:1437
void Activate(int i)
Activates the template at the passed index.
Definition registry.h:1426
void Activate(const tstring &set)
Definition registry.h:762
void Enable(const tstring &set)
Definition registry.h:758
int GetCount() const
Returns the number of templates in this list.
Definition registry.h:1369
TRegKey & GetBaseKey()
Returns the registry key upon which these templates are based.
Definition registry.h:1377
void Enable(int i)
Enables the template at the passed index.
Definition registry.h:1415
void EnableAll()
Enables all templates in this list.
Definition registry.h:1406
Encapsulates a value-data entry within one registration key.
Definition registry.h:51
uint32 GetDataSize() const
Returns the size in bytes of the data associated with this value.
Definition registry.h:1119
uint32 GetDataType() const
Returns the type code for the data associated with this value.
Definition registry.h:1111
LPCTSTR GetName() const
Returns a string identifying this value.
Definition registry.h:1103
Iterator for walking through the values of a key.
Definition registry.h:429
void Reset()
Resets the value index to zero.
Definition registry.h:1294
int Current() const
Returns the index to the current value.
Definition registry.h:1278
uint32 operator--()
Predecrements to the previous value.
Definition registry.h:1252
const TRegKey & BaseKey() const
Returns the registration key that this iterator is bound to.
Definition registry.h:1286
uint32 operator[](int index)
Sets the index of the iterator to the passed value.
Definition registry.h:1269
uint32 operator++()
Preincrements to the next value.
Definition registry.h:1236
TRegValueIterator(const TRegKey &regKey)
Creates a value iterator for a registration key.
Definition registry.h:1220
TRegistry provides high level stream and list access to the registry.
Definition registry.h:831
TXOwl is root class of the ObjectWindows exception hierarchy.
Definition except.h:38
Thrown for errors within the Registry classes.
Definition registry.h:457
TXRegistry(const tstring &context, const TRegKey &key, long errorCode=0)
Definition registry.h:459
TXRegistry(const tstring &context, tstring keyName, long errorCode=0)
Definition registry.h:463
auto GetKeyName() const -> const tstring &
Definition registry.h:467
auto GetErrorCode() const -> long
Definition registry.h:468
#define _T(x)
Definition cygwin.h:51
ocrObjectStatus
IOleObject miscellaneous status flags, defined for each or all aspects.
Definition registry.h:688
ocrMedium
Medium: means of data transfer.
Definition registry.h:659
ocrVerbAttributes
IOleObject verb attribute flags.
Definition registry.h:718
ocrAspect
Aspect: view types supported by transfer.
Definition registry.h:648
ocrDirection
Direction: transfer directions supported.
Definition registry.h:674
const int ocrFormatLimit
Maximum number of data formats per class.
Definition registry.h:614
ocrClipFormat
Format: standard clipboard numeric format, or name of custom format.
Definition registry.h:620
ocrVerbMenuFlags
IOleObject verb menu flags.
Definition registry.h:706
const int ocrVerbLimit
Maximum number of verbs registered per class.
Definition registry.h:613
@ ocrCantLinkInside
Should not be the link source.
Definition registry.h:693
@ ocrNoSpecialRendering
Older enum for previous entry.
Definition registry.h:699
@ ocrStatic
Object is an OLE static object.
Definition registry.h:692
@ ocrInsertNotReplace
Should not replace current select.
Definition registry.h:691
@ ocrRecomposeOnResize
Request redraw on container resize.
Definition registry.h:689
@ ocrRenderingIsDeviceIndependent
No decisions made based on target.
Definition registry.h:698
@ ocrOnlyIconic
Only useful context view is Icon.
Definition registry.h:690
@ ocrCanLinkByOle1
Only used in OBJECTDESCRIPTOR.
Definition registry.h:694
@ ocrActivateWhenVisible
Hint to cntnr when ocrInsideOut set.
Definition registry.h:697
@ ocrInsideOut
Can be activated concurrently.
Definition registry.h:696
@ ocrIsLinkObject
Set by OLE2 link for OLE1 compat.
Definition registry.h:695
@ ocrFile
TYMED_FILE - data as contents of file.
Definition registry.h:662
@ ocrStaticMed
OLE 2 static object.
Definition registry.h:667
@ ocrIStream
TYMED_ISTREAM - instance of an IStream object.
Definition registry.h:663
@ ocrNull
Definition registry.h:660
@ ocrMfPict
TYMED_MFPICT - CF_METAFILEPICT containing global handle.
Definition registry.h:666
@ ocrGDI
TYMED_GDI - GDI object in global handle.
Definition registry.h:665
@ ocrHGlobal
TYMED_HGLOBAL - global memory handle.
Definition registry.h:661
@ ocrIStorage
TYMED_ISTORAGE - streams within an instance of IStorage.
Definition registry.h:664
@ ocrNeverDirties
Verb can never cause object to become dirty.
Definition registry.h:719
@ ocrOnContainerMenu
Only useful context view is Icon.
Definition registry.h:720
@ ocrDocPrint
DVASPECT_DOCPRINT - print preview representation.
Definition registry.h:652
@ ocrThumbnail
DVASPECT_THUMBNAIL - picture appropriate for browser.
Definition registry.h:650
@ ocrContent
DVASPECT_CONTENT - normal display representation.
Definition registry.h:649
@ ocrIcon
DVASPECT_ICON - iconized representation of object.
Definition registry.h:651
@ ocrSet
Definition registry.h:676
@ ocrGet
Definition registry.h:675
@ ocrGetSet
Definition registry.h:677
@ ocrOemText
CF_OEMTEXT.
Definition registry.h:627
@ ocrUnicodeText
CF_UNICODETEXT Win32 only.
Definition registry.h:633
@ ocrWave
CF_WAVE.
Definition registry.h:632
@ ocrSylk
CF_SYLK.
Definition registry.h:624
@ ocrDib
CF_DIB.
Definition registry.h:628
@ ocrMetafilePict
CF_METAFILEPICT.
Definition registry.h:623
@ ocrPalette
CF_PALETTE.
Definition registry.h:629
@ ocrRiff
CF_RIFF.
Definition registry.h:631
@ ocrDif
CF_DIF.
Definition registry.h:625
@ ocrBitmap
CF_BITMAP.
Definition registry.h:622
@ ocrTiff
CF_TIFF.
Definition registry.h:626
@ ocrPenData
CF_PENDATA.
Definition registry.h:630
@ ocrText
CF_TEXT.
Definition registry.h:621
@ ocrEnhMetafile
CF_ENHMETAFILE Win32 only.
Definition registry.h:634
@ ocrMenuBreak
MF_MENUBAR.
Definition registry.h:711
@ ocrMenuBarBreak
MF_MENUBARBREAK.
Definition registry.h:710
@ ocrDisabled
MF_DISABLED.
Definition registry.h:708
@ ocrChecked
MF_CHECKED.
Definition registry.h:709
@ ocrGrayed
MF_GRAYED.
Definition registry.h:707
TLocaleString - localized name support.
Reliable platform independent header for common memory and string functions.
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
signed char int8
Definition number.h:28
unsigned char uint8
Definition number.h:32
unsigned long uint32
Definition number.h:34
owl::uint16 TLangId
Holds a language ID, a predefined number that represents a base language and dialect.
Definition lclstrng.h:26
char tchar
Definition defs.h:77
std::istream tistream
Definition strmdefs.h:39
unsigned __int64 uint64
Definition number.h:43
std::string tstring
Definition defs.h:79
std::ostream tostream
Definition strmdefs.h:40
ObjectWindows exception class & function definitions.
#define _OWLCLASS
Definition defs.h:338
Designed to provide support for localized registration parameters, the TLocaleString Struct defines a...
Definition lclstrng.h:68
A single registration list entry.
Definition registry.h:508
TLocaleString Value
Localizable value for parameter or subkey.
Definition registry.h:510
const char * Key
Non-localized parameter or registry subkey.
Definition registry.h:509
static tchar * RegFormat(const tstring &f, int a, int t, int d, TRegFormatHeap &heap)
Definition registry.h:516
static void OverflowCheck()
Data structure returned by QueryInfo.
Definition registry.h:305
DWORD SecurityDescriptorSize
Definition registry.h:313
FILETIME LastWriteTime
Definition registry.h:314
DWORD MaxValueDataSize
In bytes.
Definition registry.h:312
Definition registry.h:784
LPCTSTR Default
Default value, 0 if no default & param is required.
Definition registry.h:786
LPCTSTR TemplatesNeeded
Octal string list of template indices to activate.
Definition registry.h:787
LPCTSTR Param
Substituted parameter name.
Definition registry.h:785
tchar Prepend
Optional tchar to prepend to key before removing.
Definition registry.h:840
LPCTSTR Name
Name of param.
Definition registry.h:841
TRegKey * BaseKey
Key that that the param is based upon.
Definition registry.h:842
Includes windowing system headers, with necessary macros defined.