How to find if a user is administrator or not

It’s quite common to find out whether a user or application is running Admin account or not. well I’ve already posted a article entitled “Run Application Only in Administrator Account”. Have a look there In addition to the above reference, you can use the given code also to find out whether the user is Admin or not. Just use System.DirectoryServices.AccountManagement: In addition we can also some other way if we are using Visual Studio 2010 by adding an application manifest file. In you’re using VS 2010, there’s an option for one in the “Add New Item” dialog (right click on Read More …

Share Knowledge

Run Application Only in Administrator Account

Many time we have requirement to run application only as a administrator account, not application we need to secure single windows form at many time to give access to those  user who have not Admin account privilege. Take a look how to accomplish this task using C# language in your program. To accomplish it you can use simple function name is isAdm() which is described below to access class like WindowsIdentity you need to use System.Security.Principal namespace in your code file. as and then create function name isAdm() isAdm() function having boolean return type which will return true if apllication is Read More …

Share Knowledge

Close Application at Press of Escape Button

There are various ways to close an application by pressing the Escape button, using C#. Here are a few: Way 1: Simply add the below given code in your Windows program: Way 2: Write the below code in the ‘KeyPress’ event of a form: Way 3: Select properties of Form and select ‘KeyPreview’  and change it from ‘false’ to ‘true’‘. [By default, its value is ‘false’] Then write the below code in the ‘KeyUp’ event of the Form: so after taking these all steps, you will able to close application at press of escape button. Article Posted in CP I’ve also posted this Read More …

Share Knowledge