如果已安装Windows SDK、Windows Mobile SDK且默认包含这些目录编译源代码没有问题。由于一些改动需要版本管理发现Build Agent运行失败,考虑到迁移各方面原因还是决定修改调用部分。

首先移除项目几个配置版本Linker里的riched20.lib,之后打开UIRichEdit.cpp定位到如下源代码:

// Create Text Services component
if(FAILED(CreateTextServices(NULL, this, &pUnk)))
    goto err;

我们需要将Riched20.dll动态加载进来,CreateTextServices的函数原型如下:

HRESULT CreateTextServices(IUnknown*, IUnknown*, IUnknown*)

修改代码如下,需要注意在获取到ITextServices接口指针后不能立刻调用FreeLibrary释放Riched20.dll的模块句柄,而是在析构函数里:

typedef HRESULT(_stdcall *CTSFunc)(IUnknown *punkOuter, ITextHost *pITextHost, IUnknown **ppUnk);
CTSFunc ctsFunc = NULL;
auto hRiched20 = LoadLibrary(_T("Riched20.dll"));

if (NULL == hRiched20)
    goto err;
else
{
    ctsFunc = (CTSFunc)GetProcAddress(hRiched20, "CreateTextServices");

    if (NULL == ctsFunc)
        goto err;
}

if (FAILED(ctsFunc(NULL, this, &pUnk)))
    goto err;

相关文章:

  • 2022-12-23
  • 2021-11-28
  • 2021-05-19
  • 2022-12-23
  • 2021-07-05
  • 2021-11-05
猜你喜欢
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2021-10-24
  • 2022-12-23
  • 2021-06-29
相关资源
相似解决方案