home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 February
/
Chip_2002-02_cd1.bin
/
sharewar
/
apaths
/
APSOURCE.ZIP
/
MakePKey.c
< prev
next >
Wrap
C/C++ Source or Header
|
2001-03-26
|
2KB
|
84 lines
/* MakePKey - March 26th, 2001
**
** Copyright (c) 1997-2001 by Gregory Braun. All rights reserved.
**
** This function creates an AppPath system registry entry.
**
** Called: path = a pointer to the PATH data structure to
** be used as the values for this registry
** key.
**
** Returns: TRUE upon success, or FALSE if an error exists.
**
** Notes: This routine creates the following MS Windows 95/NT
** System Registry entry:
**
** HKEY_LOCAL_MACHINE
** Software
** Microsoft
** Windows
** CurrentVersion
** App Paths
** APPLICATION.EXE = d:\path\application.exe
** Path = d:\folder
*/
#include "AppPaths.h"
extern BOOL far MakePKey (LPPATH path)
{
auto HKEY key = NULL;
auto LONG err = NIL;
auto DWORD size;
auto DWORD result;
auto char sub[PSTRING];
wsprintf (sub,"%s\\%s",REGSTR_PATH_APPPATHS,path->name);
err = RegCreateKeyEx (HKEY_LOCAL_MACHINE,
sub,
NIL,
BLANK_STR,
REG_OPTION_NON_VOLATILE,
KEY_SET_VALUE,
NULL,
&key,
&result);
if (err != ERROR_SUCCESS)
return (FALSE);
if (*path->application) {
size = lstrlen (path->application) + 1;
err = RegSetValueEx (key,
BLANK_STR,
NIL,
REG_SZ,
(CONST BYTE *) path->application,
size);
}
if (*path->path) {
size = lstrlen (path->path) + 1;
err = RegSetValueEx (key,
"Path",
NIL,
REG_SZ,
(CONST BYTE *) path->path,
size);
}
RegCloseKey (key);
return ((err == ERROR_SUCCESS) ? TRUE : FALSE);
}
/* end of MakePKey.c - written by Gregory Braun */