首页 文章

使用C Builder时,VC Dll在Windows XP Sp3上不起作用

提问于
浏览
0

我在Visual Studio 2013中创建了VC Dll .

extern "C"  int  __declspec(dllexport) __cdecl ConvertImageToText(char* dataPath, char* imageFilePath, char* captchaCode)
{
  // to do 
  return 0;
}

我正在使用Borland C Builder 6 .

HMODULE dllHandle = LoadLibrary("Captcha.dll");
  int (__cdecl *ConvertImageToText)(char*,char*,char*);
  ConvertImageToText =(int (__cdecl *)(char*,char*,char*))GetProcAddress(dllHandle, "ConvertImageToText");
  if (ConvertImageToText != NULL )
  {
    ConvertImageToText("","","");
  }else
  {
   ShowMessage("ConvertImageToText pointer not found !");
  }

它在win7 / 8 / 8.1中运行良好 . 没有任何问题 .

但是在windows xp sp3上找不到ConvertImageToText的指针 .

我已将VC Dll Project“Platform Toolset”更改为“Visual Studio 2013 - Windows XP(v120_xp)” . 没有任何改动 .

我检查了Visual C Redistributable包 . 已安装

有什么建议吗?

2 回答

  • 1

    您需要按照文档中的描述实施正确的错误检查 .

    • 测试 LoadLibrary 的返回值 . 值 NULL 表示失败 . 如果是这样,请调用 GetLastError 以获取扩展错误详细信息 . E.测试 GetProcAddress 的返回值 . 值 NULL 表示失败 . 如果是这样,请调用 GetLastError 以获取扩展错误详细信息 .

    可能 LoadLibrary 失败,因为您的DLL链接到未安装在目标计算机上的运行时,或者因为您的DLL链接到XP上不存在的Win32 API函数 .

    如果你不能从这里开始工作,你可以使用Dependency Walker进行额外的调试 . 在配置文件模式下使用它来调试加载器尝试加载DLL . 这将揭示足够的信息来诊断问题 .

  • 2

    我安装了redist版本 . 有效 .

    enter image description here

相关问题