4 #include <winpr/path.h>
5 #include <winpr/tchar.h>
6 #include <winpr/windows.h>
7 #include <winpr/library.h>
9 int TestLibraryLoadLibrary(
int argc,
char* argv[])
11 HINSTANCE library = NULL;
12 LPCSTR SharedLibraryExtension = NULL;
13 CHAR LibraryPath[PATHCCH_MAX_CCH];
17 if (!GetModuleFileNameA(NULL, LibraryPath, PATHCCH_MAX_CCH))
19 printf(
"%s: GetModuleFilenameA failed: 0x%08" PRIX32
"\n", __func__, GetLastError());
25 if (!(p = strrchr(LibraryPath, PathGetSeparatorA(PATH_STYLE_NATIVE))))
27 printf(
"%s: Error identifying module directory path\n", __func__);
32 NativePathCchAppendA(LibraryPath, PATHCCH_MAX_CCH,
"TestLibraryA");
33 SharedLibraryExtension = PathGetSharedLibraryExtensionA(PATH_SHARED_LIB_EXT_WITH_DOT);
34 NativePathCchAddExtensionA(LibraryPath, PATHCCH_MAX_CCH, SharedLibraryExtension);
36 printf(
"%s: Loading Library: '%s'\n", __func__, LibraryPath);
38 if (!(library = LoadLibraryA(LibraryPath)))
40 printf(
"%s: LoadLibraryA failure: 0x%08" PRIX32
"\n", __func__, GetLastError());
44 if (!FreeLibrary(library))
46 printf(
"%s: FreeLibrary failure: 0x%08" PRIX32
"\n", __func__, GetLastError());