CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1

    Calling a DLL fonction

    I have a DLL program in C with visual c++ 5. In my DLL I have this fonction:

    extern "C" __declspec(dllexport)
    int EQeau(const char *szPath)
    {
    KEQeau EQeau;

    return EQeau.Do(szPath);
    }

    How can I call it in visual basic.

    Thanks.



  2. #2

    Re: Calling a DLL fonction

    Public Declare Function <FunctionName> & Lib "<your Dll name written in c " (<your dll's parameter if any&gt

    make a project reference to the C DLL and then declare the above in ur global module and then create a new instance for the referenced dll for eg

    set myvbdll = new <your CDLL > which is set as reference in project module

    and then call the funcion like this

    MYCDLL.<Your Function Name>

    if u have any problem with this mail me ur c function i will do it for u.


    The Ultimate Solution Providers

    Authors

    Sriman & Jayaraman

    Email : [email protected]
    [email protected]

    Hand Phone : +(6) 016 2237147 (Malaysia)

  3. #3
    Join Date
    May 1999
    Posts
    45

    Re: Calling a DLL fonction


    1) You can convert your ".h" file as idl.
    2) Compile it into a type library using midl compiler. eg. midl mydll.idl
    3) Reference that type library in VB using Project References Browse button.

    Note that your DLL need NOT be COM DLL.

    Sample code for idl is (change GUIDS for every DLL)



    [
    uuid(15D4AF61-78EC-11d3-B183-204C4F4F5020),
    helpstring("My DLL Library"),
    lcid (0x00000000),
    version(1.0)
    ]
    library MyDLLLib
    {
    importlib("stdole2.tlb");

    [
    helpstring("Declaration of functions from My DLL."),
    dllname("MyDLL.DLL")
    ]
    module MyDLLExports
    {
    // your declarations
    [
    entry("EQeau"),
    helpstring("This function does lot of work.")
    ]
    int EQeau(const char *szPath);

    // other declarations of the same dll


    }
    }





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