|
Dear All,
I have a com with source code compiled as dll now is there any way that i can use the class in dll without registering the com. I am new to com so dont have any idea about it
i read some where that with loadlibray we can use dll as late binding and get procaddres to access class or methods in .def file but is it possible to use class not in .def file
|
|
|
|
|
justintimberlake wrote: I have a com with source code compiled as dll now is there any way that i can use the class in dll without registering the com. I am new to com so dont have any idea about it
Check these two URLs. Let me know if this is what you are looking for.
Registration-Free Activation of .NET-Based Components: A Walkthrough[^]
Registration-Free Activation of COM Components: A Walkthrough[^]
Registering COM Applications[^] will help you understand COM application registration basics.
justintimberlake wrote: i read some where that with loadlibray we can use dll as late binding and get procaddres to access class or methods in .def file but is it possible to use class not in .def file
Yes, with LoadLibrary and GetProcAddress you can access functions in DLLs. But a COM Inprocess server is a special kind of DLL (that is designed with COM specification rules and with intention of it being used by COM aware clients). In general, as far as I know, to use a function using LoadLibrary and GetProcAddress, a function should be exported by that DLL. There are various ways to export a function, one of which is .DEF file you mentioned (see Exporting from a DLL [^] )
Let me know if this helps.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
Thanx Sohail for your i really appricite that. Can i ask you few question if i have any problem in near future because i was given only one day for the project and i couldn't do it so will have to see some other day only for my satisfaction. Once again thanx a lot
|
|
|
|
|
Sure. No problem.
Cheers,
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
I am reading a book and it says the following:
"AddRef() and Release() calls by the client do not result in an ORPC call until the final release has been detected"
I can understand the benefit (of not having a round trip from client to remote server) but can anyone please enlighten me step by step me on this one? The illustration is a big box for the Client's Process Space which has 3 main entities inside: the Client, Proxy Manager, and the Channel Objects. The Proxy Manager aggregates all the Proxy Objects that make use of IRPCProxyBuffer (1 for each Proxy Object). The diagram also implies 1 Channel Object for each remote interface.
TIA.
I am a SysAdmin, I battle my own daemons.
|
|
|
|
|
Hi All,
I have an ActiveX control. And the event map is defined in the control's implementation (.CPP) file.
Say the event map has a function
EVENT_CUSTOM("SomeEvent", FireSomeEvent, VTS_BOOL)
defined in it...
Now I can very easily call the function 'FireSomeEvent' from the control's implementation cpp file.
Can I call 'FireSomeEvent' from some other cpp file....means some other's class's code ??
If yes then how??
Urgent help needed...
Thanks and Regards,
AbbyIndian
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|
|
Hi,
I tried the (provided) code as part of an AddIn for Excel. I am able to call the function and also pass data to it. However, midway through the processing Excel crashes. I use the default way to debug the application i.e. when it crashes I click on Debug and use the Visual Studio IDE to debug the application.
NOTE: Please bear in mind that I have almost no experience with Visual C++ and very little experience with C++. I have tried to build upon some code that was handed over to me and have succeeded in passing non-array variables from Excel to COM and performing operations and successfully returning values. I have started facing problems while passing and returning arrays.
I get the error: Unhandled exception at 0x77c47fd4 in EXCEL.EXE: 0xC00000005: Access violation reading location 0x00000008.
CODE:
<br />
STDMETHODIMP CAddin::TEST(VARIANT input, VARIANT* output)<br />
{<br />
LONG lstart, lend;<br />
LONG idx = -1;<br />
LONG nPOS;<br />
HRESULT hr;<br />
BSTR HUGEP* pbstr;<br />
pbstr[input.parray->rgsabound->cElements];<br />
std::list holder;<br />
SAFEARRAY *sa = V_ARRAY(&input);<br />
hr=SafeArrayGetLBound(sa,1,&lstart);<br />
if (FAILED(hr)) return hr;<br />
hr=SafeArrayGetUBound(sa,1,&lend);<br />
if (FAILED(hr)) return hr;<br />
LOG_DEBUG(lstart<<" "<<lend<<std::endl);<br />
USES_CONVERSION;<br />
hr=SafeArrayAccessData(sa,(void HUGEP* FAR*)&pbstr);<br />
LOG_DEBUG("PBSTR "<<pbstr<<" "<<*pbstr<<std::endl);<br />
if (SUCCEEDED(hr)){<br />
for (idx=lstart;idx<=lend;idx++){<br />
CComBSTR s;<br />
LOG_DEBUG(idx<<" "<<pbstr[idx]<<std::endl);<br />
holder.push_back(W2A(s.m_str));<br />
}<br />
hr=SafeArrayUnaccessData(sa);<br />
if (FAILED(hr)) return hr;<br />
for (int i=0;i<holder.size();i++){><br />
LOG_DEBUG("Vals "<<holder.front()<<std::endl);<br />
holder.pop_front();<br />
}<br />
}<br />
else<br />
return hr;<br />
}<br />
</holder.size();i++){>
The LOG_DEBUG (...) function simply prints stuff into a log file.
From the debug session, it looks like the value for pbstr is ok, it is 06BAE7E8 but the value stored at that location is not good, it is 0x00000008 which is an inaccessible location address. Does this mean that the SafeArrayAccessData is not providing me with the correct memory addresses? BTW, the bounds of the passed array are good and so is the data in the safearray as I have found out from the debug session.
When I debug the crash, I get to see the following code:
<br />
CComBSTR& operator=(__in_opt LPOLESTR pSrc)<br />
{<br />
if (pSrc != m_str){<br />
::SysFreeString(m_str);<br />
if (pSrc != NULL){<br />
m_str = ::SysAllocString(pSrc);<br />
if (!*this)<br />
{<br />
AtlThrow(E_OUTOFMEMORY);<br />
}<br />
}else{<br />
m_str = NULL;<br />
}<br />
return *this;<br />
}<br />
The value for pSrc us 0x00000008<bad_ptr> and the value for m_str is 0x00000000<bad_ptr>.
Some questions:
1. Why am I getting an inaccessible location address?
2. Why do we use HUGEP* and FAR* instead of a simple **? I was using ** earlier but in my efforts to make this work, picked these up from some googled doc/articles online.
3. HOW can I paste stuff into this textbox? I had to rewrite all the code and it has also lost its indentation?
Thanks for any help in this matter. I assure you all, that once I get this working I'd get over this mental block about Visual C++. I want to know what is it that I am doing wrong here...
Cheers
Sukant
P.S. Again, please note that I have just begun my journey of COM/VisualC++/C++, so I would really appreciate any pointers (or FAR* for that matter) on this issue. Any criticism and feedback is more than welcome.
|
|
|
|
|
ssaddi wrote: 1. Why am I getting an inaccessible location address?
My guess is that input does not contain an array of BSTR. I'd suggest adding a check that input.vt is the correct value, which would be something like (VT_ARRAY | VT_BSTR) .
ssaddi wrote: 2. Why do we use HUGEP* and FAR* instead of a simple **? I was using ** earlier but in my efforts to make this work, picked these up from some googled doc/articles online.
You can probably leave out the HUGEP and FAR. They come from the Windows 3.1 days or earlier.
ssaddi wrote: 3. HOW can I paste stuff into this textbox? I had to rewrite all the code and it has also lost its indentation?
You can paste into almost any text box using Ctrl-v. To keep the indentation, you need to put your sections into a <pre></pre> block.
Nathan
|
|
|
|
|
Thanks for your response Nathan.
From the debug session, input looks like this
<br />
input | safearray of VARIANT=[84](BSTR=0x001a5a74"129521",BSTR=0x001a5b54"142732".....)<br />
input | vt = 8204<br />
| safearray | <br />
| [0] | BSTR=0x001a5a74"129521" | vt = 8<br />
I have tried to put in textual representation of the tree kind of view of the variable I get to see while debugging. It looks like it is an array of BSTRs. Does this provide any insight on what I am doing wrong here?
Thanks for the point about HUGEP* and FAR*, hated those in my code anyway...so from now onward won't be using them at all.
BTW, I tried CTRL-V last time and this time as well. All I get when I try to paste something is . Is anyone else getting annoyed because of this?
Again, any help will be appreciated people. Looking forward to some replies.
Cheers
Sukant
|
|
|
|
|
ssaddi wrote: I have tried to put in textual representation of the tree kind of view of the variable I get to see while debugging. It looks like it is an array of BSTRs. Does this provide any insight on what I am doing wrong here?
To me, it looks like an array of variants, each of which contains a BSTR.
ssaddi wrote: BTW, I tried CTRL-V last time and this time as well. All I get when I try to paste something is . Is anyone else getting annoyed because of this?
It sounds like something is very wrong on your computer. It may be your web browser. I suppose that it could ba a bug in Code Project, but if it is, it's one that doesn't affect most people.
Nathan
|
|
|
|
|
I didn't receive a response to my last post. Was it useful?
Nathan
|
|
|
|
|
Hi Nathan,
Sorry I was a little busy with implementing stuff because of that response. It was very useful. Turns out that it was a variant of variants with each containing a BSTR within it.
Actually, that variant of variants is also returned by another call to one of the other functions in my dll which uses one of the produc's available functions. Their function converts std::list<std::string> to Variant[Variant[BSTR]]. It's all good as long as I know what is coming out as resultant from the product's library functions. I think I'll try and make my own function to create variant of BSTRs instead of Variant of Variants.
Anyway, Thanks for all your help. You have been very helpful.
Cheers
Sukant
|
|
|
|
|
ssaddi wrote: Sorry I was a little busy with implementing stuff because of that response. It was very useful. Turns out that it was a variant of variants with each containing a BSTR within it.
Thanks! I'm glad I helped.
I'm not sure what you mean by what is wrong with the code. It looks like the createStringArray function is intended to create a variant array of variants, each of which is a BSTR. What is the problem you want to fix?
Nathan
|
|
|
|
|
BTW, looks like the Ctrl-V/Paste problem comes up only in IE7.0. I used firefox and it works fine. Weird huh?
|
|
|
|
|
ssaddi wrote: BTW, looks like the Ctrl-V/Paste problem comes up only in IE7.0. I used firefox and it works fine. Weird huh?
I'm glad you found a fix. I'm using IE7 on my computer, but it pastes just fine. We may never know what went wrong on your end.
Nathan
|
|
|
|
|
hi
this is suresh...........
i have written a comdll using Win32 dynamic link library.so the dll has run without Bugs,
next my client in console.......
#include
#include
#include "iids.h"
#include "interface.h"
void main()
{
CoInitialize(NULL);
I1* p1=NULL;
HRESULT hr=CoCreateInstance(CLSID_D,NULL,CLSCTX_ALL,IID_I1,(void**)&p1);
if(FAILED(hr))
{
cout<<"sorry component cannot be created "<<endl;
}
p1->f1();
I2 *p2;
p1->QueryInterface(IID_I2,(void**)&p2);
p2->f2();
p1->Release();
p2->Release();
CoUninitialize();
}
so finally i cannot co-create the component
|
|
|
|
|
hi
this is suresh...........
i have written a comdll using Win32 dynamic link library.so the dll has run without Bugs,
next my client in console.......
#include<objbase.h>
#include<iostream.h>
#include "iids.h"
#include "interface.h"
void main()
{
CoInitialize(NULL);
I1* p1=NULL;
HRESULT hr=CoCreateInstance(CLSID_D,NULL,CLSCTX_ALL,IID_I1,(void**)&p1);
if(FAILED(hr))
{
cout<<"sorry component cannot be created "<<endl;
}
p1->f1();
I2 *p2;
p1->QueryInterface(IID_I2,(void**)&p2);
p2->f2();
p1->Release();
p2->Release();
CoUninitialize();
}
so finally i cannot co-create the component
|
|
|
|
|
And what was the error?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi friend,
it's urgent
I am using some DLL file (LpiCom_6_0.LPOrderPart.dll) in asp file for bulk payment charging (its support by LinkPoint). Its work fine but after some days its not work means registration failed. Again when we registered.it's work fine. What can be problem. If you have any idea then please help me i am facing from six month.
Thanks
Sujit
|
|
|
|
|
Sujit Gupta wrote: it's urgent
Just because you say "It's urgnet", no one will leave their own work and find solution for you
Sujit Gupta wrote: I am using some DLL file (LpiCom_6_0.LPOrderPart.dll) in asp file for bulk payment charging (its support by LinkPoint). Its work fine but after some days its not work means registration failed. Again when we registered.it's work fine. What can be problem. If you have any idea then please help me i am facing from six month.
There could be many reasons why it's not working. But from the details you have mentioned, it seems the problem is due to your DLL getting unregistered somehow.
I believe your DLL resides on one of your servers, I would check if there any script or activity happening on your server that is unregistering it periodically and doesn't register it again. I could be wrong here, but do check.
Sujit Gupta wrote: What can be problem. If you have any idea then please help me i am facing from six month.
Did you check with LinkPoint support?
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
hi,
i'm trying to get the source html code from web page.
IOleCommandTarget *iole;
IWebBrowser2 *iex;
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER, IID_IWebBrowser2, (LPVOID*)&iex);
hr = iex ->QueryInterface(IID_IOleCommandTarget, (void**)&iole);
if(SUCCEEDED(hr))
hr = iole ->Exec(&CGID_MSHTML, IDM_VIEWSOURCE, 0, 0, 0);
that doesn't works.
could you tell me what's wrong here?
are there other ways to get html source code without using MFC?
thanks for help.
|
|
|
|
|
sashka wrote: IOleCommandTarget *iole;
IWebBrowser2 *iex;
CoCreateInstance(CLSID_InternetExplorer, NULL, CLSCTX_SERVER, IID_IWebBrowser2, (LPVOID*)&iex);
hr = iex ->QueryInterface(IID_IOleCommandTarget, (void**)&iole);
if(SUCCEEDED(hr))
hr = iole ->Exec(&CGID_MSHTML, IDM_VIEWSOURCE, 0, 0, 0);
What doesn't work here
. Query interface or
. hr = iole ->Exec(&CGID_MSHTML, IDM_VIEWSOURCE, 0, 0, 0);
what is the value of HRESULT after calling
hr = iole ->Exec(&CGID_MSHTML, IDM_VIEWSOURCE, 0, 0, 0);
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
method Exec() doesn't works.
it returns E_UNKNOWNGROUP.
i included mshtmhst.h, mshtmcid.h, mshtml.h.
in mshtmhst.h CGID_MSHTML defined in this way:
EXTERN_C const GUID CGID_MSHTML;
#define CMDSETID_Forms3 CGID_MSHTML
CMDSETID_Forms3 defined in mshtml.h:
EXTERN_C const GUID CMDSETID_Forms3
i am not very familiar with COM, but i have read that
every COM object must be registered in system through
it's unique GUID. so i tried to use macro
DEFINE_GUID(CGID_MSHTML, XXX),
XXX - GUID for CGID_MSHTML command group (found with google).
that doesn't worked.
|
|
|
|
|
Sorry for replying late. Is your problem resolved?
Can you point me to header/idl where E_UNKNOWNGROUP is defined?
sashka wrote: i am not very familiar with COM, but i have read that
every COM object must be registered in system through
it's unique GUID. so i tried to use macro
DEFINE_GUID(CGID_MSHTML, XXX),
XXX - GUID for CGID_MSHTML command group (found with google).
that doesn't worked.
You are suppose to register COM servers and coclass only for the components you develop. All other COM servers, be it Out of process server(EXE) or Inprocess servers(DLLs), are suppose to be registered in a predefined way. For Inproc servers, we usually use Regsvr32.exe to register the DLL (See DllRegisterServer function that is exported by any COM inproc server. This function is called.)
I believe reading some basics about COM before going ahead, will help design your component/application in a better way.
Sohail
modified 21-Apr-21 21:01pm.
|
|
|
|
|
sorry for replying late.
last time i gave you an incorrect description of my error, sorry for that too.
when the Exec() method fails it returns not E_UNKNOWNGROUP, but OLECMDERR_E_UNKNOWNGROUP,
it defined in docobj.h.
my goal was to retrieve a source html code from browser.
i have found another way to do it:
...
HRESULT hr;
IWebBrowser2 *iex;
OLECHAR *path = L"h://1.html";
IDispatch *iDisp;
IPersistFile *persistFile;
...
hr = iex ->get_Document(&iDisp);
if(SUCCEEDED(hr)){
hr = iDisp->QueryInterface( IID_IPersistFile, (void**)&persistFile);
if(SUCCEEDED(hr))
hr = persistFile ->Save(path, 1);
}
it works.
but i got a new problem - can't change the page, using Navigate() method:
...
hr = iex ->Navigate( L"http:\\www.bash.org", 0, 0, 0, 0);
the value of hr is -2147023116;
if you have some free time, please look whats wrong wiht that.
great thanks for help.
|
|
|
|
|