📄 registry.cpp
字号:
/*____________________________________________________________________________*\
*
Copyright (c) 1997-2003 John Roy, Holger Zimmermann. All rights reserved.
These sources, libraries and applications are
FREE FOR COMMERCIAL AND NON-COMMERCIAL USE
as long as the following conditions are adhered to.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
3. The name of the author may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHORS OR ITS CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
*____________________________________________________________________________*|
*
* $Source: /cvsroot/pi3web/Pi3Web_200/Source/EnhPi3/Registry.cpp,v $
* $Date: 2003/05/13 18:41:59 $
*
Description:
\*____________________________________________________________________________*/
/* $SourceTop:$ */
#include <assert.h>
#include <windows.h>
#include <regstr.h>
#include "Common.h"
//#define PI3WEB_REG_PATH "SOFTWARE\\JohnRoy\\Pi3Web\\CurrentVersion"
#define RPATH(x) (REGSTR_PATH_APPPATHS##x)
#define PI3WEB_REG_PATH RPATH("\\EnhPi3.exe")
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
int REG_isInstalled()
{
HKEY hKey;
if ( ::RegOpenKey(
HKEY_LOCAL_MACHINE,
PI3WEB_REG_PATH,
&hKey )!=ERROR_SUCCESS )
{ return 0; };
::RegCloseKey( hKey );
return 1;
}
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
int REG_add()
{
HKEY hKey = 0;
DWORD dwDisp;
const char *pExe;
const char *pBinDir;
if ( ::RegCreateKeyEx(
HKEY_LOCAL_MACHINE, // handle of an open key
PI3WEB_REG_PATH, // address of subkey name
0, // reserved
"", // address of class string
0, // special options flag
KEY_ALL_ACCESS, // desired security access
NULL, // address of key security structure
&hKey, // address of buffer for opened handle
&dwDisp // address of disposition value buffer
)!=ERROR_SUCCESS )
{ goto an_error; };
pExe = AD_lookupValue( __pConfig, "General", "ExePath" );
assert( pExe );
if ( ::RegSetValueEx(
hKey, // handle of key to set value for
"", // address of value to set
0, // reserved
REG_SZ, // flag for value type
(const unsigned char *)pExe, // address of value data
1 // size of value data
)!=ERROR_SUCCESS )
{ goto an_error; };
pBinDir = AD_lookupValue( __pConfig, "General", "BinDir" );
assert( pBinDir );
if ( ::RegSetValueEx(
hKey, // handle of key to set value for
"Path", // address of value to set
0, // reserved
REG_SZ, // flag for value type
(const unsigned char *)pBinDir, // address of value data
1 // size of value data
)!=ERROR_SUCCESS )
{ goto an_error; };
::RegCloseKey( hKey );
return 1;
an_error:
if ( hKey ) { ::RegCloseKey( hKey ); };
return 0;
}
/*____________________________________________________________________________*\
*
Function:
Synopsis:
Description:
\*____________________________________________________________________________*/
int REG_delete()
{
LONG lRet = ::RegDeleteKey( HKEY_LOCAL_MACHINE, PI3WEB_REG_PATH );
if ( lRet!=ERROR_SUCCESS )
{ return 0; };
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -