GetProcAddress Fail in VC++ App while using VB Dll

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JMurugesh
    New Member
    • Nov 2007
    • 13

    GetProcAddress Fail in VC++ App while using VB Dll

    I have created a VB DLL using the code given below. And then I tried to use that DLL in an VC++ Win32 application. Where the LoadLibrary/AfxLoadLibrary were working ok. But the GetProcAddress calls always returning NULL. Can anybody help?


    VB Dll code:

    Public Function LoadResourceInt eger(ByVal theStringID As Integer) As Integer
    LoadResourceInt eger = 0
    On Error GoTo ErrMsg
    LoadResourceInt eger = 1000
    Exit Function
    ErrMsg:
    LoadResourceInt eger = 0
    MsgBox ("Resource:miss ing in MUI Resource File.") ' MUI - Multilanguage User Interface
    End Function



    VC++ Win32 App uses that VB DLL:


    typedef int (__stdcall *LoadRessString )(int argument1);

    HINSTANCE hMod;
    hMod = AfxLoadLibrary( "MUIResourceEng lish.dll");
    if(NULL == hMod)
    {
    MessageBox("Obj ect Not Created","Capti on",MB_OK);
    return;
    }
    else
    {
    LoadRessString localLoadResStr ing;
    localLoadResStr ing = (LoadRessString ) GetProcAddress( hMod,"LoadResou rceInteger");
    if(localLoadRes String == NULL)
    {
    MessageBox("Get ProcAdress Failed","Captio n",MB_OK);
    FreeLibrary( hMod);
    return;
    }
    int myResString = localLoadResStr ing(1);
    MessageBox("Suc cess","Caption" ,MB_OK);
    return ;
    }GetProcAddress (hMod,"LoadReso urceInteger");
    if(localLoadRes String == NULL)
    {
    MessageBox("Get ProcAdress Failed","Captio n",MB_OK);
    FreeLibrary( hMod);
    return;
    }

    int myResString = localLoadResStr ing(1);
    MessageBox("Suc cess","Caption" ,MB_OK);
    return ;
    }

    Jothi Murugeswaran.S
  • AHMEDYO
    New Member
    • Nov 2007
    • 112

    #2
    HI...

    ops man, visual basic 6.0 just can export COM classes it cant export function as API, just you can call class members that exported by VB6 from VC++ by using import directive or COM API functions

    [CODE=cpp]
    #import "yourCOMdll.dll l"
    [/CODE]

    or you can use COM API functions as CoCreateInstanc e, CoGetobject as so on....

    finally GetprocAddress is working only with Dll have API as Windows API kernel.dll and user32.dll and this type of dll VB6 cannot export but if you reverse your operaion it will work, you can create dll from VC++ that you can use from VB6 by GetProcAddress and LoadLibrary

    GOOD LUCK...

    Comment

    • JMurugesh
      New Member
      • Nov 2007
      • 13

      #3
      Originally posted by AHMEDYO
      HI...

      ops man, visual basic 6.0 just can export COM classes it cant export function as API, just you can call class members that exported by VB6 from VC++ by using import directive or COM API functions

      [CODE=cpp]
      #import "yourCOMdll.dll l"
      [/CODE]

      or you can use COM API functions as CoCreateInstanc e, CoGetobject as so on....

      finally GetprocAddress is working only with Dll have API as Windows API kernel.dll and user32.dll and this type of dll VB6 cannot export but if you reverse your operaion it will work, you can create dll from VC++ that you can use from VB6 by GetProcAddress and LoadLibrary

      GOOD LUCK...

      Thanks for reply
      How to use the cocreateinstanc e?

      Comment

      • AHMEDYO
        New Member
        • Nov 2007
        • 112

        #4
        HI...

        COM API Functions as CoCreateInstanc e it not just a function call , it need more knowledge about COM Objects, this link may be help you



        Kind Regards

        Comment

        • JMurugesh
          New Member
          • Nov 2007
          • 13

          #5
          Originally posted by AHMEDYO
          HI...

          COM API Functions as CoCreateInstanc e it not just a function call , it need more knowledge about COM Objects, this link may be help you



          Kind Regards
          I need an example for that....
          and also i want to make sure that , by using this method can we access the functions(witho ut hardcoding import, idl,..) present in the activex dll created in vb?

          Comment

          • AHMEDYO
            New Member
            • Nov 2007
            • 112

            #6
            HI..

            ok i will get you an example in my second post, but there is no third way to do that within VC++, only Import Directive and COM API Functions can be used to create COM Objects.

            Bext Regards

            Comment

            Working...