Explorer in IE search custom browser good assistant (middle)
(Author: Green Apple Studio compiled February 08, 2001 14:00)
Detecting callers
As mentioned earlier, if you run a shell version that is not less than 471,bho, it can be referenced by both Internet Explorer and Windows Explorer. In this example, if we involve a helper object that works on HTML pages, it should have no effect on Windows Explorer. A DLL that does not want to be loaded by a particular caller can simply return False in its DllMain () function when it discovers who is the caller. When you call NULL as the first argument to the API function GetModuleFileName (), it returns the module name of the calling DLL. This parameter is the handle of the module you want to know the name of. NULL indicates that you want to know the name of the process that invoked the DLL.
if (Dwreason = = Dll_process_attach)
{
TCHAR Pszloader[max_path];
GetModuleFileName (NULL, Pszloader, MAX_PATH);
_TCSLWR (Pszloader);
if (_tcsstr (Pszloader, _t ("Explorer.exe"))
return FALSE;
}
Once you know the name of the process, you can exit the load process when it is Windows Explorer. It is dangerous to note that more stringent elimination is taken. In fact, other processes might call it for a normal reason but are rejected. The first victim is Regsvr32.exe, a program used to automatically register objects. If you are using a different test condition, for example, only Internet Explorer is allowed to perform:
if (!_tcsstr (Pszloader, _t ("Iexplore.exe"))
You won't be able to register the DLL. In fact, when Regsvr32.exe tries to load the DLL to invoke the DllRegisterServer () function, the call is rejected.
Establish contact with WebBrowser
The SetSite () method is the BHO initialization and all the places where only one task is performed. When you browse URLs with Internet Explorer, you need to wait for a couple of events to ensure that the required documents are completely downloaded and initialized. Only in this position can you access its contents securely through a possible object model. This means you need to get a pair of pointers. The first point is the IWebBrowser2, which is the interface that handles the WebBrowser object. The second pointer is related to the event. This module must be registered as a browser event listener to be able to receive notification of downloads and documentation-related events. By using an ATL smart pointer:
Ccomqiptr<iwebbrowser2, &IID_IWebBrowser2> M_spwebbrowser2;
Ccomqiptr<iconnectionpointcontainer,
&IID_IConnectionPointContainer> M_SPCPC;
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.