Click here to Skip to main content
15,892,161 members
Home / Discussions / C#
   

C#

 
GeneralRe: RGB and HSV Pin
Tomas Petricek21-Sep-02 6:19
Tomas Petricek21-Sep-02 6:19 
GeneralScrolling Metrics Pin
leppie21-Sep-02 3:53
leppie21-Sep-02 3:53 
GeneralMulticolored Text Pin
Stickman21-Sep-02 1:38
Stickman21-Sep-02 1:38 
GeneralRe: Multicolored Text Pin
leppie21-Sep-02 1:51
leppie21-Sep-02 1:51 
GeneralRe: Multicolored Text Pin
Philip Fitzsimons23-Sep-02 7:14
Philip Fitzsimons23-Sep-02 7:14 
Questionhelp ( form message releted )? Pin
imran_rafique20-Sep-02 15:59
imran_rafique20-Sep-02 15:59 
AnswerRe: help ( form message releted )? Pin
James T. Johnson20-Sep-02 16:37
James T. Johnson20-Sep-02 16:37 
Questioncan any body help (releated to hook )? Pin
imran_rafique20-Sep-02 15:03
imran_rafique20-Sep-02 15:03 
Generalsocket timeout Pin
Rüpel20-Sep-02 3:27
Rüpel20-Sep-02 3:27 
GeneralRe: socket timeout Pin
Luis Alonso Ramos20-Sep-02 4:37
Luis Alonso Ramos20-Sep-02 4:37 
GeneralRe: socket timeout Pin
Rüpel22-Sep-02 22:23
Rüpel22-Sep-02 22:23 
Generalthis is not solved yet Pin
Rüpel23-Sep-02 4:00
Rüpel23-Sep-02 4:00 
GeneralRe: socket timeout Pin
Daniel Turini23-Sep-02 9:16
Daniel Turini23-Sep-02 9:16 
GeneralRe: socket timeout Pin
Rüpel23-Sep-02 10:09
Rüpel23-Sep-02 10:09 
Generalstill doesn't work Pin
Rüpel23-Sep-02 20:52
Rüpel23-Sep-02 20:52 
Generalfinally Pin
Rüpel23-Sep-02 21:53
Rüpel23-Sep-02 21:53 
GeneralEiffel .NET for Visual Studio .NET Plug-in Pin
Kevin McFarlane20-Sep-02 1:50
Kevin McFarlane20-Sep-02 1:50 
GeneralBackground and foreground color for disabled state Pin
valos20-Sep-02 1:18
valos20-Sep-02 1:18 
QuestionShut down one program from another? Pin
Matt Philmon19-Sep-02 18:11
Matt Philmon19-Sep-02 18:11 
AnswerRe: Shut down one program from another? Pin
Stephane Rodriguez.19-Sep-02 19:08
Stephane Rodriguez.19-Sep-02 19:08 
GeneralRe: Shut down one program from another? Pin
Matt Philmon19-Sep-02 20:50
Matt Philmon19-Sep-02 20:50 
GeneralRe: Shut down one program from another? Pin
Stephane Rodriguez.19-Sep-02 21:23
Stephane Rodriguez.19-Sep-02 21:23 
Here is the actual code executed by the .NET framework when you do Process.GetMainWindowHandle():
// Process.MainWindowHandle property :
public IntPtr get_MainWindowHandle() {
	if (!(this.haveMainWindow)) {
		this.EnsureState(10);
		this.mainWindowHandle = ProcessManager.GetMainWindowHandle(this.processInfo);
		this.haveMainWindow = 1;
	}
	return this.mainWindowHandle;
}

// ProcessManager.GetMainWindowHandle(...) :
public static IntPtr GetMainWindowHandle(ProcessInfo processInfo) {
	MainWindowFinder local0;

	local0 = new MainWindowFinder();
	return local0.FindMainWindow(processInfo.processId);
}

// MAinWindowFinder :
public MainWindowFinder() : base() {
}

public IntPtr FindMainWindow(int processId) {
	EnumThreadWindowsCallback local0;

	this.bestHandle = 20315E582031596Cop_Explicit20315970
020315968;
	this.processId = processId;
	local0 = new EnumThreadWindowsCallback(this, EnumWindowsCallback);
	NativeMethods.EnumWindows(local0, 20315E582031596Cop_Explicit20315970020315968);
	return this.bestHandle;
}

private bool EnumWindowsCallback(IntPtr handle, IntPtr extraParameter) {
	int local0;

	NativeMethods.GetWindowThreadProcessId(handle, local0);
	if (local0 == this.processId && this.IsMainWindow(handle)) {
		this.bestHandle = handle;
		return 0;
	}
	return 1;
}
private bool IsMainWindow(IntPtr handle) {
	if (20315E58NativeMethods.GetWindow(handle, 4) != 20315E582031596Cop_Explicit2031597002031596820315968 || !(NativeMethods.IsWindowVisible(handle)))
		return 0;
	return 1;
}



It is clear in the IsMainWindow that your window is required to be visible, otherwise it returns 0, see :
!(NativeMethods.IsWindowVisible(handle)))


Otherwise, I would see that the behaviour of enumeration is not the same whether you execute as non interactive user (your service), or interactive user. If you had time, you could just write a C++ service doing just that and check if there is a problem.




MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
GeneralRe: Shut down one program from another? Pin
Matt Philmon20-Sep-02 4:47
Matt Philmon20-Sep-02 4:47 
GeneralRe: Shut down one program from another? Pin
leppie20-Sep-02 5:22
leppie20-Sep-02 5:22 
GeneralRe: Shut down one program from another? Pin
Matt Philmon20-Sep-02 21:33
Matt Philmon20-Sep-02 21:33 

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.