|
|
Yes, I'am aware of this function, but is doesn't work in a modal property sheet.
Remon
|
|
|
|
|
Hi!
I am trying to create an out of process server which runs as a remote service. So, I have created the service on machine B.
The client is on machine A, and has been compiled using #include (with the _i.c and .h) files. The service (on machine B) has been initialized as follows:
a. nmake the *ps.mk file
b. regsvr32 the *ps.dll file
c. Run *.exe -service
d. and finally start the service on machine B.
On machine A(client), I do the following:
CoInitialize(NULL);
LPWSTR pwszName="name of machine B;
COSERVERINFO csi={0,pwszName,NULL,0};
MULTI_QI mqi[]={{&IID_ITestInterface,NULL,S_OK}};
try{
HRESULT hr=CoCreateInstanceEx(CLSID_TestInterface,NULL,CLSCTX_SERVER,
&csi,sizeof(mqi)/sizeof(mqi[0]),mqi);
if(FAILED(hr)) _com_issue_error();
//use a smart pointer and do some method invokation..
}
catch(_com_error&error){
// display error
}
when I run this, I get the error that Interface not registered 80040155.
Can someone point out what is going wrong here. My main query is whether this error is generated from the client side (machine A), indicating that the interface should be registered on machine A, or it is generated from the server itself.
Ideas/comments would be greatly appreciated.
thanks in advance
|
|
|
|
|
hello,
i think that the *PS.dll is not registered in the client machine. So copy the ps dll in the client machine and register it and try running it. If error persists please report so that i can think of something else.
Ganesh.M.Ramaswamy
|
|
|
|
|
Hi! Thanks for your message.
I copied the *ps.dll file and registered it using regsvr32.exe. It still does not work, and I get the same error.
Does the *ps.dll file have to be copied into a specific directory e.g winnt\system32?
I have tried doing that though..
|
|
|
|
|
I can programatically create a link to a file... but how do you create a link to a folder?
Thanks,
|
|
|
|
|
I'm curious how people out there implement these 2 aspects of a class when COM pointers are in use. Here's an example class :
CClass
{
public :
CClass();
CClass( CClass& other );
~CClass();
CClass& operator=( CClass& rhs );
private :
_ConnectionPtr m_connection;
};
Given this, what's the best way to copy m_connection in the necessary routines? As so? :
CClass::CClass( CClass& other )
{
other.m_connection->QueryInterface( __uuidof(Connection), (void**)&m_connection );
}
CClass& CClass::operator=( CClass& rhs )
{
if ( this != &rhs )
{
rhs.m_connection->QueryInterface( __uuidof(Connection), (void**)&m_connection );
}
return *this;
}
Or is there a more proper way for copying the pointer from one class to another?
|
|
|
|
|
When you copy an interface pointer, check it for NULL, and if it's not NULL, copy the value then AddRef() it.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
_ConnectionPtr is smart pointer
(_com_ptr_t<_com_IIID<_Connection, __uuidof(Connection)> >).
Just do it
m_connection = rhs.m_connection;
and _com_ptr<>::operator =() calls QueryInterface himself
|
|
|
|
|
I have 2 dll 's which are using the same structure and same interfaces
but i want to write one client.
I included the headers generated by the idl 's in my client i am getting redefination of structures.
Is there any way where I can access both the DLLs using a single client.
The DLLs share the same structures and interfaces
Thanks for any help
parag
|
|
|
|
|
Yes you can . You will have to use namespace under this circumstance
Jafer
|
|
|
|
|
How do you pass a "C" type struct to a visual basic active X dll? I have looked at the tutorials on the site for passing simple system-defined datatypes but get problems with the MIDL compiler if I try to pass a structure. How does one do this? i.e. I create my active x dll and then get the .idl file from the ole viewer and try to run midl to create header file for me but that's where it goes wrong complaining about the type there. Is there an article on this somewhere?
|
|
|
|
|
Hello,
declare the structure in ur MIDL file and then in client side VB code there is something called as *type* data type. this is similar to a structure. declare this in the format as ur structure and create an instance for it and use it. this worked for me in COM dll/VB client and so i think it will work in VB activex client also.
Ganesh.M.Ramaswamy
|
|
|
|
|
Hi,
I might look a bit selfish here, but,
have you tried this ?
www.codeproject.com\atl\udtdemo.asp
Hope this helps
|
|
|
|
|
Suppose a client connected with a remote DCOM component by creating its instance and then calling its methods, can the component know where the client comes from, or what IP the client has? If can, how? And when firewall exists in the client side, how is the situation then?
Thanks a lot!
|
|
|
|
|
hello,
As far as i know the basic design of COM/DCOM is that both client and server should be unaware of the other and as i suppose COM doesnt give any direct interface/method for getting IP address (though it does these things internally). i also think that there wont be any need for a COM component to trace the client.
Ganesh.M.Ramaswamy
|
|
|
|
|
hi
I am a beginner to ATL .I cant call the control's property pages in 'Active control test container' and VC++ ,but can do that in VB.How will i do to perform that?
|
|
|
|
|
hi
I am a beginner to ATL .I made a Active control with ATL.
I can call the control's property pages in 'Active control test container' and VC++ ,but cant do that in VB(the context menu dont contain the 'Property' item).How will i do to perform that?
|
|
|
|
|
I have a COM dll with connction point interfaces. I require to sink the events in the Document class of an MFC SDI appilcation.I change the following in the document
in DeskDoc.h the following changes were made
class CDeskDoc : public COleDocument, public IDispEventImpl<
0,
CDeskDoc,
&DIID__IToolsEvents,
&LIBID_STOOLSLib,
1,
0>
{
public:
CDeskDoc();
HRESULT PassArg(BSTR * pArg);
BEGIN_SINK_MAP(CDeskDoc)
SINK_ENTRY_EX(0, DIID__IToolsEvents, 1, PassArg)
END_SINK_MAP()
}
The DeskDoc.cpp had the following added
HRESULT CDeskDoc::PassArg(BSTR * pArg)
{
BSTR chk;
chk = L"Test";
pArg = &chk;
return S_OK;
}
The following code in the MainFrame invokes the event
void CMainFrame::OnEventTest()
{
CoInitialize(NULL);
//ISDConnectionPoint *pSDConnectionPoint = NULL;
IUnknown *pSDConnectionPoint = NULL;
ITool *pTool = NULL;
HRESULT hr = CoCreateInstance(CLSID_Tool,NULL,CLSCTX_ALL,IID_IUnknown,(void**)&pSDConnectionPoint);
IConnectionPointContainer* pConnectionPointContainer;
hr = pSDConnectionPoint->QueryInterface(IID_IConnectionPointContainer, (void**)&pConnectionPointContainer);
if(SUCCEEDED(hr))
{
IConnectionPoint* pConnectionPoint;
hr = pConnectionPointContainer->FindConnectionPoint(DIID__IToolsEvents, &pConnectionPoint);
// CEventHandler* pSinkEvents = new CEventHandler();
//Get the document pointer
CDeskDoc *pDoc = (CDeskDoc*)GetActiveDocument();
GUID iid ;
BOOL bRet = pDoc->GetDispatchIID(&iid);
LPUNKNOWN lpUnknown = (LPUNKNOWN)pDoc->GetInterface(&IID_IUnknown);
DWORD dwCookie;
pConnectionPoint->Advise( lpUnknown, &dwCookie);
hr = pSDConnectionPoint->QueryInterface(IID_ISharpTool, (void**)&pTool);
pTool->Check(); //This invokes the event PassArg()
pConnectionPoint->Unadvise(dwCookie);
pConnectionPoint->Release();
pConnectionPointContainer->Release();
}
CoUninitialize();
}
This piece of code does not work.
However if i create a separate class derived from IDispEventImpl then there is no problem with the code.However i would like to sink the events in the MFC Document class it self.
Your early reply will be appreciated.
Thanks in advance.
Jafer
Jafer
|
|
|
|
|
Hello -
We have a C/C++ app witten with plain win APIs (no MFC). A nice enhancement to the project would involve the use of an ActiveX control by Infragistics. Question: Can an ActiveX control be used and accessed from plain C/C++ in an existing program that doesn't use MFC? If so, where could we find some "how to" information and possibly sample code?
Thanks,
Mike
|
|
|
|
|
where could we find some "how to" information and possibly sample code?
Everywhere, there are samples all over this site, and others, that use COM without MFC. ActiveX, or COM, is not dependent on MFC. Here is a hint, Coinitialize()
|
|
|
|
|
Mark,
Thank you for your reply. I spent some time on this great site but have to admit that I unfortunately didn't encounter the many samples you mention. Please help me in my obviously blind and confused search .
I understand the usage of CoCreateInstance() and CoInitialize(). I am puzzled however for example by how events are passed from the ActiveX control back to the C code.
Thanks in advance for the hand holding.
Mike
|
|
|
|
|
The book ATL internals had some actual samples of using something along this line using ATL. I know ATL is still a library but it is independant of MFC and is much smaller.
Sam C
----
Systems Manager
Hospitality Marketing Associates
|
|
|
|
|
|
I totally agree, I have that book as well Those are the only two books I use as an ATL reference suite.
Sam C
----
Systems Manager
Hospitality Marketing Associates
|
|
|
|