6 * Written by Keith Marshall <keithmarshall@users.sourceforge.net>
7 * Copyright (C) 2013, MinGW.org Project
10 * Implementation of a utility function to check for availabiliity of
11 * a specified API function within a specified DLL.
14 * This is free software. Permission is granted to copy, modify and
15 * redistribute this software, under the provisions of the GNU General
16 * Public License, Version 3, (or, at your option, any later version),
17 * as published by the Free Software Foundation; see the file COPYING
18 * for licensing details.
20 * Note, in particular, that this software is provided "as is", in the
21 * hope that it may prove useful, but WITHOUT WARRANTY OF ANY KIND; not
22 * even an implied WARRANTY OF MERCHANTABILITY, nor of FITNESS FOR ANY
23 * PARTICULAR PURPOSE. Under no circumstances will the author, or the
24 * MinGW Project, accept liability for any damages, however caused,
25 * arising from the use of this software.
28 #define WIN32_LEAN_AND_MEAN
32 int have_api( const char *entry, const char *dll )
34 /* Initially assuming that the specified API is "unsupported",
35 * attempt to get a handle for the nominated provider DLL.
38 enum { API_UNSUPPORTED = 0, API_SUPPORTED } status = API_UNSUPPORTED;
39 if( (provider = LoadLibrary( dll == NULL ? "msvcrt.dll" : dll )) != NULL )
41 /* When we have a valid DLL handle, look up the entry point
42 * address, within it, for the specified API function...
44 if( GetProcAddress( provider, entry ) != NULL )
46 * ...and, provided this returns a valid entry address,
47 * mark the API as "supported".
49 status = API_SUPPORTED;
51 /* Release the handle we acquired above, for the provider DLL,
52 * so that we maintain a balanced reference count.
54 FreeLibrary( provider );
56 /* Finally, return the support state for the API, as determined.
61 /* $RCSfile$: end of file */