I want to use a couple of functions from SHLWAPI.DLL. I am unsure how to make
these available to my .c source without having to link in import libraries
(Using Run-Time Dynamic Linking). The example in SDK docs is not helping in my
situation... ultimately I just need to be able to call a couple of functions
at run-time.
thanks for any advice,
kz
Use LoadLibrary to load SHLWAPI.DLL and then use GetProcAddress
to get the address of procedures that you want to call, then use the
returned
addresses to call the functions.
typedef WINSHELLAPI void (WINAPI *dfSHAddToRecentDocs)(UINT uFlags, LPCVOID
pv);
void callRunTimeFunc()
{
HMODULE hLib = LoadLibrary("SHLWAPI.DLL");
dfSHAddToRecentDocs func;
if(!hLib) return;
func = (dfSHAddToRecentDocs)GetProcAddress(hLib, "SHAddToRecentDocs");
if(func) func(SHARD_PATH, "MyDocument");
FreeLibrary(hLib);
}
Best regards,
Barry S. Kyker
thanks for the help,
kz
"Barry S. Kyker" <bsk...@bellsouth.net> wrote in message
news:sZBW9.17949$F_3....@news.bellsouth.net...
1) From the viewpoint of just occasional user of C(++): I think
that syntax of pointers-to-functions is just plain ugly, tough
to remember and tough to comprehend. I do understand it when
I see it, but I always have to take a look back when I have
to write it myself.
Obviously,
typedef void (WINAPI *dfSHAddToRecentDocs)(UINT uFlags, LPCVOID pv);
declares that dfSHAddToRecentDocs is a type which is a
pointer to void __stdcall function with given arguments.
There are language rules behind that particular syntax, but
IMO it's easier to just look back at a sample than to try
to remember them ;-). So, if you feel frustrated about
that, at least feel consoled that you're not alone :-)
| 2), I was only able to compile by removing the WINSHELLAPI identifier
| from the typedef line...
2) I think it's just a Barry's copypasto. WINSHELLAPI evaluates
to __declspec(dllimport), which doesn't make sense if you
do GetProcAddress.
--
Jugoslav
___________
www.geocities.com/jdujic