Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Thu, 13 Dec 2007 17:17:34 -0800 (PST),    group: microsoft.public.platformsdk.com_ole        back       


STA hidden windows under Windows XP   
Hi,

From my knowledge about STA, there is one hidden window associated
with each STA based thread. But it seems that knowledge is not correct
under the windwox XP platform.

Under the below sample, the main thread enter the STA apartment by
calling

CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);

From the main thread, it creates a new thread which also call
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED) and enter the STA
apartment.

So now it supposed there are two hidden windows whose class is
OleMainThreadWndClass for each thread's STA apartment. However, it
seems there is only one hidden window there from the main thread. You
can identify it by calling FindWindowEx like below at each thread:

		const char szClass[] = "OleMainThreadWndClass";
		HWND hWnd = NULL;
		DWORD tid4hwnd;
		DWORD dwIdsub = ::GetCurrentThreadId();
		do {
			hWnd = ::FindWindowEx(NULL,hWnd,szClass,NULL);
			tid4hwnd = GetWindowThreadProcessId(hWnd,NULL);
		} while ( NULL!=hWnd &&
			tid4hwnd!=dwIdsub);

At the main thread, it returns a hidden OleMainThreadWndClass window
that belongs to the main thread; at the second thread, it also only
finds the main thread's OleMainThreadWndClass hidden window.

Does that mean the hidden window is sharing by both STA based threads?
If so, is there any document like http://msdn2.microsoft.com/en-us/library/ms809311.aspx#dcomarch_concur
to state the change?

Thanks,
Steve
date: Thu, 13 Dec 2007 17:17:34 -0800 (PST)   author:   Steve Zhang

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us