Click here to Skip to main content
15,891,033 members
Home / Discussions / C#
   

C#

 
AnswerRe: Wpf Pin
Simon P Stevens15-Oct-08 22:41
Simon P Stevens15-Oct-08 22:41 
AnswerRe: Wpf Pin
Shyam Bharath15-Oct-08 23:20
Shyam Bharath15-Oct-08 23:20 
QuestionDataBound DataGridView not displaying data? [modified] Pin
kbalias15-Oct-08 20:55
kbalias15-Oct-08 20:55 
AnswerRe: DataBound DataGridView not displaying data? Pin
Shyam Bharath15-Oct-08 23:25
Shyam Bharath15-Oct-08 23:25 
QuestionRe: DataBound DataGridView not displaying data? Pin
nelsonpaixao16-Oct-08 12:54
nelsonpaixao16-Oct-08 12:54 
Question"Allow Service to interact with Desktop" Windows Services Pin
Piyush Vaishnav15-Oct-08 20:14
Piyush Vaishnav15-Oct-08 20:14 
AnswerRe: "Allow Service to interact with Desktop" Windows Services Pin
Scott Dorman16-Oct-08 7:55
professionalScott Dorman16-Oct-08 7:55 
AnswerRe: "Allow Service to interact with Desktop" Windows Services Pin
Steve Messer21-Oct-08 6:25
Steve Messer21-Oct-08 6:25 
You should ask yourself if you should be doing this. The reason I used this code was I had a windows service that logged into a DB2 database via an ODBC driver. They routinely changed their passwords and sometimes would forget to tell us. When we tried to login in after a password had been changed the ODBC driver would pop up (attempt to pop up) a dialog allowing you to enter the new password which of course never showed up as it didn't have permissions. We didn't realize any problem until the client called telling us that they hadn't received any new data.

Anyways the following code worked for me.


Reference System.Management

/// Start the service
protected override void OnStart(string[] args)
{
    ServiceDesktopPermission();
}


/// Using Management Object services the option "Allow service to interact with desktop"
/// can be enabled. This gets unchecked/disabled each time a new install or update of the
/// service is performed.
static public void ServiceDesktopPermission()
{
   try
   {
	ConnectionOptions coOptions = new ConnectionOptions();
		
	coOptions.Impersonation = ImpersonationLevel.Impersonate;
		
	// CIMV2 is a namespace that contains all of the core OS and hardware classes.
	// CIM (Common Information Model) which is an industry standard for describing 
	//        data about applications and devices so that administrators and software 
	//        management programs can control applications and devices on different 
	//        platforms in the same way, ensuring interoperability across a network. 
			    
	ManagementScope mgmtScope = new ManagementScope(@"root\CIMV2", coOptions);
		
	mgmtScope.Connect();
		
	ManagementObject wmiService;

	wmiService = new ManagementObject("Win32_Service.Name='" + "My Service Name" + "'");
		
	ManagementBaseObject InParam = wmiService.GetMethodParameters("Change");
		
	InParam["DesktopInteract"] = true;
		
	wmiService.InvokeMethod("Change", InParam, null);
      }
   catch(Exception ex)
   {
     //TODO: Log this error
   }
}

GeneralRe: "Allow Service to interact with Desktop" Windows Services Pin
aftkak3-May-10 5:25
aftkak3-May-10 5:25 
GeneralRe: "Allow Service to interact with Desktop" Windows Services Pin
mehappycamper9-Jun-11 2:43
mehappycamper9-Jun-11 2:43 
AnswerRe: "Allow Service to interact with Desktop" Windows Services Pin
stan_p21-Dec-10 1:05
stan_p21-Dec-10 1:05 
QuestionUsing reflection modify List<int> type class member...</int> [modified] Pin
chandrap15-Oct-08 17:12
chandrap15-Oct-08 17:12 
AnswerRe: Using reflection modify List type class member... Pin
Mogyi16-Oct-08 3:33
Mogyi16-Oct-08 3:33 
GeneralRe: Using reflection modify List type class member... Pin
chandrap16-Oct-08 3:49
chandrap16-Oct-08 3:49 
GeneralRe: Using reflection modify List type class member... Pin
chandrap16-Oct-08 3:54
chandrap16-Oct-08 3:54 
GeneralRe: Using reflection modify List type class member... Pin
chandrap16-Oct-08 4:24
chandrap16-Oct-08 4:24 
GeneralRe: Using reflection modify List type class member... Pin
Mogyi16-Oct-08 4:26
Mogyi16-Oct-08 4:26 
AnswerUsing reflection modify Generic type List<int> class member...</int> Pin
chandrap16-Oct-08 5:50
chandrap16-Oct-08 5:50 
QuestionCan't open solution file, Format Version 9.00 Pin
C#Coudou15-Oct-08 16:24
C#Coudou15-Oct-08 16:24 
AnswerRe: Can't open solution file, Format Version 9.00 Pin
Mycroft Holmes15-Oct-08 16:53
professionalMycroft Holmes15-Oct-08 16:53 
GeneralRe: Can't open solution file, Format Version 9.00 Pin
C#Coudou15-Oct-08 17:01
C#Coudou15-Oct-08 17:01 
GeneralRe: Can't open solution file, Format Version 9.00 Pin
Mycroft Holmes15-Oct-08 17:18
professionalMycroft Holmes15-Oct-08 17:18 
GeneralRe: Can't open solution file, Format Version 9.00 Pin
C#Coudou15-Oct-08 18:15
C#Coudou15-Oct-08 18:15 
GeneralRe: Can't open solution file, Format Version 9.00 Pin
Mycroft Holmes15-Oct-08 20:02
professionalMycroft Holmes15-Oct-08 20:02 
GeneralRe: Can't open solution file, Format Version 9.00 Pin
Scott Dorman16-Oct-08 7:59
professionalScott Dorman16-Oct-08 7:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.