|
Hi,
For a particular requirement, currently my testing team has isolated multiple copes of IE5.5 (in seperate folders with *all* the required DLLs within that folder). They launch multiple copies (sometimes upto 100) of the IE5.5 for their testing to allow individual sessions.
I'm trying to automate this, and for the same (with my very limited knowledge of COM) am trying to do the following. Please help me here to tell me if I am on the right track?:
1. I have a dialog based MFC app can launch each of the 100 different copies of IE 5.5 from their individual 100 folders using CreateProcess()
2. In the app I'm also doing (only once - I suppose this is primarily required for generating the TLH/TLI files):
#import "C:\IE Copies\IE551-1\SHDOCVW.DLL"
Doubt: As each of the 100 folders containing the IE5.5 have their own SHDOCVW.DLL, do I need to import them individually, or should this suffice?
3. After the IEs are running, next I need to "reach" their individual IWebBrowser2 interfaces (exposed by their SHDOCVW.DLL) so that I can invoke the navigation methods to automate visiting sites, logging in, etc.
Please note - The IEs are *not* registered with the system (obviously) - and so the usual methods may not work.
Doubt: Is there some way I can use CoCreateInstance() such that I can launch each of the IE5 copies, even though they're not registered on the system.
Sorry - if this sounds crude/crazy... I'd really appreciate if you can suggest a solution to this -- or even a more appropriate/elegant method to get this going.
Thanks a lot in advance, for your time & efforts.
Rgds,
nd
modified on Thursday, June 5, 2008 2:31 PM
|
|
|
|
|
I think I can use the concept from: How to get IHTMLDocument2 from a HWND[^]
Since the method needs a HWND , I need to write a PIDtoHWND() after I do the CreateProcess() which will get me only the PID.
Phew... I hope this works! Yet to test it.
Thanks,
nd
|
|
|
|
|
Stuck up once again!
I've used the code & concept as given at: How to get IHTMLDocument2 from a HWND[^]
With that, though I have a valid CComPtr<IHTMLDocument2> spHTMLDoc2 , (valid because the spHTMLDoc2->put_bgColor(CComVariant("blue")) works fine) the get_parentWindow() doesn't work and gets a 0x00000000 in the spHTMLWindow2 .
Is there something wrong with the way I'm doing this?
spHTMLDoc2->put_bgColor(CComVariant("blue"));
CComPtr<IHTMLWindow2> spHTMLWindow2;
hr = spHTMLDoc2->get_parentWindow(&spHTMLWindow2);
Thanks!
* Blood donation is the most superior form of donation, it can save lives. Celebrate special occasions, like your birthdays, by donating blood. *
modified on Saturday, June 14, 2008 2:16 AM
|
|
|
|
|
Finally, a good friend (Nanda) was able to help with this, and got the code below WORKING! This is how to get IWebBrowser2 from IHTMLDocument2 .
Pasting code below for anyone who may need this. I had a very tough week wrestling with this, don't want anyone else to go through the same.
CComQIPtr<IOleObject> spOleObject;
CComQIPtr<IOleClientSite> spOleClientSite;
CComQIPtr<IServiceProvider> spServiceProvider;
...
...
...
HRESULT hRes = spHTMLDoc2->QueryInterface(IID_IOleObject, reinterpret_cast<void **>(&spOleObject));
if (SUCCEEDED(hRes))
{
hRes = spOleObject->GetClientSite(&spOleClientSite);
if(SUCCEEDED(hRes))
{
hRes = spOleClientSite->QueryInterface(IID_IServiceProvider, reinterpret_cast<void **>(&spServiceProvider));
if(SUCCEEDED(hRes))
{
hRes = spServiceProvider->QueryService(SID_SWebBrowserApp,IID_IWebBrowser2, reinterpret_cast<void **>(&spWebBrowser));
}
if(SUCCEEDED(hRes))
{
BSTR oURL;
oURL = SysAllocString(L"http://www.google.com");
VARIANT var;
var.vt = VT_EMPTY;
spWebBrowser->Navigate((BSTR)oURL, &var, &var, &var, &var);
SysFreeString(oURL);
}
}
}
Thanks a ton Nanda!
* Blood donation is the superior'est form of donation, it can save lives. Celebrate special occasions, like your birthdays, by donating blood. *
|
|
|
|
|
#import just creates the TLH/TLI wrappers as you said. Since all the IEs are the same version, they will support the same COM interfaces, so just one #import will be enough.
|
|
|
|
|
Mike, thanks for the confirmation!
I'm still stuck up in a problem, posted above. Any ideas there?
* Blood donation is the superior'est form of donation, it can save lives. Celebrate special occasions, like your birthdays, by donating blood. *
|
|
|
|
|
Why do you need several processes? Can't you just instantiate one IE, and then automate it to open 100 new windows?
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
The reason for several copies of IE is purely for the visiting site's session management.
New Windows don't allow a new session as well as multiple copies of the same IEXPLORE binary (different process). Hence the need to make multiple self-sustained copies of IE.
Thanks!
* Blood donation is the superior'est form of donation, it can save lives. Celebrate special occasions, like your birthdays, by donating blood. *
|
|
|
|
|
Oh, I see.. tricky. Perhaps it would be easier to create 100 user accounts, and run each instance for each user? Might be trickier in some other respects. (Just throwing out some random ideas here that might be of some use )
--
Kein Mitleid Für Die Mehrheit
|
|
|
|
|
Thanks! Yes, that's what is to be done. 100 browsers, running 100 user accounts simultaneously, automated.
* Blood donation is the superior'est form of donation, it can save lives. Celebrate special occasions, like your birthdays, by donating blood. *
|
|
|
|
|
Hi all,
Does anyone know how I can initialize a VMI interface for Network adapters in Borland C++ 2006.
The class Win32_NetworkAdapter is not recognized by C++ Builder.
Generally is there any other means to detect and control (enable/disable) WiFi and Ethernet network adapters?
Thanks,
Nektarios
|
|
|
|
|
Hi All,
I need a documentation proof for the following observation i have made(presuming my observations are correct )
I have written a addin for Microsoft Excel.
This addin handles the CLOSE event from the Excel.
But now , I have a Macro in an Excel sheet which is also listening for the close event.(the macro is as below)
Private Sub Workbook_BeforeClose(Cancel As Boolean)
If MsgBox("Confirm exit", vbYesNo) = vbNo Then
Cancel = True
End If
End Sub
And in the Addin , i am using the Cancel parameter as below.
OnWorkbookBeforeClose(IDispatch* pWorkbook, VARIANT_BOOL* pbCancel)
{
//So here pbCancel value is depending on what is clicked in that message box --
// As it is seen Message box has two buttons "Yes" and "No"
// If "No" button is clicked , the Cancel parameter value we get is "True"
// If "Yes" button is clicked, the addin does what is intend it to do.(i:e it closes the Excel)
}
As it is understood
This macro pops up a message box and can alter the "cancel" depending on what is clicked.
And in the Addin,
what i get now is the edited value of the "Cancel" parameter if "NO" button is clicked.
So, what i am assuming is, THE EVENT FIRST GOES TO THE MACRO AND ONLY THEN COMES TO MY ADDIN.
So, is my assumption Correct, if so , can i have some Documentation proof for the same(i:e - The control goes to the macro first and then will be sent to the Addin's (if any))
So, has any one come across the same situation.
It would be of great help if you reply me on this.
Thanks in Advance.
Harish
|
|
|
|
|
Hi ,
i have a vb com component dll , can i pass a parameter to this dll from the windows component services ?
i need that coz the dll connect to a database so i want to send the database from outside and not be
hard coded.
thanks
|
|
|
|
|
Hi all.
This is my 1st post to the Code Project so please excuse me if I step on some toes.
My question relates to polymorphism (I'm using VS 8.0 with ATL/COM). Assume the following (off the top of my head). What I want to do is to have a ITestOne interface with CTestOne implemented and a ITestTwo interface with CTestTwo implemented. I want to use ITestTwo to access ITestTwo interface implementations and to access ITestOne Interface implementations. I will have other classes derived from ITestTwo (e.g., ITestThree, ITestFour) and CTestThree derived from CTestTwo, etc.
Any suggestions???
TIA,
Kim
[
object,
uuid(F799607A-47E7-4582-B056-9FD4F5381BA5),
helpstring("ITestOne Interface"),
pointer_default(unique)
]
interface ITestOne : IUnknown{
};
[
object,
uuid(9AE009F8-99D9-4C4A-B0BC-9A34EEFCF78B),
helpstring("ITestTwo Interface"),
pointer_default(unique)
]
interface ITestTwo : IUnknown{
};
[
uuid(B7AB057E-F270-4019-966F-52E9994F82C2),
version(1.0),
helpstring("COMTest 1.0 Type Library")
]
library COMTestLib
{
importlib("stdole2.tlb");
[
uuid(F019A63E-D8ED-463B-AB5F-996A9231E448),
helpstring("TestOne Class")
]
coclass TestOne
{
[default] interface ITestOne;
};
[
uuid(31E6DA9C-DE0D-4B69-A259-1D39E136D31F),
helpstring("TestTwo Class")
]
coclass TestTwo
{
[default] interface ITestTwo;
};
};
Now I want to _really_ derive ITestTwo from ITestOne so both interfaces will be available in ITestTwo. To do this I change the following:
From: interface ITestTwo : IUnknown {};
To: interface ITestTwo : ITestOne
So far so good???... If so I then should be able to do the following (I only added the TestOneInterface() function to existing code generated by VS):
/**** CTestTwo Declarations ****/
class ATL_NO_VTABLE CTestOne : public CTestTwo
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCoClass<ctestone, clsid_testone="">,
public ISupportErrorInfo,
public ITestOne
{
public:
CTestOne()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_TESTONE)
BEGIN_COM_MAP(CTestOne)
COM_INTERFACE_ENTRY(ITestOne)
COM_INTERFACE_ENTRY(ISupportErrorInfo)
END_COM_MAP()
// ISupportsErrorInfo
STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
/**** CTestOne Implementations ****/
STDMETHOD(TestOneInterface)( void ) { }
};
OBJECT_ENTRY_AUTO(__uuidof(TestOne), CTestOne)
/**** CTestTwo Declarations ****/
class ATL_NO_VTABLE CTestTwo :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CTestTwo, &CLSID_TestTwo>,
public ITestTwo
{
public:
CTestTwo()
{
}
DECLARE_REGISTRY_RESOURCEID(IDR_TESTTWO)
BEGIN_COM_MAP(CTestTwo)
COM_INTERFACE_ENTRY(ITestTwo)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
HRESULT FinalConstruct()
{
return S_OK;
}
void FinalRelease()
{
}
public:
/**** CTestTwo Implementations ****/
STDMETHOD(TestTwoInterface)( void ) { }
};
OBJECT_ENTRY_AUTO(__uuidof(TestTwo), CTestTwo)
|
|
|
|
|
Hello
I am using multicast delegate as follows, but the effect in the server is undesirable:
Thing.OnEvent1 += new IThingEvents_OnEvent1EventHandler(OnEvent1);
Thing.OnEvent2 += new IThingEvents_OnEvent2EventHandler(OnEvent2);
Thing.OnEvent3 += new IThingEvents_OnEvent3EventHandler(OnEvent3);
The problem is that the (C++ COM) server it thinks it has all the connections for each event.
So in the below example it trys to send the event 3 times. Apart from the unecessary processing, I am worried it is making the inter-process call each time (the incorrect calls are being thrown away on the client side somewhere).
HRESULT Fire_OnOrderCancel(lots of params)
{
HRESULT hr = S_OK;
T * pThis = static_cast(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[20];
//set avarParams
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 9, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
}
}
return hr;
}
What c# thing do I need to use to get the desired behaviour, namely events to be fired once and the c# client to do the correct delegation?
Many Thanks
deds
|
|
|
|
|
Hi,
I need to get the physical name of the currently selected spreadsheet, like MySpreadsheet.xls. How do I do this?
Brendan
|
|
|
|
|
Application.ActiveWorkbook.Name
Application.ActiveWorkbook.FullName
in terms of your programming language.
With best wishes,
Vita
|
|
|
|
|
Hai all..
I am using ISpecifyPropertyPages and OleCreatePropertyFrame to displayed webcam videostreaming property dialog but i want get the output image size that is selected from webcam property dilaog.. Pls help me some sample code.
Thanks in advance
Mani..
|
|
|
|
|
We have a windows service executing on a windows 2003 box as the 'LocalSystem' account.
This service spawns off a executable.
The executable in turn tries to create an instance of a COM object housed in a dll.
However we find that in a particular host,the executable fails at the point where it tries to intialize COM through CoInitialize.
We believe it is due to some permission violations on the box.
What are the services/permissions to be in place for a windows service account to be able to invoke COM?
|
|
|
|
|
The problem is that the application does not even start executing a single line and returns with a file not found error ;however when the same application is executed from console(and not from a service as 'localsystem' account),it executes fine.
But we found that when we comment off the 'CoInitiliazie' call then things seem fine for the application (though we obviously cannot invoke COM)
|
|
|
|
|
So were you able to figure out what was wrong with CoInitialize?
|
|
|
|
|
I want to write a ActiveX control for word, which has the transparent effect,which can't envelop the test in word document no matter what drawn in the control. But I don't know how to achieve the transparent effect. My English is poor. I hope you can follow me and can help me
|
|
|
|
|
Does anyone know how to use these new Vista COM objects in a C# project. I am talking about the IFileDialog objects/classes/libraries/idl's and all that inherit from it.
Thanks,
Adam
|
|
|
|
|
The best place to point you is probably the Common Item Dialogs[^] documentation.
I would expect Microsoft to change OpenFileDialog (etc) to eventually wrap these new interfaces, for whatever new functionality is available (if they haven't already in v3.5). What specifically does this do that you don't get from OpenFileDialog ?
DoEvents: Generating unexpected recursion since 1991
|
|
|
|
|
Follow this step:
1.You can download
Windows® API Code Pack for Microsoft® .NET Framework
2.See how the "\Windows API Code Pack 1.1\source\WindowsAPICodePack\Shell\CommonFileDialogs\CommonFileDialog.cs" make use of IFileDialogCustomize from com.
3.If you want to add a stuff to the "Open" dropdownlist,
you can write code below
customize.EnableOpenDropDown(0);
customize.AddControlItem(0, 0, "Open as XXX");
customize.AddControlItem(0, 1, "Open in YYY");
Note: 0 is the Open Button ID
After user selected, you can get the selectedIndex through
this.customize.GetSelectedControlItem(0, out openindex);
Note again: 0 is the Open Button ID
And then you can do something imply with filename and this openindex.
Wish to help you~
|
|
|
|
|