home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 February
/
Chip_2002-02_cd1.bin
/
sharewar
/
apaths
/
APSOURCE.ZIP
/
GetPString.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-03-26
|
2KB
|
72 lines
/* GetPString - March 26th, 2001
**
** Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
**
** This function returns the value associated with the specified
** registry key.
**
** Called: section = Registry section to search.
** label = Value to look for.
** def = Default to return if not found.
** value = buffer to hold returned value.
** size = size of "buffer" above.
**
** Returns: TRUE upon success, or FALSE if an error exists.
**
** Notes: This routine searchs the following key:
**
** HKEY_LOCAL_MACHINE
** Software
** Microsoft
** Windows
** CurrentVersion
** AppPaths
** Section
** Label
**
*/
#include "AppPaths.h"
extern BOOL far GetPString (LPCSTR section,LPCSTR label,LPCSTR def,LPSTR value,DWORD size)
{
auto HKEY key = NULL;
auto LONG err;
auto DWORD type;
auto char sub[PSTRING];
wsprintf (sub,"%s\\%s",REGSTR_PATH_APPPATHS,section);
err = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
sub,
NIL,
KEY_QUERY_VALUE,
&key);
if (err != ERROR_SUCCESS) {
lstrcpy (value,def);
return (TRUE);
}
err = RegQueryValueEx (key,
label,
NIL,
&type,
(LPBYTE) value,
&size);
if (key) RegCloseKey (key);
if (err != ERROR_SUCCESS) {
lstrcpy (value,def);
return (TRUE);
}
return (TRUE);
}
/* end of GetPString.c - written by Gregory Braun */