LoadLibrary fails in 64 bit O.S.

Hi,
I am using Delphi5. I have used LoadLibrary to load a dll which works fine in all kinds of Win O.S except 64 bit O.S. Handle returned by LoadLibrary is 0(zero). I have tried to trace the problem using GetLastError and FormatMessage. But GetlastError also returns 0 (Zero).


Why so? Is there any setting I need to do?

Plz reply.

Comments

  • : Hi,
    : I am using Delphi5. I have used LoadLibrary to load a dll which works fine in all kinds of Win O.S except 64 bit O.S. Handle returned by LoadLibrary is 0(zero). I have tried to trace the problem using GetLastError and FormatMessage. But GetlastError also returns 0 (Zero).
    :
    :
    : Why so? Is there any setting I need to do?
    :
    : Plz reply.
    :
    :
    The LoadLibrary(), which is natively used in the Windows unit, is loaded from kernel32.dll, a 32-bit library loader. Since the entry codes will probably (don't know for sure) be different for 32-bit and 64-bit, the LoadLibrary() fails with an unknown error (forward compatibility is still a bit of a problem). A solution might be to import the LoadLibrary() from the 64-bit kernel.
  • : : Hi,
    : : I am using Delphi5. I have used LoadLibrary to load a dll which works fine in all kinds of Win O.S except 64 bit O.S. Handle returned by LoadLibrary is 0(zero). I have tried to trace the problem using GetLastError and FormatMessage. But GetlastError also returns 0 (Zero).
    : :
    : :
    : : Why so? Is there any setting I need to do?
    : :
    : : Plz reply.
    : :
    : :
    : The LoadLibrary(), which is natively used in the Windows unit, is loaded from kernel32.dll, a 32-bit library loader. Since the entry codes will probably (don't know for sure) be different for 32-bit and 64-bit, the LoadLibrary() fails with an unknown error (forward compatibility is still a bit of a problem). A solution might be to import the LoadLibrary() from the 64-bit kernel.
    :
    -----------------------------------------------------------------------

    Thanks for reply.
    I have placed GetLastError at wrong place. Now I have placed GetLastError just after the call to LoadLibrary(). So It returns error code 193 which according to MSDN means 'is not a valid Win32 application'. Also I have treid to load some other Dll which I have made. I can load that one. But the problem is in the previous one which is not mine.

    Now you can understand the whole problem. Do you have any better suggession ? Mean while I am trying your solution.
  • : : : Hi,
    : : : I am using Delphi5. I have used LoadLibrary to load a dll which works fine in all kinds of Win O.S except 64 bit O.S. Handle returned by LoadLibrary is 0(zero). I have tried to trace the problem using GetLastError and FormatMessage. But GetlastError also returns 0 (Zero).
    : : :
    : : :
    : : : Why so? Is there any setting I need to do?
    : : :
    : : : Plz reply.
    : : :
    : : :
    : : The LoadLibrary(), which is natively used in the Windows unit, is loaded from kernel32.dll, a 32-bit library loader. Since the entry codes will probably (don't know for sure) be different for 32-bit and 64-bit, the LoadLibrary() fails with an unknown error (forward compatibility is still a bit of a problem). A solution might be to import the LoadLibrary() from the 64-bit kernel.
    : :
    : -----------------------------------------------------------------------
    :
    : Thanks for reply.
    : I have placed GetLastError at wrong place. Now I have placed GetLastError just after the call to LoadLibrary(). So It returns error code 193 which according to MSDN means 'is not a valid Win32 application'. Also I have treid to load some other Dll which I have made. I can load that one. But the problem is in the previous one which is not mine.
    :
    : Now you can understand the whole problem. Do you have any better suggession ? Mean while I am trying your solution.
    :
    You could try to use LoadLibraryEx() and specify, that the application should not run the entry codes.
    Alternatively, this article might provide an answer if the dll is 16-bit: http://www.thedelphimagazine.com/samples/thunk/article.htm
  • : : : : Hi,
    : : : : I am using Delphi5. I have used LoadLibrary to load a dll which works fine in all kinds of Win O.S except 64 bit O.S. Handle returned by LoadLibrary is 0(zero). I have tried to trace the problem using GetLastError and FormatMessage. But GetlastError also returns 0 (Zero).
    : : : :
    : : : :
    : : : : Why so? Is there any setting I need to do?
    : : : :
    : : : : Plz reply.
    : : : :
    : : : :
    : : : The LoadLibrary(), which is natively used in the Windows unit, is loaded from kernel32.dll, a 32-bit library loader. Since the entry codes will probably (don't know for sure) be different for 32-bit and 64-bit, the LoadLibrary() fails with an unknown error (forward compatibility is still a bit of a problem). A solution might be to import the LoadLibrary() from the 64-bit kernel.
    : : :
    : : -----------------------------------------------------------------------
    : :
    : : Thanks for reply.
    : : I have placed GetLastError at wrong place. Now I have placed GetLastError just after the call to LoadLibrary(). So It returns error code 193 which according to MSDN means 'is not a valid Win32 application'. Also I have treid to load some other Dll which I have made. I can load that one. But the problem is in the previous one which is not mine.
    : :
    : : Now you can understand the whole problem. Do you have any better suggession ? Mean while I am trying your solution.
    : :
    : You could try to use LoadLibraryEx() and specify, that the application should not run the entry codes.
    : Alternatively, this article might provide an answer if the dll is 16-bit: http://www.thedelphimagazine.com/samples/thunk/article.htm
    :
    ------------------------------------------------------------------------

    Hi Zibadian,
    I tried LoadLibraryEx but it also fails on 64 bit machine with same error code i.e. 193. As far as the link ; you have provided ;is concerned it is complicated. I am trying.

    By the way thanks for your co-operation and help.

    Please let me know if you have other solution.

    Bye.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories