October 1st, 2012, 08:40 PM
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 08:56 PM.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.