Reputation: 1821
So I don't do a lot of Win32 calls, but recently I have had to use the GetFileTime()
and SetFileTime()
functions. Now although Win98 and below are not officially supported in my program people do use it there anyway, and I try to keep it as usable as possible. I was just wondering what will happen as those functions do not exist in pre-NT systems, will they receive an error message of some sort for example because in that case I will add in an OS check? Thanks
Upvotes: 6
Views: 511
Reputation: 8836
If you call the functions directly, then your program will not load on Win98.
What you can do is use LoadLibrary()
/ GetProcAddress()
to get a pointer to GetFileTime()
/ SetFileTime()
. On Win98 this will fail, giving you a null pointer which you can test for and ignore. On 2000 and later you will get a pointer which you can then use.
It's a pain, but it's the only solution I know of.
Here is an example of getting the UpdateLayeredWindow function if it exists:
typedef BOOL (WINAPI* UpdateLayeredWinFunc) (HWND, HDC, POINT*, SIZE*, HDC, POINT*, COLORREF, BLENDFUNCTION*, DWORD);
UpdateLayeredWinFunc updateLayeredWindow = 0;
HMODULE user32Mod = GetModuleHandle (_T("user32.dll"));
updateLayeredWindow = (UpdateLayeredWinFunc) GetProcAddress (user32Mod, "UpdateLayeredWindow");
Upvotes: 8
Reputation: 179779
You could call FindFirstFile()
instead of GetFileTime()
. I wouldn't know an alternative for SetFileTime()
, though.
Upvotes: 0
Reputation: 180874
I believe you get an error message along the lines of "The procedure entry point (name) could not be located in (dll)", similar th the one shown:
example http://img266.imageshack.us/img266/3762/error2pm1.png
Upvotes: 0