用于MSDE分发的INSTALLSHIELD教本

来源:互联网 发布:刻字机是什么端口 编辑:程序博客网 时间:2024/05/01 16:34
安装数据库:

export prototype mydb_installed();
function mydb_installed()  
string szcommand,szcmdline;
begin     
szcommand = supportdir^"sql2ksp4////msde"^"setup.exe";
longpathtoshortpath(szcommand);
szcmdline =" blanksapwd=1 sapwd=//""+svsapassword+"//" securitymode=sql  reboot=reallysuppress /qn";
   longpathtoshortpath(szcmdline);  
   // 安装 mydb 数据库     
   sdshowmsg("正在安装 mydb 数据库...", true);
    if (launchappandwait(szcommand, szcmdline, wait) < 0) then
         messagebox ("mydb数据库安装失败!",severe);
         sdshowmsg("正在安装 mydb 数据库...", false);
         // 删除数据文件
         deletedir(supportdir ^ "sql2ksp4", root);
         abort;
    endif;
    deletedir(supportdir ^ "sql2ksp4", root);
    sdshowmsg("正在安装 mydb 数据库...", false);
end;

检测数据库是否存在

prototype checksql(); 
function checksql()
bool bsuccess;
number ntype, nvsize;
string szver; 
string szsetupver, szsetuppath,szsqlpath;
begin
  regdbsetdefaultroot ( hkey_local_machine );
  szsetuppath = "software////microsoft////mssqlserver////setup"; 
  szsetupver = "software////microsoft////mssqlserver////mssqlserver////currentversion";
  //获取sql server版本  
  ntype = regdb_string;
  if (regdbgetkeyvalueex ( szsetupver, "currentversion" , ntype , szver , nvsize ) < 0) then  
   bsuccess = false;
  else
   //获取sql server安装路径
   if (regdbgetkeyvalueex ( szsetuppath, "sqlpath" , ntype , szsqlpath , nvsize ) < 0) then
    bsuccess = false; 
   else
    bsuccess = true;
   endif;
  endif;
  return bsuccess;
end;