打包使用Mscomm开发的串口程序,在开发的机子上能运行,在其它的没装VC的机子上却出现“创建MSComm控件失败”的错误,
开始以为是Mscomm32.ocx 控件没有注册的原因,
运行 regsvr32.exe Mscomm32.ocx 后提示控件注册成功,却还是出现“创建MSComm控件失败”
查网上的资料,说要手动在注册表里添加如下内容
HKEY_CLASSES_ROOT\Licenses,在其中添加主键
4250E830-6AC2-11cf-8ADB-00AA00C00905 并将内容设置为: kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun
添加后问题解决。但不可能让每个安装的用已手动操作一遍注册表,应该在安装的时候自动添加这条注册信息
下面是我对installShield中Scripts的修改:
增加如下函数
function MscommReg()
number nRootKey,nType,nSize;
string szKey,szNumName,szNumValue,szClass;
begin
//修改注册表
nRootKey = HKEY_CLASSES_ROOT;
RegDBSetDefaultRoot(nRootKey); //置根为nRootKey
//注册子项
szKey="Licenses\\4250E830-6AC2-11cf-8ADB-00AA00C00905\\";
if RegDBKeyExist(szKey) < 0 then
//不存在,则创建这个项
RegDBCreateKeyEx(szKey,"");
endif;
//初始化每个键的公共值
nType=REGDB_STRING;
nSize=-1;
szNumName="";
szNumValue="kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun";
RegDBSetKeyValueEx(szKey,szNumName,nType,szNumValue,nSize);
end;
添加函数原型说明
prototype MscommReg();
在安装程序的最后调用
program
Disable( BACKGROUND );
CheckRequirements();
SetupInstall();
SetupScreen();
if (ShowDialogs()<0) goto end_install;
if (ProcessBeforeDataMove()<0) goto end_install;
if (MoveFileData()<0) goto end_install;
if (ProcessAfterDataMove()<0) goto end_install;
if (SetupRegistry()<0) goto end_install;
if (SetupFolders()<0) goto end_install;
MscommReg();
end_install:
CleanUpInstall();
// If an unrecoverable error occurred, clean up the partial installation.
// Otherwise, exit normally.
if (bInstallAborted) then
abort;
endif;
endprogram