欢迎光临
我们一直在努力

脱离开发主机在其他电脑里独立运行PB程序-数据库专栏,其他相关

建站超值云服务器,限时71元/月

我发现很多的同志不知道如何脱离自己的开发主机,在别人的计算机上独立运行。其实很简单,关键在于怎样在注册表中自动注册你的asa数据源。
现在我把以前我发的帖子再发一次。希望对初学者有帮助!

大家用pb编好的程序,用安装软件(例如:installshile,installwais,creatinstall等)安装打包后,在用户机上一使用就出现数据库没有连接等问题,原因就是我们没有在windows的注册表中注册我们的数据源。怎样注册呢?现在我来说一下:
首先我们用安装软件把我们的主运行文件要注册到注册表中的hkey_local_machine oftware\microsoft\windows\currentversion\app paths里,在这里我的主应用程序是idmis.exe,数据库文件是wts.db。数据库是pb8自带的asa 7数据库,原来的asa 5数据库的文件和asa 7不一样,要注意。

“注册表注册数据源”(w_regdatasorce)的open事件:
string ls_keyname
string ls_valuename
string ls_value
int li_a,li_a1,li_a2,li_a3,li_a4,li_a5,li_a6,li_a7
string ls_dbdriver,ls_dbstart,ls_dblocation,ls_wtslocation,ls_dbname,ls_db_dbeng7
//获取本软件的目录,并保存在ls_location里
registryget(“hkey_local_machine oftware\microsoft\windows\currentversion\app paths\idmis.exe”,”path”,ls_wtslocation)
ls_dbdriver=ls_wtslocation+”\dbodbc7.dll”
ls_db_dbeng7=ls_wtslocation+”\dbeng7.exe”
ls_dbname=ls_wtslocation+”\wts.db”
ls_dbstart=ls_wtslocation+”\dbeng7.exe -d -c8m”
if not (fileexists(ls_dbdriver) and fileexists(ls_db_dbeng7)) then
 messagebox(“错误!”,”没有安装sybase asa 7数据库,或者没有数据库主控文件!”,stopsign!)
 return
end if

//设置odbc\odbcinst.ini\odbc drivers
li_a=registryset(“hkey_local_machine oftware\odbc\odbcinst.ini\odbc drivers”, &
      +”sybase asa 7(函授学生信息查询数据库文件)”, &
      +regstring!,”installed”)
     
if li_a=-1 then
 messagebox(“错误!”,”应用程序无法在注册表中设置odbc drivers,请与作者联系!”,stopsign!)
 return
end if

//设置….odbc\odbcinst.ini
li_a1=registryset(“hkey_local_machine oftware\odbc\odbcinst.ini ybase asa 7(函授学生信息查询数据库文件)”, &
      +”cptimeout”,regstring!,”not pooled”)
     
li_a2=registryset(“hkey_local_machine oftware\odbc\odbcinst.ini ybase asa 7(函授学生信息查询数据库文件)”, &
      +”driver”,regstring!,ls_dbdriver)
     
li_a3=registryset(“hkey_local_machine oftware\odbc\odbcinst.ini ybase asa 7(函授学生信息查询数据库文件)”, &
      +”setup”,regstring!,ls_dbdriver)

if li_a1=-1 or li_a2=-1 or li_a3=-1 then
 messagebox(“错误!”,”应用程序无法设置注册表中odbcinst.ini,请与作者联系!”,stopsign!)
 return
end if

//设置odbc data source(odbc数据源),wts为数据源名称
li_a=registryset(“hkey_local_machine oftware\odbc\odbc.ini\odbc data sources”, &
      +”wts”,regstring!,”sybase asa 7(函授学生信息查询数据库文件)”)
     
if li_a=-1 then
 messagebox(“错误!”,”应用程序无法设置注册表odbc data source,请与作者联系!”,stopsign!)
 return
end if

li_a=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,driver,regstring!,ls_dbdriver)
li_a1=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,start,regstring!,ls_dbstart)
li_a2=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,autostop,regstring!,yes)
li_a3=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,databasefile,regstring!,ls_dbname)
li_a4=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,databasename,regstring!,wts)
li_a5=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,enginename,regstring!,函授学生信息查询系统)
li_a6=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,pwd,regstring!,sql)
li_a7=registryset(hkey_local_machine oftware\odbc\odbc.ini\wts,uid,regstring!,dba)

if li_a=-1 or li_a2=-1 or li_a3=-1 or li_a4=-1 or li_a1=-1 or li_a5=-1  or li_a6=-1  or li_a7=-1  then
messagebox(错误,应用程序无法设置odbc.ini,系统将终止运行!,stopsign!)
return
end if

如果你要设置用户级的odbc连接请对下面的键值进行设置:
置hkey_current_user oftware\odbc\odbc.ini
内容都是一样的。看看自己windows中的odbc设置,有没有变化??
好人作到底!我在付上脱离环境后所需的.dll文件:
pbvm8.dll  //pb虚拟机
pbdwe8.dll  //dw引擎
pbodb8.dll  //odbc配置文件
pbodb8.inf  //同上
dbodbc7.dll  //数据库连接文件
dbeng7.exe  //数据库启动文件。如果你是网络运行,那么就是dbserv7.exe
libjcc.dll  //我不知道  :-p
如果你有rich text对象控件,则: pbrtc.dll
如果你有ole对象,则:pbole7.dll

好了没有,你成功了吗??

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 脱离开发主机在其他电脑里独立运行PB程序-数据库专栏,其他相关
分享到: 更多 (0)