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

Hybrid View

  1. #1
    Join Date
    Sep 2012

    Call function undirectly

    I am programming an executable application (not a dll or any kind of library). I simply want an equivalent of calling function using GetProcAddress and not just a simple typedef because that method didn't seem to work for executable but only for dll developments. Here is a working example:

    typedef HRESULT (*pCoInit)(LPVOID);
    pCoInit CoInit = (pCoInit)GetProcAddress(LoadLibrary("ole32.dll"),"CoInitialize");

    CoInit will be called instead of CoInitialize.

    But when I try this code to generate an executable, when I double click the executable the program crashes. So I don't know if their is an alternative to GetProcAddress which can be used to build executable and not a dll. Also I don't know if loadlibrary can be used to load from a static library rather than a dynamic one or no, example ole32.lib instead of ole32.dll ?

    Last edited by Emapat; October 1st, 2012 at 07:56 PM.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003

    Re: Call function undirectly

    A static library is linked to your code, so LoadLibrary doesn't make sense as it's part of the executable and already loaded.

    If you already know the function's name, why do you want to call it using GetProcAddress?

  3. #3
    Join Date
    Sep 2012

    Re: Call function undirectly

    Thank you very mush for your help

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.