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
+7
A:
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");
FigBug
2008-12-02 16:59:39
A:
Michael Stum
2008-12-02 17:00:59
A:
You could call FindFirstFile instead of GetFileTime. I wouldn't know an alternative for SetFileTime, though.
MSalters
2008-12-03 14:38:17
From the research I have done it seems that there isn't one, thanks though!
SteveL
2008-12-09 16:18:24