简体   繁体   English

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

[英]VC++ Dll Not Working On Windows XP Sp3 When Using C++ Builder

I have created VC++ Dll in Visual Studio 2013. 我已经在Visual Studio 2013中创建了VC ++ Dll。

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

I'm using in Borland C++ Builder 6 like that. 我在这样的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 !");
  }

it's working well in win7/8/8.1.there isn't any problem. 在win7 / 8 / 8.1中运行良好。没有任何问题。

But can't find pointer of ConvertImageToText on windows xp sp3. 但是在Windows XP SP3上找不到ConvertImageToText的指针。

I have changed VC++ Dll Project "Platform Toolset" as "Visual Studio 2013 - Windows XP (v120_xp)".nothing not changed. 我已将VC ++ Dll项目“平台工具集”更改为“ Visual Studio 2013-Windows XP(v120_xp)”。没有任何更改。

I have checked Visual C++ Redistributable packages.All installed 我已经检查了Visual C ++可再发行组件包。

Any sugguestions ? 有什么建议吗?

You need to implement proper error checking as described by the documentation. 您需要按照文档中的说明实施正确的错误检查。

  1. Test the return value of LoadLibrary . 测试LoadLibrary的返回值。 A value of NULL indicates failure. NULL表示失败。 If that is so, call GetLastError for extended error details. 如果是这样,请调用GetLastError以获取扩展的错误详细信息。 E. Test the return value of GetProcAddress . E.测试GetProcAddress的返回值。 A value of NULL indicates failure. NULL表示失败。 If that is so, call GetLastError for extended error details. 如果是这样,请调用GetLastError以获取扩展的错误详细信息。

Likely LoadLibrary is failing because your DLL is linked to a runtime that is not installed on the target machine, or because your DLL is linked to Win32 API functions that do not exist on XP. LoadLibrary可能失败,因为您的DLL链接到目标计算机上未安装的运行时,或者因为您的DLL链接到XP上不存在的Win32 API函数。

If you cannot work it out from here you can use Dependency Walker for extra debugging. 如果无法从此处解决问题,则可以使用Dependency Walker进行额外的调试。 Use it in profile mode to debug the loader's attempt to load the DLL. 在概要文件模式下使用它可以调试加载程序尝试加载DLL的尝试。 That will reveal enough information to diagnose the problem. 这将揭示足够的信息来诊断问题。

I have installed that redist release. 我已经安装了该redist版本。 it worked. 有效。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM