home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 February
/
Chip_2002-02_cd1.bin
/
sharewar
/
apaths
/
APSOURCE.ZIP
/
GetRKeys.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-03-26
|
2KB
|
83 lines
/* GetRKeys - 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 Run 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 follow key:
**
** HKEY_LOCAL_MACHINE || HKEY_CURRENT_USER
** Software
** Microsoft
** Windows
** CurrentVersion
** Run
** Title = d:\folder\program.exe /flags
**
*/
#include "AppPaths.h"
extern BOOL far GetRKeys (HWND list,BOOL user)
{
auto HKEY key = NULL;
auto DWORD inx = NIL;
auto LV_ITEM item = { NIL };
auto LONG err;
auto DWORD size;
auto DWORD len;
auto char sub[PSTRING];
auto char value[PSTRING];
auto char run[PSTRING];
lstrcpy (sub,REGSTR_PATH_RUN);
err = RegOpenKeyEx ((user) ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE,
sub,
NIL,
KEY_READ,
&key);
if (err != ERROR_SUCCESS)
return (FALSE);
ListView_DeleteAllItems (list);
do {
size = PSTRING;
len = PSTRING;
if ((err = RegEnumValue (key,inx,value,&size,NULL,NULL,(LPBYTE) run,&len)) != ERROR_SUCCESS) {
inx++;
continue;
}
item.mask = LVIF_TEXT;
item.iItem = inx;
item.iSubItem = COLUMN_1;
item.pszText = value;
ListView_InsertItem (list,&item);
ListView_SetItemText (list,inx,COLUMN_2,run);
inx++;
} while (err != ERROR_NO_MORE_ITEMS);
if (key) RegCloseKey (key);
return ((inx) ? TRUE : FALSE);
}
/* end of GetRKeys.c - written by Gregory Braun */