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

Threaded View

  1. #1
    Join Date
    Sep 2012
    Posts
    3

    Call function undirectly

    Hello
    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 ?

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

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