Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

DLLImport in C++

Back to Forum: Tech Off
  • User profile image
    brussell

    I have a utility that I am writing in C++.NET.
    I wrote three MFC DLLs.

    I am trying to inlude and use the DLLs in the utility.

    namespace dbBld91
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder91.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII( int iType );
    }
    namespace dbBld90
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder90.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII( int iType );
    }
    namespace dbBld80
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder80.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII( int iType );
    }

    namespace SymbolDatabaseGenerator
    {
        ...
        dbBld91::BuildASCII( iVendor );
        ...
    }

    No matter what namespace I tell it to call BuildASCII() from, it uses the DLL that is imported last (currently dbBld80).

    Any ideas how to fix this? I need to use all the DLLs.

  • User profile image
    Sven Groot

    Why not just use the old fashioned way with LoadLibrary and GetProcAddress?

  • User profile image
    brussell

    Sven Groot wrote:
    Why not just use the old fashioned way with LoadLibrary and GetProcAddress?


    Because this was the first way I found. Not any real reason.


    Found the solution.
    I can name the function whatever I want. So I just named them differently.
    Thanks though!

    namespace dbBld91
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder91.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII91( int iType );
    }
    namespace dbBld90
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder90.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII90( int iType );
    }
    namespace dbBld80
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder80.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII80( int iType );
    }

    I can rewrite that to be:
    namespace dbBld
    {
        using namespace System::Runtime::InteropServices;
        [DllImport("dbBuilder91.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII91( int iType );

        [DllImport("dbBuilder90.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII90( int iType );

        [DllImport("dbBuilder80.dll", EntryPoint = "BuildASCII")]
        extern "C" void BuildASCII80( int iType );
    }

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.