运行错误:372,加载控件VSFlexgrid失败。您的vsflex8.ocx版本可能已过期

问题:

我有一个troble当我编译我的计划,我另一台计算机上运行,​​我得到这个问题无法加载控制“VSFlexGrid”从vsflex8.ocx

运行时错误“372”;

无法从vsflex8.ocx加载控件'VSFlexGrid'。您的vsflex8.ocx版本可能已过时。确保您使用的是您的应用程序提供的控件版本

如何解决此问题?

解决方法:

问题原因:此错误表示该文件的较旧版本已在Windows中注册,即使较旧的文件可能不再位于计算机上。

方法:拷贝原始的vsflex8到目的计算机并注册此版本的OCX文件:

  1. 拷贝编译计算机中的vsflex8文件到目的计算机。注释:这里需要说明的是,编译的程序如果是32位,也需要将ocx文件拷贝到目标计算机的SysWOW64目录下并用64位注册方式注册后才能正常;

  2. 转到您的Windows(目标计算机)开始菜单并选择运行。

  3. 输入regsvr32 filename.ocx像:

    的Windows 32位regsvr32 C:\Windows\System32\vsflex8.ocx

    的Windows 64位regsvr32 C:\Windows\SysWOW64\vsflex8.ocx

  4. 单击确定

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用C++/CLI封装ActiveX控件VSFlexGrid的例子: 1. 在Visual Studio中创建一个新的C++/CLI类库项目。 2. 在项目中添加一个新的类,用于封装VSFlexGrid控件。 3. 在该类的头文件中,包含以下代码: ``` #pragma once namespace VSFlexGridWrapper { using namespace System::Runtime::InteropServices; [ComVisible(true)] [ClassInterface(ClassInterfaceType::AutoDispatch)] public ref class VSFlexGridWrapper { public: VSFlexGridWrapper(); void SetRowCount(int count); void SetColumnCount(int count); void SetCellText(int row, int col, System::String^ text); void SetCellBackColor(int row, int col, System::Drawing::Color color); private: // Pointer to the VSFlexGrid ActiveX control System::IntPtr vsflexgridPtr; }; } ``` 4. 在类的实现文件中,使用以下代码来初始化VSFlexGrid控件: ``` #include "stdafx.h" #include "VSFlexGridWrapper.h" namespace VSFlexGridWrapper { VSFlexGridWrapper::VSFlexGridWrapper() { // Instantiate the VSFlexGrid ActiveX control vsflexgridPtr = System::Runtime::InteropServices::Marshal::GetIUnknownForObject(gcnew AxVSFlexLib::AxVSFlexGrid()); } } ``` 5. 在实现文件中添加对VSFlexLib的引用: ``` #using <mscorlib.dll> #using <System.dll> #using <System.Drawing.dll> #using <System.Windows.Forms.dll> #using <System.ComponentModel.dll> #using <AxInterop.VSFlexLib.dll> ``` 6. 实现类中的方法,以便在外部调用: ``` void VSFlexGridWrapper::SetRowCount(int count) { AxVSFlexLib::AxVSFlexGrid^ vsflexgrid = (AxVSFlexLib::AxVSFlexGrid^)System::Runtime::InteropServices::Marshal::GetObjectForIUnknown(vsflexgridPtr); vsflexgrid->Rows = count; } void VSFlexGridWrapper::SetColumnCount(int count) { AxVSFlexLib::AxVSFlexGrid^ vsflexgrid = (AxVSFlexLib::AxVSFlexGrid^)System::Runtime::InteropServices::Marshal::GetObjectForIUnknown(vsflexgridPtr); vsflexgrid->Cols = count; } void VSFlexGridWrapper::SetCellText(int row, int col, System::String^ text) { AxVSFlexLib::AxVSFlexGrid^ vsflexgrid = (AxVSFlexLib::AxVSFlexGrid^)System::Runtime::InteropServices::Marshal::GetObjectForIUnknown(vsflexgridPtr); vsflexgrid->TextMatrix[row, col] = text; } void VSFlexGridWrapper::SetCellBackColor(int row, int col, System::Drawing::Color color) { AxVSFlexLib::AxVSFlexGrid^ vsflexgrid = (AxVSFlexLib::AxVSFlexGrid^)System::Runtime::InteropServices::Marshal::GetObjectForIUnknown(vsflexgridPtr); vsflexgrid->CellBackColor = color.ToArgb(); vsflexgrid->Redraw = true; } ``` 7. 在项目中添加对AxInterop.VSFlexLib.dll和Interop.VSFlexLib.dll的引用。 8. 在应用程序中使用该类,例如: ``` #include "stdafx.h" #include "VSFlexGridWrapper.h" using namespace VSFlexGridWrapper; int main(array<System::String ^> ^args) { VSFlexGridWrapper^ vsflexgrid = gcnew VSFlexGridWrapper(); vsflexgrid->SetRowCount(5); vsflexgrid->SetColumnCount(3); vsflexgrid->SetCellText(0, 0, "Hello"); vsflexgrid->SetCellText(0, 1, "World"); vsflexgrid->SetCellBackColor(0, 0, System::Drawing::Color::Red); return 0; } ``` 这个例子演示了如何使用C++/CLI来封装ActiveX控件VSFlexGrid,并提供了一些常用的方法来设置行数、列数、单元格文本和单元格背景颜色。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值