I'm not interested in getting version information. All I want to do is to make sure my application will only run on a legal version of Windows and not on a pirated version. Windows uses some trick to determine this but still allows pirated versions to continue to run, although with some limits.
So, is there a way to check if the application is installed on a legal, genuine Windows version? (Vista and better, at least.)
Let me clear something up: Microsoft isn't preventing users to use a non-validated or illegal version of their operating system. Thus I don't have any reasons to block my application on such a version either. But I do want my application to be aware of the illegal version and warn the user that his Windows version isn't validated. Maybe he forgot, maybe he doesn't want to validate. There could be plenty of reasons for this and I don't want to block them, just making them aware of a problem with their Windows version.
Also, when someone uses a non-valid version of Windows then I might want to do a more strict validation check of my own software, if it's a commercial product. In my free products, I just want an annoying popup, which will just appear once per day.
The main problem with non-validated Windows versions is that they might contain additional spyware and other malware and there's a chance that they don't get all required updates. These Windows versions have a weaker protection than validated Windows versions. Since several of my applications use sensitive data, I don't want any malware leaking away this sensitive data.
Plus, I consider pirated software harmful for any free alternatives. Linux and FreeBSD would have been much more popular if it wasn't for all those pirated Windows versions that are roaming around. People who use pirated software are unlikely to have bought the product in the first place but I would prefer them to use a free alternative instead. Pirated software does a little harm to Microsoft, but it does a lot more harm to the Free community since it keeps people connected to those commercial products...
It's an interesting question but wrong attitude. It is not your business checking the affairs of the user.
Or you might as well:
Require their tax declaration before selling your software to them
A written proof from police they have no criminal record (or they may be inclined to break the law again and pirate your software)
Check if they have any torrent software installed (of course it can be used legally but the very fact they have it implies they may misuse it)
Check if they have antivirus software installed (to raise their social awareness and to help fight spam bot networks)
A credit history report (to be sure they have promptly paid their bills and will also not forget to pay for your software)
A proof from their family doctor they have no terminal disease (a person feeling condemned may break the law and pirate your software)
You see where it's going right?
One of the key rules for developing software - your software should be useful, make the users happy and build as few barriers as possible.
You can't possibly know and you shouldn't care.
The legal status of an install is entirely unrelated to anything on the disk. The same install can be unlicensed now and licensed the next minute without any changes to the machine.
That's something for Microsoft to worry about. Not you.
Microsof offers a small API, but MSDN doesn't state anything about how the used DLL is installed at the client system. My guess is, that it comes with the SP2 or WGA utility from windows Update.
This is the MSDN page for the API.
Why don't you also check to make sure they're not running a pirated version of Photoshop? Or Half-Life? How about Microsoft Office?
See where I'm going with this? I don't particularly agree with piracy checks as it stands - but in order to perhaps save you a headache, I would suggest that you only worry about whether your own software is pirated, using whatever means you wish (licence keys, phoning home, whatever nefarious and intrusive method you so desire!). So someone who pirated Windows MAY be likely to also pirate your software too. If you intend to block usage of your software if you detect they're running a pirated copy of Windows - well, that's just bad practice. What if the validation software is buggy, or incorrect, or reports that the software is pirated because SOMEBODY ELSE used this person's legitimately bought licence key?
Aside from it being none of your business, Windows in particular has been known to falsely report that a legitimate copy of Windows was pirated. You should not trust anybody's validation tools but your own (and even then you might have coded a crappy validation tool!). There are so many things that could cause an incorrect piracy report - I would steer way clear of this approach.
Not even Microsoft can do this reliably. It is a constant arms race as Microsoft updates WGA against people who seemingly have to do very little to bypass it. This is exacerbated by the needs of OEMs who (rightly) need to have preinstalled and prevalidated copies of OSs so they don't annoy their customers, whom may well be business customers. I think that a lot of the "hacks" around this have to do with OEM master keys.
Basically, pirating software (including Windows and your software) is a social problem not a technical one. The worst thing you can do as a software vendor (imho) is to annoy your legitimate customers in the quest to stop pirates to the point that you make your legitimate customers pirates. Example: some games have gone so far as to install rootkits as well as limiting the number of activations (eg Spore).
Limiting activations in particular is an evil practice. People have an innate sense of fairness about these things. If they have two activations of something, are running Windows XP and switch to Windows 7 RC and will then switch to a real version of Windows 7 when released then they've just gone over the limit. As in the case of Spore, you can request additional activations over the phone but this kind of thing just rubs people the wrong way. Some to the point that they'll feel quite justified in bypassing such restrictions.
As for downvoting your question, I suspect it's because people don't like your intent, probably for reasons that are similar to the ones I've listed above.
The way I see it, I won't ever trust someone else's verification system to be accurate enough that I would be willing to lock people out of using my software.
I see where you're coming from, but I suggest having MS worry about Windows validation.
In addition, there's really no way to know the true legal status of an install through the machine itself. Sure, there's "validation" and all that jazz, but that's nigh meaningless in context of the truth.
Just asking the technical part, leaving out your reasons/philosophy would have given you direct answers.
If you prevent pirating your own software (i mean prevent it running on pirated windows) then probably your software will not be as sucsessfull as it could.
Just make your client pay fair price for your software.
来源:https://stackoverflow.com/questions/1458896/how-to-detect-if-a-windows-version-is-legal-or-not