Pb如何判断OCX控件是否注册?
OCX注册后(例:Regsvr32 pdfview.ocx)会在注册表中留下信息:
HKEY_CLASSES_ROOT\CLSID\{433268D7-2CD4-43E6-AA24-2188672E7252}\TypeLib
HKEY_CLASSES_ROOT\CLSID\{433268D7-2CD4-43E6-AA24-2188672E7252}\InprocServer32
64位系统在Wow6432Node:
HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{433268D7-2CD4-43E6-AA24-2188672E7252}\TypeLib
HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{433268D7-2CD4-43E6-AA24-2188672E7252}\InprocServer32
示例代码:
string ls_temp,ls_path
integer li_ret
li_ret = RegistryGet("HKEY_CLASSES_ROOT\CLSID\{433268D7-2CD4-43E6-AA24-2188672E7252}\TypeLib", "", RegString!, ls_temp) //返回1已注册
if li_ret = 1 then
li_ret = RegistryGet("HKEY_CLASSES_ROOT\CLSID\{433268D7-2CD4-43E6-AA24-2188672E7252}\InprocServer32", "", RegString!, ls_path) //返回控件文件路径
Else
RUN( “Regsvr32.exe pdfview.ocx” )
end if
如何查询控件的CLSID值?
在pb9中从Workspace页切换到Components页,展开+ActiveX Controls、+Controls找到Pdfview OCX控件,右击鼠标弹出菜单,点击Proerties菜单项,可以查找到该控件的CLSID、Path。
如何取得系统已安装文件的路径?
int li_rc
string ls_runpath
li_rc = RegistryGet( "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe", "", RegString!, ls_runpath)