简体   繁体   中英

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

I have created VC++ Dll in Visual Studio 2013.

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.

  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.

But can't find pointer of ConvertImageToText on windows xp sp3.

I have changed VC++ Dll Project "Platform Toolset" as "Visual Studio 2013 - Windows XP (v120_xp)".nothing not changed.

I have checked Visual C++ Redistributable packages.All installed

Any sugguestions ?

You need to implement proper error checking as described by the documentation.

  1. Test the return value of LoadLibrary . A value of NULL indicates failure. If that is so, call GetLastError for extended error details. E. Test the return value of GetProcAddress . A value of NULL indicates failure. If that is so, call GetLastError for extended error details.

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.

If you cannot work it out from here you can use Dependency Walker for extra debugging. Use it in profile mode to debug the loader's attempt to load the DLL. That will reveal enough information to diagnose the problem.

I have installed that redist release. it worked.

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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