 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Danid Guest
|
Posted: Wed Jul 27, 2005 3:49 pm Post subject: DLL registration |
|
|
Please help,
I want to create a dll to use it is web page using ASP.
In the past I created an OCX component and registered it (regsvr32.exe) and then if I search the register I found the component with its clsid.
In the case of the DLL, I register it by the same way as I did for the ocx, but then If I cannot find it in the register if I search for it.
Is the registration of a DLL different from OCX? Shoud I add more things to the DLL to be registered correctly?
Thanks in advance,
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Jul 27, 2005 4:44 pm Post subject: Re: DLL registration |
|
|
"Danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | In the case of the DLL, I register it by the same way as I did for
the ocx, but then If I cannot find it in the register if I search for it.
Is the registration of a DLL different from OCX?
|
No.
Does the DLL contain ActiveX/Com objects to begin with?
Gambit
|
|
| Back to top |
|
 |
danid Guest
|
Posted: Wed Jul 27, 2005 5:55 pm Post subject: Re: DLL registration |
|
|
Here are the steps I make to create a DLL:
File->New->ActiveX->ActiveX Library
I add my own functions and the compile it.
I call it in my C++ app by LoadLibrary() and it works.
But I have no experience with using it in a web page. I know that I have to register it first.
I use BCB6
Thanks
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"Danid" <danid (AT) yahoo (DOT) com> wrote in message
news:42e7ad0a$1 (AT) newsgroups (DOT) borland.com...
In the case of the DLL, I register it by the same way as I did for
the ocx, but then If I cannot find it in the register if I search for it.
Is the registration of a DLL different from OCX?
No.
Does the DLL contain ActiveX/Com objects to begin with?
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Wed Jul 27, 2005 7:18 pm Post subject: Re: DLL registration |
|
|
"danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | File->New->ActiveX->ActiveX Library
|
That creates a DLL with no ActiveX/COM objects added to it. You have to do
that separately. Without any ActiveX/COM objects, registering the DLL is
useless as there is nothing available to register. In order to use the DLL
in an ASP script, you must add ActiveX/COM objects to the DLL as well, as
that is what the ASP code will actually be working with.
Gambit
|
|
| Back to top |
|
 |
danid Guest
|
Posted: Thu Jul 28, 2005 8:35 am Post subject: Re: DLL registration |
|
|
Thanks Gambit, that's a step forward.
Now I add a COM Object to my project then I register it. I can see the name of the added COM in the register. But when I try to call it in my ASP page (Server.CreateObject) I get the following error:
"No such Interface supported"
What I am doing wrong again?
Thanks,
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"danid" <danid (AT) yahoo (DOT) com> wrote in message
news:42e7ca8a$1 (AT) newsgroups (DOT) borland.com...
File->New->ActiveX->ActiveX Library
That creates a DLL with no ActiveX/COM objects added to it. You have to do
that separately. Without any ActiveX/COM objects, registering the DLL is
useless as there is nothing available to register. In order to use the DLL
in an ASP script, you must add ActiveX/COM objects to the DLL as well, as
that is what the ASP code will actually be working with.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jul 28, 2005 4:49 pm Post subject: Re: DLL registration |
|
|
"danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | Now I add a COM Object to my project then I register it. I
can see the name of the added COM in the register. But when
I try to call it in my ASP page (Server.CreateObject) I get the
following error:
"No such Interface supported"
|
I cannot answer that because you did not explain EXACTLY what you did.
Please explain, step by step, everything that you did.
Gambit
|
|
| Back to top |
|
 |
danid Guest
|
Posted: Thu Jul 28, 2005 7:54 pm Post subject: Re: DLL registration |
|
|
I created an ActiveX project:
File->New->Other->ActiveX->ActiveX Library
I added a new COM Object
File->New->Other->ActiveX->COM Object
coClassName: coTestClass
Threading Model: Apartment
Implemented Interface: IcoTestClass
in the coTestClassImpl.h I added:
int doAdd(int i1, int i2);
in the coTestClassImpl.cpp I added:
int TcoTestClassImpl :: doAdd(int i1, int i2)
{
return i1 + i2;
}
I saved, compiled and got a DLLTEST.dll
I then run regsvr32 DLLTEST.dll
In the register I have DLLTest.coTestClass that I want to use in ASP
SET testObj = Server.CreateObject("DLLTest.coTestClass")
In this line I get the error:
"No such interface supported"
Thanks,
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"danid" <danid (AT) yahoo (DOT) com> wrote in message
news:42e898d9$1 (AT) newsgroups (DOT) borland.com...
Now I add a COM Object to my project then I register it. I
can see the name of the added COM in the register. But when
I try to call it in my ASP page (Server.CreateObject) I get the
following error:
"No such Interface supported"
I cannot answer that because you did not explain EXACTLY what you did.
Please explain, step by step, everything that you did.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jul 28, 2005 8:25 pm Post subject: Re: DLL registration |
|
|
"danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | in the coTestClassImpl.h I added:
int doAdd(int i1, int i2);
|
Did you add that method to IcoTestClass by using the Type Library Editor?
It does not look like you did. You must use the Type Library Editor to make
any changes/additions to the COM object and CoClass.
| Quote: | In the register I have DLLTest.coTestClass that I want to use in ASP
SET testObj = Server.CreateObject("DLLTest.coTestClass")
|
That is likely not the correct ProgID string to use. You need to use the
exact same string that appears in the DECLARE_PROGID macro inside of
coTestClassImpl.h. In the Type Library Editor, did you name your COM
object's module to be "DllTest"? If your COM object set up as the default
interface for the CoClass?
Gambit
|
|
| Back to top |
|
 |
danid Guest
|
Posted: Thu Jul 28, 2005 9:23 pm Post subject: Re: DLL registration |
|
|
Thanks for taking time to look at my problem.
I followed your last instructions but I still get the same error.
Can you please show me step by step how I can get this to work?
Thanks,
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"danid" <danid (AT) yahoo (DOT) com> wrote in message
news:42e937e6$1 (AT) newsgroups (DOT) borland.com...
in the coTestClassImpl.h I added:
int doAdd(int i1, int i2);
Did you add that method to IcoTestClass by using the Type Library Editor?
It does not look like you did. You must use the Type Library Editor to make
any changes/additions to the COM object and CoClass.
In the register I have DLLTest.coTestClass that I want to use in ASP
SET testObj = Server.CreateObject("DLLTest.coTestClass")
That is likely not the correct ProgID string to use. You need to use the
exact same string that appears in the DECLARE_PROGID macro inside of
coTestClassImpl.h. In the Type Library Editor, did you name your COM
object's module to be "DllTest"? If your COM object set up as the default
interface for the CoClass?
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Thu Jul 28, 2005 10:29 pm Post subject: Re: DLL registration |
|
|
"danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | I followed your last instructions but I still get the same error.
|
Then you need to post your actual files, because you apparently still have
not set them up correctly.
| Quote: | Can you please show me step by step how I can get this to work?
|
You already know step by step what to do now.
Gambit
|
|
| Back to top |
|
 |
Danid Guest
|
Posted: Sat Jul 30, 2005 4:44 pm Post subject: Re: DLL registration |
|
|
I posted my code in borland.public.attachements: DLL registration
Thanks
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"danid" <danid (AT) yahoo (DOT) com> wrote in message
news:42e94cee$1 (AT) newsgroups (DOT) borland.com...
I followed your last instructions but I still get the same error.
Then you need to post your actual files, because you apparently still have
not set them up correctly.
Can you please show me step by step how I can get this to work?
You already know step by step what to do now.
Gambit
|
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Jul 30, 2005 7:12 pm Post subject: Re: DLL registration |
|
|
"Danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | I posted my code in borland.public.attachements: DLL registration
|
You need to check your computer's clock. The message was dated January 1.
I see several things wrong with your project:
1) in the Project Options, under the "Linker" tab, you have the "Use dynamic
RTL" option enabled, and under the "Packages" tab you have the "Build with
runtime packages" option enabled. With those two options enabled, your DLL
is *not* self-contained. It has dependancies on several external libraries
that would have to be distributed along with the DLL in order for it to
operate correctly. You should disable both of those options so that the DLL
does not have those dependancies.
2) in the Project Options, under the "ATL" tab, you should change the
"Instancing" option to "Single Use".
3) your doCount() method is not implemented properly. You are using the
method's return value to return the sum of the provided parameters. That is
not the correct way to return a value from a COM control. All COM methods
must return an HRESULT indicating whether the operation was successful or
not. The actual return value is handled via an additional method parameter
that is marked as [out, retval]. For example:
--- ActiveX10_TLB.h ---
interface ICoActiveX10 : public IUnknown
{
public:
virtual HRESULT STDMETHODCALLTYPE doCount(int i1/*[in]*/, int
i2/*[in]*/, int* result/*[out,retval]*/) = 0; // [1]
};
--- CoActiveX10Impl.h ---
public:
STDMETHOD(doCount(int i1, int i2, int* result));
--- CoActiveX10Impl.cpp ---
STDMETHODIMP TCoActiveX10Impl::doCount(int i1, int i2, int* result)
{
*result = i1 + i2;
return S_OK;
}
Gambit
|
|
| Back to top |
|
 |
danid Guest
|
Posted: Sun Jul 31, 2005 3:35 pm Post subject: Re: DLL registration |
|
|
Thanks again. It worked, finally :)
I made an ocx component with a method doCount(int i1, int i2, int *result), I tested it in ASP and I got the result
set conn= Server.CreateObject("OCXActiveProj1.OCXActive")
dim x, y, z
x = 3
y = 4
Response.write conn.doCount(cint(x), cint(y))
Now I want to call it using Borland C++:
typedef int WINAPI (*FuncPtr)(int, int, int*);
void __fastcall TForm1::Button3Click(TObject *Sender)
{
HMODULE dll_handle = LoadLibrary("D:\Dev\test\OCX1\OCXActiveProj1.ocx");
if (!dll_handle)
ShowMessage("Error: could not load OCXActiveProj1.ocxn");
else
{
FuncPtr doCount= (FuncPtr) GetProcAddress(dll_handle, "doCount");
int i1 = 1;
int i2 = 3;
int *result;
if (!doCount)
ShowMessage("Error: could not find address of function doCountn");
else
ShowMessage(AnsiString(doCount(i1, i2, result));
FreeLibrary(dll_handle);
}
}
I get the error:
Error: could not find address of function doCount
Another question:
Is it possible to use TADOQuery in an OCX component and if yes, how? let say I want to make a method that counts the records in a table ADO->RecordCount();
Danid
"Remy Lebeau (TeamB)" <no.spam (AT) no (DOT) spam.com> wrote:
| Quote: |
"danid" <danid (AT) yahoo (DOT) com> wrote in message
news:42e937e6$1 (AT) newsgroups (DOT) borland.com...
in the coTestClassImpl.h I added:
int doAdd(int i1, int i2);
Did you add that method to IcoTestClass by using the Type Library Editor?
It does not look like you did. You must use the Type Library Editor to make
any changes/additions to the COM object and CoClass.
In the register I have DLLTest.coTestClass that I want to use in ASP
SET testObj = Server.CreateObject("DLLTest.coTestClass")
That is likely not the correct ProgID string to use. You need to use the
exact same string that appears in the DECLARE_PROGID macro inside of
coTestClassImpl.h. In the Type Library Editor, did you name your COM
object's module to be "DllTest"? If your COM object set up as the default
interface for the CoClass?
Gambit
|
|
|
| Back to top |
|
 |
danid Guest
|
Posted: Sun Jul 31, 2005 3:36 pm Post subject: Re: DLL registration |
|
|
Thanks again. It worked, finally :)
I made an ocx component with a method doCount(int i1, int i2, int *result), I tested it in ASP and I got the result
set conn= Server.CreateObject("OCXActiveProj1.OCXActive")
dim x, y, z
x = 3
y = 4
Response.write conn.doCount(cint(x), cint(y))
Now I want to call it using Borland C++:
typedef int WINAPI (*FuncPtr)(int, int, int*);
void __fastcall TForm1::Button3Click(TObject *Sender)
{
HMODULE dll_handle = LoadLibrary("D:\Dev\test\OCX1\OCXActiveProj1.ocx");
if (!dll_handle)
ShowMessage("Error: could not load OCXActiveProj1.ocxn");
else
{
FuncPtr doCount= (FuncPtr) GetProcAddress(dll_handle, "doCount");
int i1 = 1;
int i2 = 3;
int *result;
if (!doCount)
ShowMessage("Error: could not find address of function doCountn");
else
ShowMessage(AnsiString(doCount(i1, i2, result));
FreeLibrary(dll_handle);
}
}
I get the error:
Error: could not find address of function doCount
Another question:
Is it possible to use TADOQuery in an OCX component and if yes, how? let say I want to make a method that counts the records in a table ADO->RecordCount();
Danid
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Aug 01, 2005 5:32 pm Post subject: Re: DLL registration |
|
|
"danid" <danid (AT) yahoo (DOT) com> wrote
| Quote: | I made an ocx component
|
You do not need to use an OCX in this situation. A DLL works just fine.
You should use OCX for visual components, not non-visual ones.
| Quote: | Now I want to call it using Borland C++:
snip |
You are taking the completely wrong approach to do that. You need to add
the DLL's TLB.cpp into your project and then creating an instance of the
TLB's CoClass object, ie.
#include "OCXActiveProj1_TLB.h"
void __fastcall TForm1::Button3Click(TObject *Sender)
{
// names may vary depending on your actual implementation...
TCOMIOCXActive OCX = CoOCXActiveProv::Create();
if( OCX )
{
int i1 = 1;
int i2 = 3;
int *result;
HRESULT hRes = OCX->doCount(i1, i2, &result);
if( SUCCEEDED(hRes) )
ShowMessage(result);
else
ShowMessage("Error: doCount() failed, HRESULT = " +
AnsiString(hRes));
}
else
ShowMessage("Error: could not load OCXActive");
}
| Quote: | I get the error:
Error: could not find address of function doCount
|
That is correct, because doCount() is not an exported function to begin
with. You cannot use GetProcAddress() to retreive a pointer to it. It is a
method in a class, which itself is not exported either. The only way to
gain access to the objects of a COM DLL/OCX is via the DLL's exported
DllGetClassObject() function, which returns an IClassFactory object.
IClassFactory has a CreateInstance() method for creating instances of the
DLL's COM objects. In the above code, Create() calls CoCreateInstance(),
which handles calling into IClassFactory for you.
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
|
|