以下所有测试在XP系统下完成:注册APlayer.dll控件,控件的执行流程如下:
1.将控件文件拷贝到:C:\Documents and Settings\All Users\Application Data\Thunder Network\APlayer\目录下,分别为:APlayer_3.5.0.638.dll和atl71.dll.
(
注意:如果当前系统中没有(C:\Documents and Settings\All Users\Application Data\Thunder Network\)这个文件夹的话,控件注册会报错!所以:这里一定要注意Thunder Network文件夹是否存在,如果不存在,控件就无法注册,下边步骤就无法进行)
2.控件会在注册表,HKEY_CURRENT_USER\Software\Thunder Network\APlayer下建立path项,取值为:C:\Documents and Settings\All Users\Application Data\Thunder Network\APlayer\APlayer_3.5.0.638.dll,版本不同名字会有所区别.
3.注册npaplayer.dll控件.
4.查找path的值,取出path的路径信息,拷贝解码库文件到C:\Documents and Settings\All Users\Application Data\Thunder Network\APlayer\
多次测试后发现问题,关键问题找到,
如果文件夹C:\Documents and Settings\All Users\Application Data\Thunder Network不存在,控件就无法进行正常安装.
解决方法:建立文件夹,具体路径如下:C:\Documents and Settings\All Users\Application Data\Thunder Network,即可正常注册控件.
我的安装方案
控件安装:INStall.bat
@echo off
@md "C:\Documents and Settings\All Users\Application Data\Thunder Network"
@regsvr32 /s APlayer.dll
@regsvr32 /s npaplayer.dll
for /f "tokens=1,2,*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Thunder Network\APlayer" ^| find /i "Path"') do SET "pURL=%%k"
@xcopy /E /Y .\codecs\*.* "%pURL%\..\codecs\*.*"
控件卸载:UnInstall.bat
@echo off
@regsvr32 /s /u APlayer.dll
@regsvr32 /s /u npaplayer.dll
for /f "tokens=1,2,*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Thunder Network\APlayer" ^| find /i "Path"') do SET "pURL=%%k"
rd /s /q "%pURL%\..\..\..\Thunder Network"
@echo y|reg delete "HKEY_CURRENT_USER\Software\Thunder Network\" /va /f
正常的安装和卸载,保证无残留.
建议: APlayer.dll在注册时,加入Thunder Network文件路径的判断,当文件夹不存在时,先建立文件夹,然后拷贝控件到对应目录中.