Wednesday 15 September 2010

c# - Programmatically check if user has enough rights for software installation -


In my application (it only supports Windows 7 and higher), I want to run a script which Some installation programs will run. Before doing so, I have to check that it will provide this author with enough rights to run this script from my app which can run this installation. Otherwise, Windows refuses to do so and shows a message with the fact that administrative rights are required for the user who launches my app.

According to this, the easy way to solve my problem does not always work properly, but I do not like other suggestions (using Win API).

Can anyone explain to me how my problem is simple and well-documented? To use NET code, but not Win API?

I know that it matches your "but not Win API?", But in fact , P / Invoke and Win32 API are the way to go.

The process upgrade is only related to Windows (so it does not mean if you want to use your code with mono), it is up to the Win32 API, OK.

GetTokenInformation is a good thing to use, just make sure you use IntPtr for platform-specific sizes (or better than that) : Safe Handle to handle the process), so it will work fine on both x86 / x64 machines.

No comments:

Post a Comment