1。代碼如下:
string datafile,odbc_driver
int reg_result
integer odbc_init
odbc_init=profileint("system.ini","start","first",1)
ulong ul_n,ul_m
ul_n=25
ul_m=0
//第一次運行時進行注冊
//if odbc_init= 1 then //如果等於1 則進行注冊
//判斷系統是否已經安裝Access
string ls_sys,ls_install
ls_sys="HKEY_LOCAL_MacHINE\Software\ODBC\ODBCINST.INI\ODBC DRIVERS"
RegistryGet(ls_sys, "Microsoft Access Driver (*.mdb)", RegString!,ls_install)
if trim(ls_install)<> "Installed" then
messagebox("錯誤","未安裝Microsoft Access Driver")
halt
end if
environment env // holds environment information
string startupfile // holds name of start-up file
/* Get the environment information */
IF ( GetEnvironment(env) <> 1 ) THEN
MessageBox( "Application: Open", "Unable to get environment information.~n Halting ..." )
HALT
END IF
/* Select start-up file by Operating system */
CHOOSE CASE env.OSType
CASE Windows!
if directoryexists('c:\Windows\System') then
odbc_driver="c:\Windows\System\odbcjt32.dll"
elseif directoryexists('d:\Windows\System') then
odbc_driver="d:\Windows\System\odbcjt32.dll"
elseif directoryexists('e:\Windows\System') then
odbc_driver="e:\Windows\System\odbcjt32.dll"
elseif directoryexists('f:\Windows\System') then
odbc_driver="f:\Windows\System\odbcjt32.dll"
elseif directoryexists('g:\Windows\System') then
odbc_driver="g:\Windows\System\odbcjt32.dll"
else
messagebox('錯誤!','無法注冊ODBC!')
halt
end if
case WindowsNT!
if directoryexists("c:\WINNT\System32") then
odbc_driver="c:\WINNT\System32\odbcjt32.dll"
elseif directoryexists("d:\WINNT\System32") then
odbc_driver="d:\WINNT\System32\odbcjt32.dll"
elseif directoryexists("e:\WINNT\System32") then
odbc_driver="e:\WINNT\System32\odbcjt32.dll"
elseif directoryexists("f:\WINNT\System32") then
odbc_driver="f:\WINNT\System32\odbcjt32.dll"
elseif directoryexis