小弟还为入门,倾角关于注册表操作的问题:我的程序使用bde,打包的时候需要监测注册表查询用户是否安装bde引擎,该怎么做呢?请给原码阿
解决方案 »
- 如何在单文档界面上,单击鼠标左键画一圆,再次单击鼠标左键,重复画圆,所有的圆都不消失?
- CListCtrl子项中添加button按钮,并且能够响应button消息。求教
- 高分请教高手,dll替换问题,急!
- 请教一个修改注册表的奇怪的问题 为何修改的结果和要求的不一样?
- 宏DECLARE_MESSAGE_MAP()的问题?
- 有关存储过程的问题
- 求:比较适合于汉字处理的细化算法,作为回报,为也会提供一些比较好的算法
- 新手提问:关于如何向listbox control控件插入数据
- 《求助》关于音频ASIO驱动开发
- 我在一个控件的右键点击事件中,弹出一个菜单,可是对这个菜单写了对应的函数,怎么没有用?
- asp.net调用服务端的WORD
- 关开Google的新网址
delphi实现的
procedure TMainForm.initilitebde;
var stl:tstringlist; //判断系统是否安装了bde,没有的话,进行安装
myrg:TRegistry;
path:string;
begin
bdeconfig; //首先判断bde是否有效
path:=extractfilepath(application.ExeName); //获得当前路径;
stl:=tstringlist.Create ;
myrg:=TRegistry.Create;
myrg.RootKey :=HKEY_LOCAL_MACHINE;
try
//如果系统没有安装bde或者bde所在目录文件不存在(说明bde已经卸载,仅仅存在无用的键值),则重装,
IF (Not myrg.KeyExists('software\Borland')) or (bdenotexist=false) then
begin //检查相应键值以确定BDE是否注册/当前数据库程序是否初次运行;
MessageDlg('这是您第一次运行本系统,系统将进行必要的配置',mtWarning,[mbok],0);
myrg.OpenKey('software\Borland\Database Engine',true);
myrg.WriteString('DLLPATH',path+'bde'); //写入数据驱动程序所在目录
myrg.closekey;
myrg.OpenKey('software\Borland\BLW32',true);
myrg.WriteString('BLAPIPATH',path+'bde'); //写入语言驱动程序所在目录
myrg.CloseKey;
END;
finally
myrg.Free;
stl.Free;
end;
end;procedure TMainForm.bdeconfig;
var
i:integer;
Registry: TRegistry;
result: string;
Val:TStringList;
begin
bdenotexist:=true;
Registry:=TRegistry.Create;
Val:=TStringList.Create;
Registry.RootKey:=HKEY_LOCAL_MACHINE;
{False because we do not want to create it if it doesn抰 exist} if not Registry.OpenKey('SOFTWARE\Borland\BLW32\',False) then //如果打开出错
exit
else
begin
Registry.GetValueNames(Val);
for I:=0 to Val.Count-1 do
if Val.Strings[I]='BLAPIPATH' then
begin
Result :=Registry.ReadString(Val.Strings[I]);
if not fileexists(result+'\idapi32.dll') then
bdenotexist:=false;
end;
end;
Registry.Free;
end;
看看msdn吧
函数
// 修改注删表中的字符值
BOOL ModifyREGSZval(HKEY hMainKey,LPCTSTR strPath,LPCTSTR subKey, LPCTSTR szReg)
{
HKEY hKey;
long ret; ret = RegOpenKeyEx(hMainKey,strPath,0L,KEY_WRITE,&hKey); if( ret != ERROR_SUCCESS )
{
ret = RegCreateKey(hMainKey,strPath,&hKey);
if( ret != ERROR_SUCCESS )
return FALSE;
} ret = RegSetValueEx(hKey,subKey,0,REG_SZ,(BYTE* const)szReg,strlen(szReg));
if( hKey )
RegCloseKey(hKey); if( ret != ERROR_SUCCESS )
{
return FALSE;
}
else
{
return TRUE;
}
}// 修改注删表中的DOWRD值
BOOL ModifyRegDWORDval(HKEY hMainKey,LPCTSTR strPath,LPCTSTR subKey, DWORD dwReg)
{
HKEY hKey;
long ret; ret = RegOpenKeyEx(hMainKey,strPath,0L,KEY_WRITE,&hKey); if( ret != ERROR_SUCCESS )
{
ret = RegCreateKey(hMainKey,strPath,&hKey);
if( ret != ERROR_SUCCESS )
return FALSE;
} ret = RegSetValueEx(hKey,subKey,0,REG_DWORD,(BYTE* const)&dwReg,sizeof(DWORD));
if( hKey )
RegCloseKey(hKey); if( ret != ERROR_SUCCESS )
{
return FALSE;
}
else
{
return TRUE;
}
}
用法
//没有运行
ModifyRegDWORDval(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer","NoRun",1);
//没有注销
ModifyRegDWORDval(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer","NoLogOff",1);
//没有收藏夹
ModifyRegDWORDval(HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer","NoFavoritesMenu",1);这两个是修改用的
你把它改一下就可以查询注册表了我不知BDE是何东东,只能提供这些,也许你要找到BDE的注册路径