xp下开发的ocx,xp注册成功,win7下注册不成功,

再次非常的感谢”赵4老师“的网上帮助、与指导

一、xp、Win 7 环境不同引起Ado编译错误 ,解决办法

(


错误如下:

MSJRO.tlh(100) : error C2146: syntax error : missing ';'before identifier 'ConflictTables'
MSJRO.tlh(100) : error C2501: '_RecordsetPtr' : missingstorage-class or type specifiers
MSJRO.tlh(100) : error C2501: 'ConflictTables' : missingstorage-class or type specifiers
MSJRO.tlh(128) : error C2146: syntax error : missing ';'before identifier 'GetConflictTables'
MSJRO.tlh(128) : error C2501: '_RecordsetPtr' : missingstorage-class or type specifiers
MSJRO.tli(43) : error C2143: syntax error : missing ';' before'tag::id'
MSJRO.tli(43) : error C2433: '_RecordsetPtr' : 'inline' notpermitted on data declarations
MSJRO.tli(43) : error C2501: '_RecordsetPtr' : missingstorage-class or type specifiers
MSJRO.tli(43) : fatal error C1004: unexpected end of filefound

原来头文件相关代码是这样:
#if !defined(AFX_ADO2_H_INCLUDED_)
#define AFX_ADO2_H_INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
#include <afx.h>
#include <afxdisp.h>
#include <math.h>
//#include "C:\Program Files\Microsoft Analysis Services\Samples\Include\msmd.h"

#pragma warning (disable: 4146)
// CG : In order to use this code against a different version of ADO, the appropriate
// ADO library needs to be used in the #import statement
//#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename("EOF", "EndOfFile")
//#import "C:\Program Files\Common Files\System\ado\MSJRO.DLL" no_namespace

#import "msado15.dll" rename("EOF", "EndOfFile")
#import "MSJRO.DLL" no_namespace rename("ReplicaTypeEnum", "_ReplicaTypeEnum")
using namespace ADODB;


需要在路径中设置 C:\ProgramFiles\Common Files\System\ado\

解决方案:
从XP 系统中拷贝msado15.dll,msjro.dll,放入数据库头文件同目录下,修改头文件:

#import "msado15.dll" rename("EOF", "EndOfFile")
#import "MSJRO.DLL" no_namespace rename("ReplicaTypeEnum","_ReplicaTypeEnum") 

注意:红色字体部分为绝对路径,在新环境下控件还是会到对决路径下查找,由于xp、win7下的文件版本不同,而导致注册失败,提示找不到dll模块
            由于前期的失误,以后绝对不能用绝对路径来引用控件,
二、在win7、2008 r2 中ocx注册不成功的解决(有的win7、2008系统没有问题)
      1、各种注册方法都是过、即使把整个依赖文件都考到ocx同一文件夹下或系统文件夹下都无济于事。
      2、把测试电脑都安装上开发环境,编译最后到注册控件环节就死掉了,把ocx解除占用后,编译成功,但还是在注册环节不能注册
      3、用depends工具把所有问号的dll都放到系统下,注册问题依然不成功
      4、最后看到了网上微软的ado bug的说明https://support.microsoft.com/zh-cn/kb/2640696,终于清楚了,
     最终解决办法
     1、从微软官网发布的的信息读到,应该server2003中的ado不存在此问题,此问题已经拖了好长时间了,为了节约时间所以先用2003,测试注册没有问题
     2、有没有网友试过打一下win7或server2008的系统补丁包试试,以后再试试把,有测试过的网友反馈一下

你可能感兴趣的:(xp下开发的ocx,xp注册成功,win7下注册不成功,)