views:

176

answers:

3

Hello,

Does ntdll.dll come standard with windows xp and windows vista? I know that I have it on my windows xp machine, but am not sure that is standard with every machine.

The reason I am curious is for the NTQuerySystemInformation function to get CPU usage of a windows xp and/or windows vista system.

Thanks,

Steve

+3  A: 

Yes, but the function you want to use doesn't might not. According to MSDN, NTQuerySystemInformation may be altered or unavailable in future versions of Windows. You should use GetSystemInfo instead, which is in Kernel32.dll and available from Windows 2000 and up.

You really should learn to check MSDN regarding API calls before you use them. And, if you did so, you should learn to listen, as once it's deprecated MS is free to remove it from future NTDLL files in updates (although they don't typically do so). Choosing to intentionally use a deprecated function when there is a viable and supported alternative is always a bad idea.

Ken White
I did check MSDN prior and because I saw "NTQuerySystemInformation may be altered or unavailable in future versions of Windows", I decided to ask here if ntdll was available in Win XP and Vista. I am not concerned with any other OS besides these two. How do you know that the function is not available in ntdll for XP or Vista? Also, GetSystemInfo retrieves a system info structure which does not have the information to get the CPU usage. You really should learn to check MSDN regarding API calls before you use them ;)
stjowa
Read the documentation. Since it doesn't specifically say it *is* available, it may not be. Your refusal to believe things straight from the mouth of the maker doesn't change things. If you in fact read the docs, you should have seen the alternate function that MS says you should use instead, and the fact that it was *specifically* available for XP and Vista (since they're "Windows 2000 and up"). IOW, if you indeed saw that the function was deprecated, and there was a current replacement that worked on your target OSs, it makes no sense for you to still try and use the wrong function.
Ken White
Ok, it MAY not be available, but that doesn't mean that it is NOT available (source: webster's dictionary) - which is EXACTLY what you said in your original post. Also, if you actually read the documentation and understand what i was asking in my post, you will see that there is no function suggested for the information that I need. Your suggested function of GetSystemInfo() will NOT give me the needed information - that returns SYSTEM_BASIC_INFORMATION which will not give me the CPU usage.
stjowa
May not be available means "you can't count on it being available". Burying your head in the sand and refusing to listen doesn't hurt anyone but you. You've had alternate suggestions (mine and Fraser's below), and you've been told directly from MS that you shouldn't use this function. Obviously, you're not interested in hearing the answer - why did you bother to ask the question in the first place?
Ken White
Also, from the documentation on NTQuerySystemInformation, I don't see nay reference to getting CPU usage; QueryPerformanceCounter would appear to be a better alternative (as would WMI as suggested by Fraser).
Ken White
I think we need a referee :) Anyway, thanks for the input. I'll keep researching for the best way to find system CPU usage for XP and Vista.
stjowa
<g> No problem. Hope at least something was of use in all of that text.
Ken White
A: 

According to the site below, "this is a file required by Windows and deleting the file will cause errors with Windows." With that said, I think it's safe to assume all machines will have it.

http://www.computerhope.com/issues/ch000960.htm

yankee2905
This link might give an indication the mentioned dll is very likely to be there, the other answers try to address the root of the problem.I myself try to avoid using unsupported apis.
Gregory Pakosz
+1  A: 

Why use undocumented ntdll.dll functions? You can use WMI to get the CPU usage. For example using Win32_Process should be able to help.

Fraser