Archive: Plugin for controlling Internet Explorer


Plugin for controlling Internet Explorer
Hi,

I've created a plugin for controlling Internet Explorer. I haven't found anything like it yet. Or anyway, that has the ability to make toolbars visible in Internet Explorer.

I know, it's a bit big (51K) but I couldn't get it to compile/link smaller :igor:

Anyway, it does the following, not much, but it can easily be expanded upon:

- Open an internet explorer instance
- Surf to an URL
- Make a toolbar visible (you need to know its CLSID)
- Close the browser.

source files included.

Remco Lam


can't look at your code at the moment but have a look at the source code for the plugin here which may be of use in showing how you can cut the dll size down :)

the code has a similar feature to you're plugin i guess and when i put the code in it only added 1k to 1.5k to the plugin's size (was thinking of coding a similar plugin myself but don't need to now i guess ;) )

hope this is of some help

-daz


I've downloaded and compiled that plugin and compared all the settings.

I could copy almost all settings and it still worked. All except the entrypoint, if I set that I get the following error:

libcmt.lib(crt0.obj) : error LNK2001: unresolved external symbol _main

Besides, I think most of the filesize probably comes from the my inclusion of COM pointers... (comdef.h) But if anyone manages in creating a smaller dll, I'd be very interested :)


the reason for the size is because of 'libcmt.lib' which is the c run time (crt) library. had a look and you're using things like sprintf, memset and using the default 'new' and 'delete' operators.

in my code i redefine the 'new' and 'delete' operators to not use the crt and if you put in you're own memset function and to use wsprintf(..) then that should cut things down :)

if you don't beat me to it i'll post a modified version for you

-daz


Make a toolbar visible
It can't be done using the registry?

And the other features:

- Open the Internet Explorer: Using the function "Wait file execution registry based" and just renaming the part that says (like) ExecWait "$..." to Exec "$...".
- Close the Internet Explorer: Have some functions in Archive for it.
- Opening an URL: Executing (i.e.) http://www.test.com using "Wait file execution registry based" (see Open the Internet Explorer).

(to get the function "Wait file execution registry based", see it in my signature)

Originally posted by deguix
[B]It can't be done using the registry?
It probably can, but I've looked into that, and it looks like IE stores its active toolbars in a binary registry setting. Good luck deciphering that! :p

And of course, you could use other functions to open IE and surf to an URL. But my point was this one can easily be extended for all sorts of functions. You can even receive IE events (although I don't know why you'd need that in an installer)

Dr0:
Much obliged if you'd post that updated version. I'm pretty goed at high level programming, but don't ask me about low level code optimizations... Although I'll certainly take a look at your code and play around with it. Always good to learn something new. Why, just this week I learned how to make an installer using NSIS :)

Remco

here's what i've done (only 4.5k now :) ) i have stripped some bits from the project (exdll dependancies which weren't needed) and a few other bits.

the link error was to do with the crt being included :( i've altered the Navigate and Toolbar functions (the Navigate definitely works but you'll need to check the toolbar one out)

for interest it is related to the _bstr_t (taken from an msdn example)

Favorites Reader uses some of the new C++ smart pointers and new types available in Visual C++ 5.0 such as _bstr_t. These features clean up the code significantly but unfortunately they do require the C Run-time. This does increase the size of the DLL a bit.
40k is a bit (bigger than a basic nsis installer :rolleyes: )

-daz

Originally posted by DrO
here's what i've done (only 4.5k now :) ) i have stripped some bits from the project (exdll dependancies which weren't needed) and a few other bits.
Wow! I'm impressed. As I said before, I've never really looked at how to optimize my code for size.

Unforunately, showbar doesn't work anymore...

Which is really weird, since I've stepped through the execution and the BSTR variant looks exactly the same whether I fill it using your functions or whether I use _bstr_t as a cast. (I put it back in just to test)

:(

Remco

Just relalized something. I think the problem is with bstr ownership.
When I do this:
vtBandGUID1.bstrVal = _bstr_t(szBarCLSID);

the _bstr_t class knows its being assigned to another BSTR and so relinguishes control over the BSTR (Or allocates a new BSTR)

When I do:
vtBandGUID2.bstrVal = bBarCLSID;

Nothing special is done and the call of ShowBandObject doesn't have access to the bstr that is being passed on.
VariantClear() afterwards isn't even necessary...

Or am I completely off track here... I have to admit, I've been bluffing my way through COM without really understanding it :P

Remco


Well, I was right, I've solved it.

I just needed to add SysAllocString

So the call now is:
vURL.bstrVal = SysAllocString(bstrUrl);

Thanx for the downsizing help daz!

Give me sec and I'll upload a new working version


Well, here it is. The dll is now 4.5K

Actually the bug is pretty obvious, once you see it :)

Again, thanks daz

Remco


just seen this has changed.

it was no problem plus a 4.5k is a lot nicer ;)

-daz

[edit]
just checked out the new version and i see you haven't updated the text file -> still refers to a 56k file size. pointing it out in case you haven't noticed it already ;)
[/edit]


Originally posted by DrO

just checked out the new version and i see you haven't updated the text file -> still refers to a 56k file size. pointing it out in case you haven't noticed it already ;)
Does this justify uploading it again? I think I'll just leave it this way. I'll change it locally in case I ever need to distrtibute it again. Thanks for the tip :)

<edit>
Well, I'll upload it again, I've made some changes anyway
>/edit>

Remco

Here's a new version. The attached zip contains the 2 dll's, one real small one (3.5K) that works just fine. And a slightly bigger one (5.1K) that displays some messageboxes when an error occurs.

Of course I've also updated the included text file.

Greets

Remco


No Archive page? :(


Originally posted by kichik
No Archive page? :(
Is that something I should do? I'm still new to all this :p

Remco

archive is here

you will need to register as a user for the archive (is up at the top of the page to do that). once your registered then go down to 'contribute' (or similar worded) and follow the instructions.

as a note you should probably link to the most current version you have in this thread on the page you create.

-daz


Originally posted by DrO
as a note you should probably link to the most current version you have in this thread on the page you create.
Ah, that last one, I didn't think of that... I'd already checked the contrib part of the archive, but since I wasn't allowed to upload I didn't see the point in submitting anything :D

I'll make a page right away...

<EDIT>
It is done!
</EDIT>
Remco

I downloaded the plugin and put it in:

C:\Program Files\NSIS\Plugins

And then I tried compiling this:


outFile "installer.exe"
section
IEFunctions::OpenBrowser /NOUNLOAD
sectionEnd


only to get this error:

Invalid command: IEFunctions::OpenBrowser
Error in script "C:\Documents and Settings\jnowacki\Desktop\NSIS\link.nsi" on line 7 -- aborting creation process


Suggestions?


Make sure you put IEFunctions.dll not IEFunctionsDbg.dll in there. Also what are you doing exactly? If you want to just open a web page, just use ExecShell open `http://...`

Stu