|
One solution is containment. Another solution is aggregation, but only allow access to certain interfaces.
Kuphryn
|
|
|
|
|
Kuphryn, thanx for your answer, but could you elaborate your answer? How does containment work? Can you show me an example or article?
|
|
|
|
|
Concept of containment is as C++'s "has a" inheritance relationship. In other words, the outside COM object containers interfaces that will then utilize the inner object. The outsider exposes whatever functions it wants.
Kuphryn
|
|
|
|
|
Your non-creatable object should not have the class-factory. However I don't know how to make it possible in MFC.
With best wishes,
Vita
|
|
|
|
|
I found what I was looking for. I just have to remove the coclasses from the idl file, so the classes are not registered. This way external applications can only access the main (co-)class. Now the 'non-coclasses' cannot be created with CoCreateInstance anymore, instead they have to be created by calling their own static CreateInstance method.
|
|
|
|
|
I want to export data from a MFC program to EXCEL 97.
The function prototypes are in excel8.h
This is all part of excel8.olb. The only documentation I can find is for VB (vbaxl8.hlp on the MS Office distribution CD)
WHERE CAN I FIND THE DOCUMENTATION FOR THE FUNCTIONS OF excel8.h (for C/C++ not VB)
Anybody who knows COM, and OLE Automation should know...
I am just a rookie when it comes to this part of programming
Ethernal gratitude is guaranteed...
Daniela
|
|
|
|
|
I have to reply to my own post...
There is NO documentation for EXCEL Automation for C++.
It is extremely difficult using the VB documentation to get the C++ code right.
For example
range.PasteSpecial(Paste, Operation, SkipBlanks, Transpose)
In VB, all 4 parameters are VARIANTS
in the C prototype file excel8.h, the first two parameters
are of type long.
The "#define" for parameter Paste can nowhere be found
I found a pathetic way to work around my problems.
Just record a bunch of macros in EXCEL and call them from the C program
myapp.Run( COleVariant("MyMacro"),...)
//there are 30!!! optional parameters instead of the periods
Daniela
|
|
|
|
|
I am having the same problem. Augh.
If you find any good documentation please let me know.
Mardigin
|
|
|
|
|
hi there..
i am enabling mfc in an activex control and what happens is that when i debug it ..it throws an access violation in OLE32.lib..
dont know why..ne ideas?
regards
safee
|
|
|
|
|
thanks amigo..
it got resolved..
i logged on today ... sorry for keeping u waiting..
regards
safee
|
|
|
|
|
I [users] get this error when the service has run for a long time...
Any idea about this?
the event log shows..
----------------------------------------------------------------------
The COM+ Services DLL (comsvcs.dll) was unable to load because allocation of thread local storage failed.
Process Name: MyExe.exe
Error Code = 0x80070008 : Not enough storage is available to process this command.
COM+ Services Internals Information:
File: .\comsvcs.cpp, Line: 289
----------------------------------------------------------------------
After seraching in the net, I realized that I am not the only one to get this problem... There are many executables which get this error. Apparently we are all doing the same kind of process.. [like calling CoInit many times (with proper un-inits)..etc]
But, nowhere a solution is discussed... any luck here??
Thanks for your time!
|
|
|
|
|
I have done a GIS implementation in VC++ with Ms-access as back end iwant to convert this into Activex control & place it on the web .Can Anybody helpme out?
A.Satish Kumar
|
|
|
|
|
Hi,
I've created a DCOM Server through the ATL COM Appwizard, I've added a custom (IUnknown) interface and added some methods as below;
[helpstring("method GetComputerName")] HRESULT GetComputerName([out] BSTR *pName);
[helpstring("method GetComputerTime")] HRESULT GetComputerTime([out] long *lTime);
I was able to compile and call these methods thru the client and successfully get the values even from a remote machine.
Now I added a CLIENTINFO Structure in a header file and included the file in the idl using the #import directive,
#import "ClientInfo.h"
I added another method with a pointer to the ClientInfo structure as the parameter as follows
[helpstring("method GetComputerName")] HRESULT GetComputerName([out] LPCLIENTINFO pClInfo);
I was able to compile the code, but when i call this function from the client code, i get an exception and it crashes.
I want to know if we can pass User-Defined Data structures as parameters in a DCOM server? Why is this giving a problem even though i have derived the interface thru IUnknown? Shud we use VARIANTs here, but why shud we since i havent specified an IDispatct \ Automation interface?
The same thing works fine if i create an IN_PROC DLL.
Please tell me how we can achieve this in DCOM, also pls direct me to any examples or tutorials or articles on this.
Thanks,
Anand
|
|
|
|
|
|
Thanks John. Cant this be done if we do custom marshaling. And I have seen an RPC server which takes Struture Pointers as above as parameters in the IDL file.
Thanks
Anand
|
|
|
|
|
Anand Vinod wrote:
Cant this be done if we do custom marshaling.
I believe it can if you do custom marshaling.
John
|
|
|
|
|
Your [out] parameter is incorrect. A pointer-to-a-pointer must be passed in (similar to QueryInterface) :-
HRESULT GetComputerName([out] LPCLIENTINFO *pClInfo);
OR
HRESULT GetComputerName([out] CLIENTINFO **pClInfo);
Implementation :-
HRESULT GetComputerName(CLIENTINFO **pClInfo)
{
*pClInfo = new CLIENTINFO;
(*pClInfo)->m_bstrComputerName = SysAllocString(L"");
return S_OK;
}
The single level pointer that you were passing is only valid within a single process address space.
|
|
|
|
|
Your [out] parameter is incorrect. A pointer-to-a-pointer must be passed in (similar to QueryInterface) :-
HRESULT GetComputerName([out] LPCLIENTINFO *pClInfo);
OR
HRESULT GetComputerName([out] CLIENTINFO **pClInfo);
Implementation :-
HRESULT GetComputerName(CLIENTINFO **pClInfo)
{
*pClInfo = new CLIENTINFO;
(*pClInfo)->m_bstrComputerName = SysAllocString(L"");
return S_OK;
}
The single level pointer that you were passing is only valid within a single process address space.
Jason Lee Duncalf
|
|
|
|
|
Hello,
i am creating an EXE com server through ATLCOMAppWizard. i inserted a NEWAtlObject through insert->newatlobject,i selected simple object then i prefered custom interfaces in attributes and checked the option of support Error information & connection points. i added more interfaces to the object by adding code to .IDL file &compiled it & made necessary changes to cpp file .
finally when build the project i got everything successful & the message of successfully registered component.also seen in the registry about coclass guid present.
i am facing problem to create a client to that EXE-server, i cann't create object via CoCreateInstance though i included MIDL-generated .h &_i.c files in the client code.
please help me in creating client to the above EXE-server.If possible please send a example of EXE-client code.
satish silla
Larsen & Tubro Ltd,
Mumbai.
|
|
|
|
|
Since you are creating a server, you need to create a proxy-stub dll and register it, and specify CLSCTX_SERVER in your CoCreateInstance call
This article shud help you;
http://www.codeproject.com/com/HelloTutorial1.asp
Anand
|
|
|
|
|
Hey guys,
Im trying to write a simple client app
(MFC dialog wizard based app) and I have included the ".tlb" of my component0 to the include folder and added the "#include mycomponent.tlb"
anyidea what this means? how to resolve it.....
thanks
When I tried building at this stage I'm getting the following error message
--------------------Configuration: nativecomclient - Win32 Debug--------------------
Compiling...
StdAfx.cpp
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x2'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x1'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x1'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x3'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x81'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x80'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0xff'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2018: unknown character '0x1'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2146: syntax error : missing ';' before identifier 'A'
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : error C2501: 'MSFT' : missing storage-class or type specifiers
c:\dcom\alangordon\ch5\writers component\server\writerscomponent.tlb(1) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
nativecomclient.exe - 18 error(s), 0 warning(s)
|
|
|
|
|
did you mean to
#import "mycomponent.tlb"
instead of
#include "mycomponent.tlb"
?
|
|
|
|
|
YES !!
I can;t beleive I didnt catch that !!!
I almost gave up on my code !
Thank you so much !
![Roll eyes | :rolleyes:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_rolleyes.gif)
|
|
|
|
|
hello,
i have an local server application exposing some objects with dispinterface events.
and i have a simple .vbs file which creates an object instance, and connects the event interface and releases everything.
Set App = CreateObject( "Server.App" )
WScript.connectObject App, "app_"
WScript.DisconnectObject App
set App = Nothing
wscript.quit
then the wscript crashes with an access violation. if i remove the connectobject line, the wscript terminates without error. seems like the wscript crashes inside the quit method, an messagebox right in front on the quit is displayed correctly.
if i connect the event interface from a c++ client, with atladvise, atlunadvise, everything works, i get no error there.
what could be the problem there? where can i search why the wscript crashes? if have no source for the wscript.
the advise and unadvise marshalls the interface into a stream to make it accessable from any thread.
... error checking
LPSTREAM pStream = 0;
hRes = CreateStreamOnHGlobal( 0, TRUE, &pStream );
if ( SUCCEEDED( hRes ) )
{
hRes = CoMarshalInterface( pStream, iid, p, MSHCTX_LOCAL | MSHCTX_INPROC | MSHCTX_NOSHAREDMEM, 0, MSHLFLAGS_TABLESTRONG );
}
... store stream and return cookie.
maybe there is the problem, i also tried with MSHCTX_INPROC only, but the same error occurred.
thanks in advance
enrico
|
|
|
|
|
Can you check the error within your vbs? I have had to debug vbscript before and what I had to do was add the line "on error resume next" and then in your case add a error check right after the call to connectobject. I typically check if err.number <> 0 then msgbox err.number & " " & err.description. That depends on the security context your script is running under. For debugging, I usually isolate the suspect script into a solitarty script file that I can execute from my desktop, thus inheriting my security rights and msgbox fires with the info I want.
|
|
|
|