home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 February
/
Chip_2002-02_cd1.bin
/
sharewar
/
apaths
/
APSOURCE.ZIP
/
GetPKeys.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-03-26
|
2KB
|
88 lines
/* GetPKeys - March 26th, 2001
**
** Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
**
** This function searches the MS Windows 95/NT System Registry,
** enumerating all AppPath key values it finds.
**
** Called: list = Handle to the ListView control to be filled.
**
** 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
** PROGRAM.EXE = d:\folder\program.exe
**
*/
#include "AppPaths.h"
extern BOOL far GetPKeys (HWND list)
{
auto HKEY key = NULL;
auto DWORD inx = NIL;
auto LV_ITEM item = { NIL };
auto LONG err;
auto DWORD size;
auto char sub[PSTRING];
auto char value[KSTRING];
auto char folder[PSTRING];
auto char path[KSTRING];
lstrcpy (sub,REGSTR_PATH_APPPATHS);
err = RegOpenKeyEx (HKEY_LOCAL_MACHINE,
sub,
NIL,
KEY_READ,
&key);
if (err != ERROR_SUCCESS)
return (FALSE);
ListView_DeleteAllItems (list);
do {
size = KSTRING;
if ((err = RegEnumKeyEx (key,inx,value,&size,NULL,NULL,NULL,NULL)) != ERROR_SUCCESS) {
inx++;
continue;
}
item.mask = LVIF_TEXT;
item.iItem = inx;
item.iSubItem = COLUMN_1;
item.pszText = value;
ListView_InsertItem (list,&item);
GetPString (value,BLANK_STR, BLANK_STR,folder, PSTRING);
GetPString (value,"Path", BLANK_STR,path, KSTRING);
ListView_SetItemText (list,inx,COLUMN_2,folder);
ListView_SetItemText (list,inx,COLUMN_3,path);
inx++;
} while (err != ERROR_NO_MORE_ITEMS);
if (key) RegCloseKey (key);
return ((inx) ? TRUE : FALSE);
}
/* end of GetRKeys.c - written by Gregory Braun */