 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Stan R. Guest
|
Posted: Thu Jul 06, 2006 8:10 am Post subject: Load com dll? |
|
|
Hello. I am developing a Com DLL in Visual Studio 2003 .NET, more
specifically, using the Perl Dev Kit add on which allows me to compile
Perl 5 code into EXE, Services, and DLLs (using COM.)
In the example provided with the PDK, the Com Object is invoked (in a
sample vbScript) as so:
Dim objMyControl
Set objMyControl = CreateObject("My.Control")
This of course works only after running the `regsvr32 MyControl.dll` at
the command line.
So my question is, how do you load a COM dll in BCB (using BCB 5 Ent) ?
Also, is it possible ot load the DLL straight in the program without
having to register it with regsvr32?
If not, then what is the equivilent method for the VBS code above?
I really hope this can work because if I can access Perl function in
this way it will save me a lot of coding for a text processing
application i'm writing. I have a whole slew of routines writen in Perl
that handle the massive jobs with ease, so you can see why I wanted some
way to use them in my C++/Win32 applications.
P.S.
I found BCB to be a great app, always loaved it, but I could never for
thel ife of me understand why the VCL didn't include any RegEx? I know
about the PCRE Lib for C++, but if you've ever used RegEx in Perl 5, you
will groan in anguish looking at equivilent coding done with PCRE :-)
--
Stan |
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jul 06, 2006 8:10 am Post subject: Re: Load com dll? |
|
|
"Stan R." <none@none> wrote in message
news:44ac963f (AT) newsgroups (DOT) borland.com...
| Quote: | So my question is, how do you load a COM dll in BCB (using BCB 5 Ent) ?
|
You can do the same thing that you did in the VBScript. The VCL's Variant
class has a CreateObject() method. Objects in VB are wrapped as VARIANTs
anyway.
However, I would not recommend that approach for C++. It is better to use
the Win32 API's CoCreateInstance() function to access the COM interfaces
directly instead.
| Quote: | Also, is it possible ot load the DLL straight in the program
without having to register it with regsvr32?
|
Technically yes. Use LoadLibrary() to load the DLL into memory, then use
GetProcAddress() to access the DLL's DllGetClassObject() function. You can
then use DllGetClassObject() to retreive the DLL's IClassFactory interface,
and from that you can use its CreateInstance() method to create other
objects that the DLL supports.
This is what CoCreateInstance() does internally, so you would be better off
just registering the DLL and letting the OS do all of the work for you.
| Quote: | I really hope this can work because if I can access Perl function in
this way it will save me a lot of coding for a text processing
application i'm writing. I have a whole slew of routines writen in Perl
that handle the massive jobs with ease, so you can see why I wanted
some way to use them in my C++/Win32 applications.
|
The OS has its own build-in Scripting Host to run scripts. You can run a
script that is written in any language that there is a scripting engine
installed for. So if you had a compatible PerlScript engine installed, you
can run Perl scripts directly. Look at the IActiveScript and
IActiveScriptParse interfaces in MSDN's documentation.
Gambit |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|