tags:

views:

10

answers:

0

If you inspect a dll using depends.exe (Dependency Walker) it shows you the functions that the dll exports. In Windows 98, when I look at user32.dll, it lists both MessageBoxA and MessageBoxW. Similarly, kernel32.dll lists both GetModuleFileNameA and GetModuleFileNameW.

MSDN descriptions for these two functions state that MessageBox is available as both MessageBoxA and MessageBoxW in Windows 98. For GetModuleFileName it states that GetModuleFileNameW requires the Microsoft Layer for Unicode (unicows.dll).

So, MSDN states that these are available in Windows 98 without unicows:

GetModuleFileNameA
MessageBoxA
MessageBoxW

but this requires unicows:

GetModuleFileNameW

If I run the following program, the lines marked with <--- fire:

char a[100] = {0};
wchar_t w[100] = {0};

if(GetModuleFileNameA(NULL, (LPCH)(&a), 444) == 0) {
    MessageBoxA(NULL, "failed", NULL, MB_OK);
}
else {
    MessageBoxA(NULL, (LPCSTR)(&a), NULL, MB_OK); <---
}

if(GetModuleFileNameW(NULL, (LPWCH)(&w), 444) == 0) {
    MessageBoxW(NULL, L"failed", NULL, MB_OK); <---
}
else {
    MessageBoxW(NULL, (LPCWSTR)(&w), NULL, MB_OK);
}

My question: the above behavior matches what MSDN says, but why does kernel32.dll export GetModuleFileNameW at all when it is only going to fail when called? Note that the function does exist in the dll, because the program runs to the second <--- line.


(PS. I ask this purely out of interest - I am not trying to fix a problem!)