CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Jun 2012
    Posts
    3

    How to load dll which is win32 into x64 environment

    Hi

    In VS2010, I have VC++ class in x64 enviornment, when I use
    HINSTANCE hDLL = LoadLibrary(L"test.dll"); => test.dll is win32
    hDll is NULL

    if I use
    HINSTANCE hDLL =LoadLibraryExW(L"test.dll",NULL,LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE );
    hDll has value.

    but when I run
    FUNC Setup2004;
    Setup2004 = (FUNC)GetProcAddress(hDLL, "SetUp2004");


    Setup2004 is NULL.

    And, test.dll run in win32 enviroment with above program is well.

    So, who could give me some suggestion?

    Thanks
    Angel

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How to load dll which is win32 into x64 environment

    Quote Originally Posted by AngelDES View Post
    Hi

    In VS2010, I have VC++ class in x64 enviornment,
    Is your application a 64-bit app? If so, you cannot load 32-bit DLL's into the address space of a 64-bit application.

    If it's not a 64-bit application, then call GetLastError() to determine why the DLL does not load.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Jun 2012
    Posts
    3

    Re: How to load dll which is win32 into x64 environment

    Quote Originally Posted by Paul McKenzie View Post
    Is your application a 64-bit app? If so, you cannot load 32-bit DLL's into the address space of a 64-bit application.

    If it's not a 64-bit application, then call GetLastError() to determine why the DLL does not load.

    Regards,

    Paul McKenzie
    Hi Paul
    Thanks to your reply.
    Do you have any idea about how to load 32-bit DLL's into 64-bit app?
    Because my app is 64-bit app, and I don't have this 32-bit DLL source code, so I cann't recompile this to be 64-bit.

    Thanks
    Angel

  4. #4
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,633

    Re: How to load dll which is win32 into x64 environment

    Do you have any idea about how to load 32-bit DLL's into 64-bit app?
    Modules architecture must match. To load 32-bit dll your process must be 32-bit one. I heard some people been in such a desperate situation create a 32-bit COM server wrapping their problem dlls.
    Best regards,
    Igor

  5. #5
    Join Date
    Jun 2012
    Posts
    3

    Re: How to load dll which is win32 into x64 environment

    Quote Originally Posted by Igor Vartanov View Post
    Modules architecture must match. To load 32-bit dll your process must be 32-bit one. I heard some people been in such a desperate situation create a 32-bit COM server wrapping their problem dlls.
    Hi Igor
    Thanks to your reply.
    I also heard it can use TASK class to avoid this problem, but I don't know how to use? Who does know this and could give me some suggestion?

    Thanks,
    Angel

  6. #6
    Join Date
    Dec 2008
    Posts
    144

    Re: How to load dll which is win32 into x64 environment

    Quote Originally Posted by Igor Vartanov
    I heard some people been in such a desperate situation create a 32-bit COM server wrapping their problem dlls.
    I've done this once. But I didn't have any other choice that time. Anyway it's ugly and awful.

    Quote Originally Posted by AngelDES View Post
    Who does know this and could give me some suggestion?
    It’s impossible to load 34-bit DLL into the 64-bit application. If you really need this 32-bit DLL is there any specific reason you want your application to be 64-bit?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured