Re: ActiveX EXE
- From: Bee <Bee@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 30 Sep 2009 14:16:01 -0700
Food for thought.
This is a little different and I think superior to other things I have seen.
So now I go into study mode.
Thanks!
"mayayana" wrote:
For documentation see here:.
http://pntpm3.ulb.ac.be/Info/Activex/
That's about the only substantial docs I
know of.
The project I linked is a DLL, but they're very
similar. An EXE is out-of-process and can have
events, but other than that it's almost the same.
Both have dual COM interfaces (for early or late
binding). Both can have GUI elements. Both are
typically based on one creatable, public class and
can also have additional creatable classes and/or
non-creatable public classes. The DLL sample I
linked was designed to show all those options in
as simple a way as possible. I've written a number
of EXEs but they're quite complex in their
functionality. (An SMTP emailing component, an
http component, and a progress bar. The first two are
EXEs because I needed asynchronous operation and
events: There's usually a time lag when talking to
a web server and the "conversation" requires passive
reception. The progress bar is an EXE so that it can
run from a script without getting caught up in the
script's execution process.)
The "all in one client server project" is just a way
to test the component as you're writing it. Once it's
compiled it gets registered and then you create the
object from any project/process. But since it's a creatable
COM object you need a "client" in order to test it.
You can do it in two projects if you want to. Each
time you compile the EXE in one project, a second
project that references it will get the new version
because VB automatically registers during compile.
(Also see note below about project compatibility
vs binary compatibility.)
VB should take care of that with each compile. When
you ship you'll probably want to register the EXE during
install.
( You don't actually have to register an EXE. It will
register itself when run. But when you're creating the
object it will need to be registered. Conveniently,
all ActiveX EXEs have a command line option that
causes them to self-register:
[full path of ActiveX EXE] & " /regserver"
)
It might be easiest to start the project and then
ask questions, but if you don't know where to start
at all, this might help:
Start an ActiveX EXE project. By default it will be
Project1 with a class named Class1. That defines
your ProgID servername.classname for the object.
In Class1 put this and then compile it:
Public Function YooHoo() As String
YooHoo = "hi there"
End Function
Project properties: Don't worry about it for now,
but you want thread-per-object to allow for multiple
created instances running separately. And once you get
the basic interface set up you will probably want to
switch to binary compatibility. Project compatibility
results in a new CLSID with each compile, so any
references to the last compile will no longer be valid.
Open a second project -- a basic EXE. Name the
project Project1test so that it won't be "Project1".
Set a reference to Project1. Put a button on Form1
and add this code:
Private Sub Command1_Click()
Dim P1 As Project1.Class1
Set P1 = New Project1.Class1
MsgBox P1.YooHoo
Set P1 = Nothing
End Sub
Now run your project and click the button.
That's the gist of it. Then there are options like having
events, code that you might want to run in the
Intialize and Terminate events, etc. And of course
you can have subs and properties in your public
class. But what I've shown above is the basic functionality.
Your ActiveX EXE gets registered. Then any process
can create as many separate instances as desired.
In case it's of any help, here's a link to a progress
bar used in scripting. The sample scripts show how
there can be numerous bars running separately:
www.jsware.net/jsware/scripts.php5#snaz
The code is not in the package, and it's probably
more than you want to deal with, but the download
might be of interest just to see a typical interface
("object model") if you're not clear about that.
- Next by Date: Re: Was going to.........
- Next by thread: Re: ActiveX EXE
- Index(es):
Loading