Generate hardware code

  • Thread starter Thread starter Etienne
  • Start date Start date
E

Etienne

Hi, in order to protect my software using web activation, I generate a
computer hardware code. I'm using the motherboard serial and CPU serial,
with ManagementObjectSearcher class. This relies on WMI. On Win9x, since it
doesn't support WMI, I simply get the windows volume serial, although it's
not as good.

But now the problem is. The user needs to be admin in order to get those
codes! If the software runs under a guess account, it crashes. Any good
suggestion?

Thanks,
Etienne Charland
 
Hi,

Do you need to check those things every time, or just once?

Because you say activation, it might be that you only want it once. In that
case, you can prompt the user for an admin password the first time the
application is run. You can then use PInvoke and LogonUser Win32 API
function to generate a user token. Then use WindowsIdentity.Impersonate to
impersonate the administrator user until you activate. Remember to restore
to normal user level after you are done.

(If you need to check once, this could also be checked during setup, which
probably requires elevated privileges anyway)

If you require these things every time, you somehow need to make sure your
program gets elevated privileges to read those things. Always asking for an
admin password could be annoying, and might not be available always either.

Regards
-Lenard
 
Back
Top