|
I understand the difference between the types of interfaces, but what puzzles me is why it would work in an exe and not in a dll.
|
|
|
|
|
Different connection point container implementations? Only thing I can think of off the top of my head.
Another thing you could try (if you haven't already) is ATL's QI debugging (using _ATL_DEBUG_QI) - you can see what interfaces are being used. You can use DbgView[^] to trace the QI's when running outside Visual Studio.
|
|
|
|
|
Really appreciate you taking the time to help with this. Apologies for being a bit dense, but I want to make sure I understand...
I'm using the same code (it's a C++ class) and compiling that code in two different scenarios. In the test app exe, Invoke is called. In the toobar dll, it's not. Since it's the same code in both cases, does "different connection point implementations" refer to the connection point implementation of the control host?
That would seem a sensible neighborhood for the culprit since the control code is the same in both scenarios. So, if this is what you mean, would you have any suggestions on how I could debug the connection point implementations in these two scenarios?
Thanks again, man.
|
|
|
|
|
Christopher Duncan wrote: does "different connection point implementations" refer to the connection point implementation of the control host?
Yep
Christopher Duncan wrote: So, if this is what you mean, would you have any suggestions on how I could debug the connection point implementations in these two scenarios?
I guess the QueryInterface debugging would be a reasonable start. Also, if your interface is dual , make it a dispinterface - that should (he said!!) fix the problem.
|
|
|
|
|
Okay! First, I'll make it dispinterface, and if that doesn't do it I'll find some chickens to sacrifice.
Thanks!
|
|
|
|
|
Hi
I have created an ATL application exe type (jjjj) where I am using to create ATL component
it gives following error
QLView.obj : error LNK2005: _CLSID_MyAWrapper already defined in jjjj.obj
SQLView.obj : error LNK2005: _LIBID_Project1Lib already defined in jjjj.obj
SQLView.obj : error LNK2005: _IID_IMyAWrapper already defined in jjjj.obj
Debug/jjjj.exe : fatal error LNK1169: one or more multiply defined symbols found
what to do here.. please suggest ..
thanks
Lee
Leya
|
|
|
|
|
I think you'll find this is caused because you're #including initguid.h in more than one .cpp file.
Make sure that it's only included in *one* cpp file explicitly. If it's in stdafx.h, take it out of there and put it in a .cpp file instead.
|
|
|
|
|
Hi,
I want to build a ATL wrapper on c++ class and would like to use that component in VB.
I insert an ATL class MyAWrapper
I add one property HRESULT String([out, retval] BSTR *pVal)
one method HRESULT ClearString() to IMyAWrapper.
IDL file shows it then in MyAWrapper.h
i put following c++ code
class foo
{
std::string m_str;
public:
foo(std::string bar, bool baz) : m_str(bar)
{
if (baz) throw std::exception();
}
std::string get_string(void) { return m_str; }
void clear_string(void) { m_str = ""; }
};
in ATL class.. class MyAWrapper I addfollowing code.
STDMETHOD(FinalConstruct)(void)
{
try {
m_pfoo = new foo("test", false);
}
catch (...) {
return E_FAIL;
}
return S_OK;
}
in MyAWrapper.cpp, I put
STDMETHODIMP MyAWrapper::get_String(BSTR *pVal)
{
// TODO: Add your implementation code here
if (pVal == NULL)
return E_POINTER;
std::string sTemp = m_pfoo->get_string();
*pVal = ::SysAllocStringLen(sTemp.c_str(), sTemp.length());
return *pVal ? S_OK : E_OUTOFMEMORY;
}
STDMETHODIMP MyAWrapper::ClearString()
{
// TODO: Add your implementation code here
m_pfoo->clear_string();
}
Please tell me Are these stpes OK??
or
where to put c++ code?
I can not compile the project.. I get around 34 errors one of which is
'std' : is not a class or namespace name
Pleasew tell me how to have this perfectly function.
Thanks
Lee
Leya
|
|
|
|
|
yang__lee wrote: std' : is not a class or namespace name
Probably, you forgot to include header, string in this case.
Prasad
MS MVP - VC++
|
|
|
|
|
Hi,
I am using CListBox on the Dialog using WTL, but i am unable to remove its flickering, when it get resized with Dialog. I am using CDialogResize for resizable layout for this app.
I have tried using WM_ERASEBACKGRND too but it wont help.
How is this flicker removed.
Regards,
R.T.
It is necessary once in one's life to put every thing in doubt, so far as possible, in order to reach the truth. DesCartes
|
|
|
|
|
Try using WS_CLIPCHILDREN with your dialog?
|
|
|
|
|
Already tried that :S. but of no use. Also i have already tried Other common methods concerning with windows properties. But i seriously think i have to override WM_PAINT, WM_DRAWITEM etc, but how is the main question.
Regards,
R.T.
It is necessary once in one's life to put every thing in doubt, so far as possible, in order to reach the truth. DesCartes
|
|
|
|
|
Respected, all i am trying a web page which needs to display clients computer name and local time in clients computer....when viewing a page stored in another server computer........plz help me
pokhrel rohit
|
|
|
|
|
Hi,
I have created a COM exe server using ATL8.0, where I have a connection point container interface that fires events for its clients (implementing sink). I am able to receive events at client side, but if I try passing an interface pointer(other than IUnknown) as an [in] parameter it becomes invalid at client side, that is, any method call on this pointer generates exception.
The same peice of code works perfectly fine with DLL server.
Can any one tell me the reason for this behaviour?
Is this problem due to different Address Space?
what is the solution to this problem?
Please Help.
Thanks in Advance.
Kavita seth
|
|
|
|
|
Hi, Kavita.
If your exe is operating as an out of proc server (i.e., your client code is not in the exe), then that would probably explain the different results. In a DLL / in proc scenario your client and server are operating within the same address space, and of course with an out of proc exe they're not. When you pass in a normal pointer (of any kind) from one program to another, it's going to be in foreign address space.
In general, I don't think that's your best way to go. Instead, consider doing a slight tweak to your code so that instead of passing back an interface pointer to the client, you instead just pass a param value back that tells the client, "now query for this interface on me and call it." Either way, the client calls the appropriate function, but this approach is more in keeping with the COM / QueryInterface way of doing things.
Hope this helps,
Chris
|
|
|
|
|
Hi Chris,
Sorry for such a late reply.
Thanks for your suggestion.
But I can not modify the IDL file as it is following some standards, hence my event has to pass the interface pointer.
One more update is there.
My client if written in VB6.0, is able to use that pointer.
But not my VC++ client.
So this appears not to be the problem of address space as VB client is able to call any of the methods of Server with the same interface pointer received along with the event.
Can you suggest any thing
Kavita seth
|
|
|
|
|
Hello Kavita,
Is the interface (passed in via the [in] parameter of the event method) a custom interface ? i.e. is it derived directly from IUnknown as opposed to being derived from IDispatch.
If so, one possible reason is that the Proxy/Stub DLL for the custom interface is not available. You need to build and register such a Proxy/Stub DLL.
For instruction on building and registering Proxy/Stub DLLs, please refer to my blog entry :
http://www.codeproject.com/script/profile/whos_who.asp?msg=1413206&id=24366#xx1413206xx[^]
Best Regards,
Bio.
|
|
|
|
|
Hello Kavita,
If you would like some sample codes demonstrating the Proxy/Stub concepts I mentioned in my earlier reply, please email me :
bio_lim_2004@yahoo.com
Best Regards,
Bio.
|
|
|
|
|
I using FindFirstFile in a while loop like:
while (hfind = FindFirstFile(TEMP,&FindFileData))
{
if (hfind == INVALID_HANDLE_VALUE)
break;
//Do some stuff with the file
}
This will work if i delete or move each file after finding or else it will contiuosly loop. Is there a method that would simply step through each file read and go onto the next so that i do not have to delete the original and when it reaches the last file in the directory then it will return?
Or is there a better way? BTW, these files are XML files.
Thanks,
|
|
|
|
|
You only need to call FindFirstFile() once, after that, call FindNextFile()
|
|
|
|
|
LCI wrote: while (hfind = FindFirstFile(TEMP,&FindFileData))
{
if (hfind == INVALID_HANDLE_VALUE)
break;
//Do some stuff with the file
}
Instead try the following
hfind = FindFirstFile(TEMP, &FindFileData);
if(hfind != INVALID_HANDLE_VALUE)
{
do
{
// Do some stuff..
hfind = FindNextFile(hfind, &FindFileData);
}while(hfind != INVALID_HANDLE_VALUE);
}
Cheers,
Suresh
|
|
|
|
|
Can anyone please help me or give me some sample code? I need to create an ATL COM service which has a dummy interface.. say. add 2 numbers.. After creating the service, i want to register it as a windows service. Then i want to create a client which connects to this service and uses the interface.. (adds 2 numbers)
I have searched online and there is not a decent article which explains the process step by step... Any help in this regard will be very useful.
Thanks in advance!!!!
|
|
|
|
|
Hi,
Create a ATL Project and choose service(EXE) type. The Wizard will generate code for you.
Add an ATL Simple object Like as you add ATL Simple Object to any ATL Project.
Implement your dummy methods or what ever you want.#
Build the project, Go to command prompt and type <exe name> -i to Install it as a Windows service.
In Client you can do a #import on this executable and you can use your dummay interface and methods.
Cheers,
Suresh
|
|
|
|
|
I have succeded in creating a service with a dummy interface.... Then in the client I have imported the header file of the service and defined the GUID's. Suppose i have an interface IFirst_ATL and it has a method addnumbers(), then how can i access that method. I am trying to create an instance of the service by
hr = CoCreateInstance( CLSID_First_ATL, NULL, CLSCTX_INPROC_SERVER,
IID_IFirst_ATL, (void**) &IFirst_ATL);
IFirstATL->AddNumbers(5, 7, &ReturnValue);
but this is not giving me the desired results. Can you please provide me a sample and successfully running code for accessing the methods of the service?
Thanks in Advance!
|
|
|
|
|
Seems that i have found out the problem.. I replaced CLSCTX_INPROC_SERVER with CLSCTX_LOCAL_SERVER in CoCreateInstance(). But now i am facing a different problem.
I have defined a method in my interface as.
STDMETHODIMP CFirst_ATL::AddNumbers(LONG x, LONG y, LONG* z)
{
*z = x + y;
return S_OK;
}
when i try calling this method from client as
hr = IFirst_ATL->AddNumbers(5, 7, &ReturnValue);
the method returns S_OK, but the value in ReturnValue is some garbage value. Can anyone please advice where have i went wrong?
Thanks!
|
|
|
|