Custom toolbar compatible for IE Protected Mode - c++

I have created a custom toolbar for IE. I am placing my COM DLL in System32 folder. IE is able to load my toolbar in protected mode. My toolbar should read some data from ini file which is created in InternetCache folder. I am not registering my COM component to any category (e.g. CATID_AppContainerCompatible).
My question is
1) Is it compulsory to place the my DLL in sub folder of program files?
2) Do I need to register to app container category?
3) How can I make sure that my toolbar is compatible with protected mode.
Thanks in advance.
Regards,
Santhosh

I used to develop a BHO for IE6+ before and hope you'll find those answers useful.
1) Is it compulsory to place the my DLL in sub folder of program files?
Don't remember exactly but if it's both signed and placed under a trusted location the more chances IE will pick it up.
2) Do I need to register to app container category?
Just registering a COM DLL module should be enough.
3) How can I make sure that my toolbar is compatible with protected mode.
It is by default but in protected mode you'll receive 'access denied' error on attempts of reading from or writing to many locations both on file system and in registry.
In registry you can use HKEY_CURRENT_USER\Software\AppDataLow and %USERPROFILE%\AppData\LocalLow on file system.

Related

How to unload ActiveX's ocx without terminating main application to allow the ocx to be overwritten?

I have ActiveX controls implemented in VB6 and are instantiated inside MFC42 application.
I have a tree view structure on the left panel of the application and when different items in the tree are selected, different ActiveX are loaded accordingly on the right panel to display the details of the selected item.
Whenever I want to modify the VB code for the ActiveX, I will need to restart the application. This greatly interrupts the development flow since the application starts pretty slowly.
In some ActiveX we have dummy code/data to allow the ActiveX to be executed inside Internet Explorer, which is faster to load, but not all of our ActiveX have it.
I am expecting that when I click different item in the tree view, the previous ActiveX is unloaded and I can overwrite it with a new version.
If the ActiveX has never been instantiated/displayed, I am able to replace the ocx while the application is still running.
I searched in the internet and found two articles on ActiveX, both of them suggest that the proper way to clean up is to:
m_pControl = new CWnd;
m_pControl->CreateControl(strControlProgid,
"",
WS_VISIBLE,
rc,
this,
5000,
NULL,
FALSE,
NULL);
// ...
m_pControl->DestroyWindow();
delete m_pControl;
The ActiveXs we have are already destroyed using this method but I still need to exit the application in order to overwrite the ocx.
EDIT:
Alternatively, for VC++ 6 (with MFC42), instead of CoFreeUnusedLibrariesEx which is mentioned by Noseratio in his answer; I can use CoFreeUnusedLibraries which will work without delay for Single Threaded Apartement (STA).
Provided the COM reference counting works correctly in your app, you could try forcing to unload the no-longer-in-use ActiveX DLL with CoFreeUnusedLibrariesEx.

Custom dialogs and porting wid in WiX

I have a custom dialog which has an extension wid (CustomDialog.wid) and has a helper library to go with it written in C++. The helper library searches for SQL Servers in the network and fills the combobox in the custom dialog. It also saves the server name or IP address so that it may be used by custom actions later.
Can I use this custom dialog directly in WiX or do I need to create a WiX supported custom dialog?
You can convert them into WiX format by building a Visual Studio Setup and Deployment project and then using WiX's dark.exe to create a .wxs file. The output may or may not be completely useful but it's worth a try. You'd probably want to make the dialog size and layout are the same as any "built-in" WiX dialogs you might use in your new project.

Retrieving ActiveX classID from the system registry with C++

I am working on a windows application that has a shockwave flash player embedded in it.The C++ part should be able to call Flash movie methods and vice versa.Initial experiment was done using MFC.It works.But now I want to port it to Qt as it allows easier UI development.Qt has got QAxObject which holds the ActiveX control you assign to it via setCotrol() method which should get a classID of the ActiveX or its name.Because the classID is more reliable than a name and because I have not found an example where flash player ActiveX is accessed using a name ,now I want to know how to retrieve that classID from the system registry of the OS.I suppose that for every machine some specific activeX classID may vary (correct me if I am wrong on it) .If it is true then I need to access the registry ,find shockwave activeX classid and then pass it into QaxObject::setControl() method.How do I do that?
Forgot to mention that in MFC application the ActiveX control gets the requested ActiveX automatically once you select the ActiveX type from the list of available system controls.In Qt you have no such an option.
Reading this http://www.nirsoft.net/utils/acm.html I understand that the CLASSID is constant on any machine.Is it true ? If yes then please discard my question as there is no reason searching for the ActiveX key on specific machine by the ProgID if it is the same always.
Thanks.
It would be better to query from the registry by mime type. You can find details on where that is stored here:
http://msdn.microsoft.com/en-us/library/aa751976%28v=vs.85%29.aspx
You can look up the mimetype in the registry and get the CLSID from that. You can look it up by name as well; the locations of both registry keys are explained in that document.

How can save Application Settings in the Registry via MFC?

I have a MFC application created by the MFC Project Wizard. I wanted to save/read application settings in the registry and so asked this question to find a C++ Registry wrapper as the Windows API is very messy. However, I have now heard that the MFC provides a way to do this. Is this true? If so, how can I read/write values, see whether a key exists and get a list of all the keys?
MFC provides an easy way to read/write Windows registry.
In your project you'll have a global CMyProjectName theApp; object.
CMyProjectName inherits CWinApp class which provides the SetRegistryKey() method.
That method sets theApp to write in the registry instead of an "ini" file.
In the documentation check out
CWinApp::GetProfileInt
CWinApp::GetProfileString
CWinApp::WriteProfileInt
CWinApp::WriteProfileString
methods on how to read and write integers and strings in the registry.

How to convert an ActiveX (webbrower hosted) project into static library project?

I have an ActiveX component which contains a control (webbrowser control embedded in composite control dialog pane) for accessing certain URL. The ActiveX component accessing URL can be used in other MFC or VB projects. The usage is to register the ActiveX component (use regsvr32 cmd) and then insert the control in a dialog window by using "Insert ActiveX control".
Now I am planning to convert the ActiveX component to static library with the same browser window and web access functions. I wonder how to do it? In addition, how the browser window (in static library) can be used in other MFC projects. Is it through functions call? Is there a sample project available?
I used Microsoft .Net 2003 as development tool.
Thank you very much in advance.
I'm a little unclear about the extent to which you think you can put all of that in a static library.
This is probably not going to be as straightfoward as you think. The wizard and code in VS/MFC/ATL which allows you to insert an ActiveX control in a dialog is doing a lot of work for you. That said, it makes certain assumptions about the nature of the site for the ActiveX control, such as how the message pump works, who is the owner window, the threading model, and so on. In a dialog, these are knowns. In another context, they are not.
The right way to go about doing what you're doing is to leave it as an ActiveX control. Maybe if you stated what problem you are trying to solve by putting it into a static library, we could give other options.
The WebBrowser ActiveX control is really a wrapper for the shdocvw.dll library, in the system32 folder. shdocvw.dll is the heart and soul of IE (and, by extension, much of the Windows Explorer interface). It's all very heavily based on COM, which has its own rules for loading libraries and so on. So the site (any application which wants to use your ActiveX control) really needs to be friendly to ActiveX/COM anyway.