4 #include <winpr/path.h>
5 #include <winpr/tchar.h>
6 #include <winpr/windows.h>
7 #include <winpr/library.h>
9 int TestLibraryGetModuleFileName(
int argc,
char* argv[])
11 char ModuleFileName[4096];
16 SetLastError(ERROR_SUCCESS);
17 len = GetModuleFileNameA(NULL, ModuleFileName, 2);
20 printf(
"%s: GetModuleFileNameA unexpectedly returned %" PRIu32
" instead of 2\n", __func__,
24 if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
26 printf(
"%s: Invalid last error value: 0x%08" PRIX32
27 ". Expected 0x%08X (ERROR_INSUFFICIENT_BUFFER)\n",
28 __func__, GetLastError(), ERROR_INSUFFICIENT_BUFFER);
33 SetLastError(ERROR_SUCCESS);
34 len = GetModuleFileNameA(NULL, ModuleFileName,
sizeof(ModuleFileName));
37 printf(
"%s: GetModuleFileNameA failed with error 0x%08" PRIX32
"\n", __func__,
41 if (len ==
sizeof(ModuleFileName))
43 printf(
"%s: GetModuleFileNameA unexpectedly returned nSize\n", __func__);
46 if (GetLastError() != ERROR_SUCCESS)
48 printf(
"%s: Invalid last error value: 0x%08" PRIX32
". Expected 0x%08X (ERROR_SUCCESS)\n",
49 __func__, GetLastError(), ERROR_SUCCESS);
53 printf(
"GetModuleFileNameA: %s\n", ModuleFileName);