Hi Nick,
On 2018-11-05 18:09, Nick Surfer wrote:
I am writing a program which needs to know exact
environment in which it
is running. In case of Windows I simply use GetVersionEx and then
analyze dwMajorVersion + dwMinorVersion which is enough for my case
(then I know which WIN API calls I should use). But I stuck how to
recognize that my program runs in ReactOS. I failed to find any docs
about it. Any help is appreciated.
For most scenarios this is even wrong for
Windows itself. For example in
order to figure out if the ITaskbarList4 COM interface is available you
should NOT check the OS version and then act depending on whatever you
found out. Instead you should attempt to query for the interface and use
it if you succeed. It's trivial to create a shim class that will return
S_FALSE for each method called when the interface could not be queried.
Similarly if you are interested in a function that only exists on, say,
Windows 7, you'd use GetProcAddress() to find if the function you're
interested in exists. If it doesn't you'd use your fallback code path.
Of course if the function you are requesting behaves in a completely
different way than the original you'd be out of luck. But in case of
ReactOS _such_ observation should prompt you to file a ticket for the
defect (unless it's a known one). The point here is that for public and
documented functions there's pretty much a contract, just like for COM
interfaces.
Generally it's a suboptimal idea to use the OS version to conditionally
execute this or that code path. Instead try to check for capabilities
and go by whatever finding that gives you ...
Further reading:
<https://blogs.msdn.microsoft.com/oldnewthing/20040213-00/?p=40633>
Hope this helps,
Oliver
PS: now if you wanted to tell ReactOS apart from Windows one way would
be to look into the version information resource of one of the
well-known DLLs. kernel32.dll comes to mind. But as I pointed out above,
you likely do NOT want to do this NOR need this for all but a few edge
cases.