-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAutoReg.cpp
More file actions
711 lines (587 loc) · 17 KB
/
AutoReg.cpp
File metadata and controls
711 lines (587 loc) · 17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
/*******************************************************************
// Copyright (c) 2000, Robert Umbehant
// mailto:rumbehant@wheresjames.com
//
// 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 Foundation, Inc., 59 Temple Place, Suite 330, Boston,
// MA 02111-1307 USA
//
*******************************************************************/
// Reg.cpp: implementation of the CAutoReg class.
//
//////////////////////////////////////////////////////////////////////
#include "StdAfx.h"
#ifdef DEBUG_NEW
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAutoReg::CAutoReg()
{_STTEX();
// Make sure the list is empty
RemoveAll();
// Start with the local machine
SetComputer( NULL );
}
CAutoReg::~CAutoReg()
{_STTEX();
}
BOOL CAutoReg::CreateEntry( LPREGENTRY pReg, HKEY hKey, LPCTSTR pKey, DWORD dwType,
LPCTSTR pName, void* pvoidData, DWORD dwLength,
DWORD dwDef, void* pvoidDef, DWORD dwDefLength,
DWORD dwUser, LPCTSTR pComputer )
{_STTEX();
// Sanity Checks
if ( pReg == NULL ) return FALSE;
if ( pKey == NULL ) return FALSE;
// Blank out the structure
ZeroMemory( (LPVOID)pReg, sizeof( REGENTRY ) );
// Save the users data
// Key info
pReg->hKey = hKey;
strcpy( pReg->szKey, pKey );
pReg->dwType = dwType;
// User variable info
pReg->dwLength = dwLength;
if ( pName == NULL || pName[ 0 ] == 0x0 ) pReg->szName[ 0 ] = 0x0;
else strcpy( pReg->szName, pName );
pReg->pvoidData = pvoidData;
// Set user default value info
SetDefault( pReg, dwDef, pvoidDef, dwDefLength );
// User value
pReg->dwUser = dwUser;
// Remote computer info
if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
strcpy( pReg->szComputer, pComputer );
else pReg->szComputer[ 0 ] = 0x0;
return TRUE;
}
BOOL CAutoReg::AddEntry( HKEY hKey, LPCTSTR pKey, DWORD dwType,
LPCTSTR pName, void* pvoidData, DWORD dwLength,
DWORD dwDef, void* pvoidDef, DWORD dwDefLength,
DWORD dwUser, LPCTSTR pComputer )
{_STTEX();
CAutoRegEntry reg;
// Fill in the data
CreateEntry( ®, hKey, pKey, dwType, pName, pvoidData, dwLength,
dwDef, pvoidDef, dwDefLength, dwUser, pComputer );
// Add it to the list
m_Entrys += reg;
return TRUE;
}
void CAutoReg::RemoveAll()
{_STTEX();
m_Entrys.empty();
}
DWORD CAutoReg::Size()
{_STTEX();
return m_Entrys.size();
}
BOOL CAutoReg::Get(LPREGENTRY pRE, DWORD dwIndex)
{_STTEX();
DWORD size = Size();
LPREGENTRY reg;
if ( pRE == NULL || !size || dwIndex >= size ) return FALSE;
// Get the settings
reg = (LPREGENTRY)&m_Entrys[ dwIndex ];
// Copy the data
memcpy( (LPVOID)pRE, (LPVOID)reg, sizeof( REGENTRY ) );
return TRUE;
}
BOOL CAutoReg::Restore(LPCTSTR pName, DWORD *pdwNumRead )
{_STTEX();
BOOL bRet = TRUE;
DWORD size = Size();
LPREGENTRY reg;
if ( pdwNumRead != NULL ) *pdwNumRead = 0;
for ( DWORD i = 0; i < size; i++ )
{
// Get the settings
reg = (LPREGENTRY)&m_Entrys[ i ];
if ( !ReadReg( pName, reg, m_szComputer ) ) bRet = FALSE;
else if ( pdwNumRead != NULL ) (*pdwNumRead)++;
} // end for
return bRet;
}
BOOL CAutoReg::ReadReg(LPCTSTR pName, LPREGENTRY pReg, LPCTSTR pComputer)
{_STTEX();
HKEY hKey, hRoot;
char szKey[ MAX_PATH ];
BOOL bRet = TRUE;
DWORD dwType;
DWORD dwLength;
BOOL bRemote = FALSE;
if ( pReg == NULL ) return FALSE;
// Generate key name
szKey[ 0 ] = 0x0;
strcpy( szKey, pReg->szKey );
if ( pName != NULL && pName[ 0 ] != 0x0 )
{
if ( szKey[ 0 ] != 0x0 ) strcat( szKey, "\\" );
strcat( szKey, pName );
} // end if
// Connect to remote computer if needed
if ( pReg->szComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( pReg->szComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return FALSE;
bRemote = TRUE;
} else if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( (char*)pComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return FALSE;
bRemote = TRUE;
} // end else if
// Must want the local machine
else hRoot = pReg->hKey;
// Open The Key
if( RegOpenKeyEx( hRoot, szKey, 0,
KEY_QUERY_VALUE, &hKey ) != ERROR_SUCCESS )
{
// Close the remote key if open
if ( bRemote ) RegCloseKey( hRoot );
Default( pReg );
return FALSE;
} // end if
// Record the length and type
dwLength = pReg->dwLength;
dwType = pReg->dwType;
// Read The Data
if( RegQueryValueEx( hKey, pReg->szName, 0, &dwType,
(LPBYTE) pReg->pvoidData, &dwLength ) != ERROR_SUCCESS )
bRet = FALSE;
// Make sure it is the correct type
// And The Correct Length
if( !bRet || pReg->dwType != dwType )
{
bRet = FALSE;
Default( pReg );
} // end if
// Close The Key
RegCloseKey( hKey );
// Close the remote key if open
if ( bRemote ) RegCloseKey( hRoot );
return bRet;
}
BOOL CAutoReg::SetDefault( LPREGENTRY pReg, DWORD dwDef,
void* pvoidDef, DWORD dwDefLength )
{_STTEX();
if ( pReg == NULL ) return FALSE;
pReg->dwDef = dwDef;
if ( pvoidDef == NULL )
{
pReg->dwDefSource = 1;
pReg->pvoidDef = NULL;
pReg->dwDefLength = sizeof( DWORD );
} // end if
else
{
if ( dwDefLength == 0 )
{
pReg->dwDefSource = 2;
pReg->pvoidDef = NULL;
strcpy( pReg->szDef, (char*)pvoidDef );
pReg->dwDefLength = strlen( pReg->szDef ) + 1;
} // end if
else
{
pReg->dwDefSource = 0;
pReg->dwDefLength = dwDefLength;
pReg->pvoidDef = pvoidDef;
} // end else
} // end else
return TRUE;
}
BOOL CAutoReg::Default(LPREGENTRY pReg)
{_STTEX();
if ( pReg == NULL ) return FALSE;
switch( pReg->dwDefSource )
{
case 0 :
memcpy( pReg->pvoidData, pReg->pvoidDef, pReg->dwDefLength );
break;
case 1 :
*((LPDWORD)pReg->pvoidData) = pReg->dwDef;
break;
case 2 :
memcpy( pReg->pvoidData, (LPVOID)pReg->szDef, pReg->dwDefLength );
break;
default : break;
} // end switch
return TRUE;
}
BOOL CAutoReg::Save( LPCTSTR pName )
{_STTEX();
BOOL bRet = TRUE;
DWORD size = Size();
LPREGENTRY reg;
for ( DWORD i = 0; i < size; i++ )
{
// Get the settings
reg = (LPREGENTRY)&m_Entrys[ i ];
if ( !WriteReg( pName, reg, m_szComputer ) ) bRet = FALSE;
} // end for
return bRet;
}
BOOL CAutoReg::WriteReg( LPCTSTR pName, LPREGENTRY pReg, LPCTSTR pComputer )
{_STTEX();
HKEY hRoot;
HKEY hKey;
BOOL bRet = TRUE;
char szKey[ MAX_PATH ];
BOOL bRemote = FALSE;
// Generate key name
szKey[ 0 ] = 0x0;
strcpy( szKey, pReg->szKey );
if ( pName != NULL && pName[ 0 ] != 0x0 )
{
if ( szKey[ 0 ] != 0x0 ) strcat( szKey, "\\" );
strcat( szKey, pName );
} // end if
// Connect to remote computer if needed
if ( pReg->szComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( pReg->szComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return FALSE;
bRemote = TRUE;
} else if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( (char*)pComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return FALSE;
bRemote = TRUE;
} // end else if
// Must want the local machine
else hRoot = pReg->hKey;
// Open The Key
if( RegCreateKey( hRoot, szKey, &hKey ) != ERROR_SUCCESS )
{
// Close the remote key if open
if ( bRemote ) RegCloseKey( hRoot );
return FALSE;
} // end if
// Set The Key Value
if( RegSetValueEx( hKey, pReg->szName, 0, pReg->dwType,
(LPBYTE) pReg->pvoidData, pReg->dwLength )
!= ERROR_SUCCESS )
bRet = FALSE;
RegCloseKey( hKey );
// Close the remote key if open
if ( bRemote ) RegCloseKey( hRoot );
return bRet;
}
void CAutoReg::DefaultAll()
{_STTEX();
DWORD size = Size();
for ( DWORD i = 0; i < size; i++ )
{
// Set Defaults
Default( (LPREGENTRY)&m_Entrys[ i ] ) ;
} // end for
}
LPREGENTRY CAutoReg::GetEntry(LPCTSTR pName)
{_STTEX();
DWORD size = m_Entrys.size();
LPREGENTRY reg = NULL;
// If the list is empty
if ( !size ) return NULL;
// Search the list and find the correct entry
for ( DWORD i = 0; i < size && reg == NULL; i++ )
if ( m_Entrys[ i ] == pName )
reg = (LPREGENTRY)&m_Entrys[ i ];
return reg;
}
// Return Values
//
// 0 = No Access or invalid key data
// 1 = KEY_QUERY_VALUE
// 2 = KEY_READ
// 3 = KEY_WRITE
// 4 = KEY_QUERY_VALUE | KEY_WRITE
// 5 = KEY_READ | KEY_WRITE
//
DWORD CAutoReg::TestAccess( LPCTSTR pName, LPREGENTRY pReg, LPCTSTR pComputer )
{_STTEX();
HKEY hKey, hRoot;
char szKey[ MAX_PATH ];
BOOL bRemote = FALSE;
DWORD access = 0;
if ( pReg == NULL ) return 0;
// Generate key name
szKey[ 0 ] = 0x0;
strcpy( szKey, pReg->szKey );
if ( pName != NULL && pName[ 0 ] != 0x0 )
{
if ( szKey[ 0 ] != 0x0 ) strcat( szKey, "\\" );
strcat( szKey, pName );
} // end if
// Connect to remote computer if needed
if ( pReg->szComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( pReg->szComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} else if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( (char*)pComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} // end else if
// Must want the local machine
else hRoot = pReg->hKey;
// Query access
if( RegOpenKeyEx( hRoot, szKey, 0,
KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS )
{
RegCloseKey( hKey );
// We have KEY_QUERY_VALUE access
access = 1;
} // end if
// Read access
if( RegOpenKeyEx( hRoot, szKey, 0,
KEY_READ, &hKey ) == ERROR_SUCCESS )
{
RegCloseKey( hKey );
// We have KEY_READ access
access = 2;
} // end if
// Write access
if( RegOpenKeyEx( hRoot, szKey, 0,
KEY_WRITE, &hKey ) == ERROR_SUCCESS )
{
RegCloseKey( hKey );
// We have KEY_WRITE access
access += 3;
} // end if
if ( bRemote ) RegCloseKey( hRoot );
// Tell the caller how it turned out
return access;
}
DWORD CAutoReg::TestAccess( LPCTSTR pName, LPREGENTRY pReg )
{_STTEX();
LPREGENTRY reg;
if ( pReg != NULL ) reg = pReg;
else reg = (LPREGENTRY)&m_Entrys[ 0 ];
// Get the access level
return TestAccess( pName, reg, m_szComputer );
}
char* CAutoReg::AccessString( DWORD access )
{_STTEX();
#define SW_ACCESS( l, str ) case l : return str; break;
switch( access )
{
SW_ACCESS( 1, "Query access to data only" );
SW_ACCESS( 2, "Read access to data only" );
SW_ACCESS( 3, "Write access to data only" );
SW_ACCESS( 4, "Query and Write access to data only" );
SW_ACCESS( 5, "Full Read Write access to data granted" );
default : SW_ACCESS( 0, "Access to data is denied" );
} // end switch
}
BOOL CAutoReg::DeleteEntry ( LPCTSTR pName, LPREGENTRY pReg, LPCTSTR pComputer )
{_STTEX();
BOOL bRet = FALSE;
HKEY hKey, hRoot;
char szKey[ MAX_PATH ];
BOOL bRemote = FALSE;
DWORD access = 0;
// Sanity Check
if ( pReg == NULL ) return FALSE;
if ( pName == NULL && pReg->szName[ 0 ] == 0x0 ) return FALSE;
// Generate key name
strcpy( szKey, pReg->szKey );
// Connect to remote computer if needed
if ( pReg->szComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( pReg->szComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} else if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( (char*)pComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} // end else if
// Must want the local machine
else hRoot = pReg->hKey;
// Open The Key
if( RegOpenKeyEx( hRoot, szKey, 0, KEY_ALL_ACCESS, &hKey ) != ERROR_SUCCESS )
{
// Close the remote key if open
if ( bRemote ) RegCloseKey( hRoot );
return FALSE;
} // end if
// Attempt to delete the key
if( RegDeleteKey( hKey, ( pName != NULL ) ? pName : pReg->szName ) == ERROR_SUCCESS ) bRet = TRUE;
// Close the keys
RegCloseKey( hKey );
if ( bRemote ) RegCloseKey( hRoot );
return bRet;
}
BOOL CAutoReg::DeleteSubKeys ( HKEY hRoot, LPCTSTR pKey )
{_STTEX();
HKEY hKey;
char szKey[ MAX_PATH ];
DWORD dwSize = MAX_PATH - 1;
FILETIME ft;
ZeroMemory( (LPVOID)&ft, sizeof( FILETIME ) );
// Open The Key
if( RegOpenKeyEx( hRoot, pKey, 0, KEY_ALL_ACCESS, &hKey ) != ERROR_SUCCESS )
return FALSE;
// For each sub key
while ( RegEnumKeyEx( hKey, 0, szKey, &dwSize,
NULL, NULL, NULL, &ft ) == ERROR_SUCCESS )
{
// A little recursion
DeleteSubKeys( hKey, szKey );
// Attempt to delete the key
RegDeleteKey( hKey, szKey );
dwSize = MAX_PATH - 1;
} // end while
// Close the key
RegCloseKey( hKey );
return TRUE;
}
BOOL CAutoReg::DeleteSubKeys ( LPCTSTR pName, LPREGENTRY pReg, LPCTSTR pComputer )
{_STTEX();
BOOL bRet = FALSE;
HKEY hRoot;
char szKey[ MAX_PATH ];
BOOL bRemote = FALSE;
DWORD access = 0;
// Sanity Check
if ( pReg == NULL ) return FALSE;
// Generate key name
szKey[ 0 ] = 0x0;
strcpy( szKey, pReg->szKey );
if ( pName != NULL && pName[ 0 ] != 0x0 )
{
if ( szKey[ 0 ] != 0x0 ) strcat( szKey, "\\" );
strcat( szKey, pName );
} // end if
// Connect to remote computer if needed
if ( pReg->szComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( pReg->szComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} else if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
{
if ( RegConnectRegistry( (char*)pComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} // end else if
// Must want the local machine
else hRoot = pReg->hKey;
// Attempt to delete the Sub-keys
if( DeleteSubKeys( hRoot, szKey ) == ERROR_SUCCESS ) bRet = TRUE;
// Close the remote key if needed
if ( bRemote ) RegCloseKey( hRoot );
return bRet;
}
BOOL CAutoReg::GetSubKey( DWORD index, LPREGENTRY pDest, LPCTSTR pName, LPREGENTRY pReg, LPCTSTR pComputer )
{_STTEX();
BOOL bRet = FALSE;
HKEY hKey, hRoot;
char szKey[ MAX_PATH ];
BOOL bRemote = FALSE;
DWORD access = 0;
DWORD dwSize = sizeof( pReg->szName );
// Sanity Check
if ( pReg == NULL ) return FALSE;
if ( pDest == NULL ) return FALSE;
// Blank out the structure
ZeroMemory( (LPVOID)pDest, sizeof( REGENTRY ) );
// Generate key name
szKey[ 0 ] = 0x0;
strcpy( szKey, pReg->szKey );
if ( pName != NULL && pName[ 0 ] != 0x0 )
{
if ( szKey[ 0 ] != 0x0 ) strcat( szKey, "\\" );
strcat( szKey, pName );
} // end if
if ( pReg->szName[ 0 ] != 0x0 )
{
if ( szKey[ 0 ] != 0x0 ) strcat( szKey, "\\" );
strcat( szKey, pReg->szName );
} // end if
// Connect to remote computer if needed
if ( pReg->szComputer[ 0 ] != 0x0 )
{
strcpy( pDest->szComputer, pReg->szComputer );
if ( RegConnectRegistry( pReg->szComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} else if ( pComputer != NULL && pComputer[ 0 ] != 0x0 )
{
strcpy( pDest->szComputer, pComputer );
if ( RegConnectRegistry( (char*)pComputer,
pReg->hKey,
&hRoot ) != ERROR_SUCCESS ) return 0;
bRemote = TRUE;
} // end else if
// Must want the local machine
else hRoot = pReg->hKey;
// Open The Key
if( RegOpenKeyEx( hRoot, szKey, 0, KEY_ALL_ACCESS, &hKey ) != ERROR_SUCCESS )
{
// Close the remote key if open
if ( bRemote ) RegCloseKey( hRoot );
return FALSE;
} // end if
pDest->dwUser = 0;
pDest->hKey = pReg->hKey;
// Save the location of the key
strcpy( pDest->szKey, szKey );
FILETIME ft;
// Get sub-key info
if ( RegEnumKeyEx( hKey, index, pDest->szName, &dwSize,
NULL, NULL, NULL, &ft ) == ERROR_SUCCESS )
{
bRet = TRUE;
// Attempt to get sub-key info
if( RegQueryValueEx( hKey, pDest->szName, 0, &pDest->dwType,
(LPBYTE) pDest->pvoidData, &pDest->dwLength )
== ERROR_SUCCESS )
{
SetDefault( pDest );
} // end if
else
{
pDest->dwType = REG_NONE;
pDest->dwLength = 0;
} // end else
dwSize = MAX_PATH -1;
} // end if
// Close the keys
RegCloseKey( hKey );
if ( bRemote ) RegCloseKey( hRoot );
return bRet;
}