|
ok, I understood, you hit the correct point.
I'm using dual interfaces (I noticed that using or not the oleautomation keyword does not affect things) and I'm using universal marshaling.
One last thing: WHY does it work with CreateInstance? Just because CreateInstance uses the registery-based technique? How can it manage better these UDTs?
Thanks again for your (your and Mil10's) precious help, that was not the first COM I created, but I was never gone so deep in COM architecture...
Best regards,
Morenz
|
|
|
|
|
morenz wrote: I noticed that using or not the oleautomation keyword does not affect things
That's because since it's a dual interface it's implicitly an automation interface.
morenz wrote: WHY does it work with CreateInstance?... How can it manage better these UDTs?
To put it simple: it cannot. Since it's the same interface and the same marshaller this won't change. I suspect that when you used CreateInstance() you had a server registered on the same machine as the client and it was invoked as an in-process server so there was no need for marshalling, hence it would seem to handle the UDTs better but in fact they were never "handled" at all.
But I'm only guessing here.
--
Roger
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
No, I verified several times... The server is registered also in client machine (with /RegServer switch), but it's configured (via DCOMCNFG) to go ONLY remote. To be sure, I referred for my test to some image files there were present only on server machine, and I referred them putting down the entire path when calling server methods. If it was like that you are saying, I should get a "file not found" error, instead it did all that it had to do with no problems at all. Also, if I unplug network cable, I get a "RPC Server Unavailable" error.
Last question: if I decide not to use dual interfaces (therefore using IUnknown instead of IDispatch), can I get rid of this problem? If I decide doing custom marshaling where can I get an example of this technique (that I've never seen before?)
Thanx again....
Morenz
|
|
|
|
|
Sorry Morenz, I haven't done custom marshalling so I cannot guide you in the howto process of custom marshalling.
However, I do know that with custom marshalling you can marshal any UDT you like since you have control of how it's done and transferred through the RPC channel.
I suspect that the howto-part is non-trivial and perhaps that might make you consider still using universal marshalling and automation interfaces.
If you're going for custom marshalling I guess you have to buy a good book about the subject...
--
Roger
It's suppose to be hard, otherwise anybody could do it!
|
|
|
|
|
ok, no matter.
The final decision will be taken by the customer, and it will be based on how SOON they want the project
In the worst case (custom marshaling) I think I will buy a book and, why not, consider to give a shot in some serious forum, like this...
Thanks for all.
Enjoy
Morenz
P.S. Pardon me, but in your footnote (or signature) you have a typo: you should have "It's supposed to be hard" instead of "It's suppose to be hard"
|
|
|
|
|
Hey!
I was wondering if anyone knows of a way to lookup which com components are installed in Windows XP. I know I can look it up through Visual Studio but I don't want to install that on every system every time I want to check the installed com components.
|
|
|
|
|
Look at the subkeys of "HKEY_CLASSES_ROOT/CLSID" in the registry.
Steve
|
|
|
|
|
Hey good luck,
i have created the sample application for same
see the following code
CoInitialize (NULL);
ICatInformation *pCatInfo=NULL;
HRESULT hr=CoCreateInstance (CLSID_StdComponentCategoriesMgr ,NULL,CLSCTX_INPROC_SERVER,IID_ICatInformation ,(void **)&pCatInfo);
pCatInfo->AddRef ();
IEnumGUID *pEnumGUID=NULL;
CATID pcatidImpl[1];
CATID pcatidReqd[1];
pcatidImpl[0]=CATID_Control;
pCatInfo->EnumClassesOfCategories (1,pcatidImpl,0,pcatidReqd ,&pEnumGUID);
CLSID clsid;
while( (hr= pEnumGUID->Next( 1, &clsid, NULL ))==S_OK )
{
BSTR bstrClassName;
OleRegGetUserType (clsid,USERCLASSTYPE_FULL,&bstrClassName);
CString strControlName(bstrClassName);
m_list1.AddString (strControlName);
}
pCatInfo->Release ();
CoUninitialize ();
Knock out 'T' from CAN'T
You 'CAN' if you think you 'CAN'
|
|
|
|
|
Can someone explain me the major differences between an ActiveX control
and a COM dll in the context of accessing it from a web page using some
script.
For example, I need to get the MAC ID of the machine from within a web
page. So I thought of developing a COM dll, pack it in a cab using
cabarc, and call the method from within a script in the OnLoad of the
page. Do I need to actually go for creating an ActiveX control instead
of developing the COM dll? Is there any problem with using a COM dll?
Is there any additional advantage in going for ActiveX instead of COM
dll? Infact both the approaches worked fine on my development machine
!!
Thanks in advance.
|
|
|
|
|
If you dont need any UI features, then ofcourse you can go for a simple com component. Activex is for putting UI stuff.
rgds..mil10
|
|
|
|
|
How many kinds of DLLs are there? one that we are able to use with VB, ASP ect. The one which we are able to use with C++ but not VB, Can we create a DLL that is not COM based, and use it in VB? And what kind of Dlls we find in the windows system directories? Can any one brief on it?
NULL
|
|
|
|
|
For more information on dll's you can refer the bottom link
http://www.thevbzone.com/l_dll.htm#DLL%20TYPES
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
Hi,
In one of the code snippets i have seen this.
It looks something like this.
interface IA;
interface IB;
class CCOMTest : public IA,public IB
{//Some code here
}
Inorder to get the pointer to IA,
the code looks something like this
static_cast<IA*>this;
why static_cast ??
what happens if i do (IA*)this ???
can anybody clarify my doubt??
I am a beginner to COM.
Thanks in Advance.
Appu
|
|
|
|
|
this is available in this codeproject site itself.
visit : http://www.codeproject.com/cpp/static_cast.asp
^-^
@|@
- redCat
|
|
|
|
|
"Normal casting" (a.k.a "C-style" casts) should be avoided. If you need to cast always use static_cast , const_cast , reinterpret_cast or dynamic_cast . There are many reasons, some of which are that with these "function-style" casts your cast is:
1. Explicit (in intent).
2. Visible.
3. Checked for safety by the compiler.
There are still many people who use C++ but, for one reason or another, use "C-style" casts: These people are making a mistake. If you've been a maintenance programmer for a few years and seen the havoc caused by vague (in intent) and hard to spot or grep for casts you will probably agree. Some people argue that the new casts are ugly. That is intentional: casting, in general, is an ugly and dangerous practice and more often then not indicates a design flaw in your code. Casts should be ugly.
Steve
|
|
|
|
|
Hi All,
Can anybody explain the need of default interface in COM?
I am beginner to COM.
Thanks in Advance.
Appu
|
|
|
|
|
hi ,
i guess you are asking about IUnknown.
if so, this interface contains the 3 basic methods that are pillars of COM technology to work.
Interface is nothing but the abstract base class in c++.
it means that ultimately all components are required to implement these three methods and simply it is generalized in this IUnknown interface.. that's it
- cheers
redCat
^-^
@|@
|
|
|
|
|
Thanks for the immediate response.
But my doubt is different.
if we look at the idl file that is generated in a COM application we could find something like this.
[default] interface ICOMSample;
Will this [default] be associated with all interfaces. if not, why??
and What is the need of this.
Appu
|
|
|
|
|
[default] is an indicator to scripting languages such as VBScript which interface is the default one. Such scripting languages cannot navigate to alternate interfaces, so in effect they can only access the single interface marked [default]. This attribute is saved in the generated type library but doesn't otherwise affect the generated code.
Visual Basic 6.0 can access non-default interfaces but this feature isn't commonly used. You simply create a variable of the interface type (e.g. Dim o As IOtherInterface) and assign an existing object to that variable - if the class implements that interface, VB assigns the variable, and if not, an error occurs. Similar behaviour occurs in .NET languages.
If all your clients are C++ clients you don't need to worry about this attribute.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
using the [default] attribute, we are specifying that this interface is to be returned for the client by default at the time of creating object using the ProgID.
let us say the scripting client create an object for MSXML Parser using the CreatObject("Microsoft.XMLDOM") method.
by default IXMLDOMDocument interface is returned. here is where we can realize the use of this
[default] attribute.
there cannot be many [default] keywords.. one for incoming and one for outgoing interface is allowed that's all . also if you are not specifying anything, by default the first thing is taken.
^-^
@|@
- redCat
|
|
|
|
|
Hi folks,
I'm developing a DCOM Client/Server project under Win2000 SP4 (both client and server) with VC++ 6.0.
An object in this project has to interface with National Instruments Vision Builder 7, which DLLs are registered under \system32 folder (the package works with no problem)
In this object, I have to pass an UDT that is a struct containing a safearray of another struct and two integer (that is, the safearray contains the RGB Values of all the points of my image and the two integers keep the image size). These structures are shown below.
When I compile, I get MIDL warning 2368: Could not set UUID ... etc etc etc... but I've seen that this can be ignored with no problems.
Now, when I run both client and server, I get an error when preparing to pack the safearray. In facts, I call GetRecordInfoFromGuids to build my SafeArray with VT_RECORD. Before, I was not doing error checking and everything seemed to be alright, but I got crashes. Now, that I added an if (FAILED(hr)) statement just after the call, I get a 0x80029C4A value, that is "Cannot load type library/DLL".
Here's the structs:
typedef <br />
[uuid(394143BC-4672-4E14-85DB-A96EBCA5A417),<br />
version(1.0),<br />
helpstring("RGB Representation of a single point")]<br />
struct RGBValue_struct {<br />
unsigned char B;
unsigned char G;
unsigned char R;
unsigned char alpha;
} RGBValue;<br />
<br />
<br />
typedef<br />
[uuid(7F7037D8-C4D5-4b75-9C68-A9627EDE914B),<br />
version(1.0),<br />
helpstring("IVA_Data COM Wrapper")]<br />
struct COM_IVA_Data<br />
{<br />
SAFEARRAY(PointFloat) saPoints;<br />
int numPoints;<br />
int pointIndex;<br />
}COM_IVA_Data;
Here's the function call :
HRESULT Image2Variant (IVA_Image Source, COM_IVA_Image *Dest)<br />
{<br />
<br />
HRESULT hr = 0;<br />
SAFEARRAYBOUND sabRGB[2];<br />
<br />
sabRGB[0].lLbound = 0;<br />
sabRGB[0].cElements = Source.columns * Source.rows;<br />
<br />
hr = SafeArrayDestroy(Dest->saPoints);<br />
if (hr != 0)<br />
{<br />
sprintf(logMessage, "CAugVisionEngine - Image2Variant - SafeArrayDestroy Failed (%ld)",hr);<br />
WriteLogFile(logMessage);<br />
}<br />
Dest->saPoints = NULL;<br />
IRecordInfo *pUDTRecordInfo = NULL;<br />
hr = ::GetRecordInfoFromGuids(LIBID_AugSvrLib, 1,0,0,RGBValue_IID, &pUDTRecordInfo);<br />
if (FAILED(hr))<br />
{<br />
sprintf(logMessage,"GetRecordInfoFromGuids failed (0x%X). Invalid Argument.",hr);<br />
WriteLogFile(logMessage);<br />
return(-1);<br />
}<br />
<br />
Dest->saPoints = SafeArrayCreateEx(VT_RECORD, 1, sabRGB,pUDTRecordInfo);<br />
if (Dest->saPoints == NULL)<br />
{ <br />
WriteLogFile("Image2Variant - Array Cannot be Created");<br />
return (-1);<br />
}<br />
<br />
Dest->columns = Source.columns;<br />
Dest->rows = Source.rows;<br />
<br />
for (int i = 0; i < Source.columns*Source.rows; i++)<br />
{<br />
<br />
RGBValue TempValue = Source.array[i];<br />
hr = SafeArrayPutElement(Dest->saPoints, (long *)&i, &TempValue);<br />
if (hr != 0)<br />
{<br />
<br />
WriteLogFile("SafeArrayPutElement failed!");<br />
return (NULL);<br />
<br />
}<br />
}<br />
<br />
return (S_OK);<br />
}
Here's the method prototype where I make the above function call:
In .IDL:
HRESULT loadImage([in]BSTR FileName, [out, retval]COM_IVA_Image *IVAImage);
In .H
STDMETHOD(loadImage)(/* [in] */ BSTR FileName, /* [out] */ COM_IVA_Image *IVAImage);
Here's what I verified:
1) The typelib is both on source and in executable folder (on both machines);
2) The DLLs are all under \system32 folder. I have moved none of them to my executable folder.
3) proxy/stub DLL is correctly registered in both machines
4)
I'm really stuck. I don't know what to do and I had to release project to customer 2 months ago...
Thanks in advance,
Morenz
|
|
|
|
|
just a guess..
i have always seen iid name to be seen as class name..
RGBValue_struct_IID inplace of RGBValue_IID ....in ::GetRecordInfoFromGuids(LIBID_AugSvrLib, 1,0,0,RGBValue_IID, &pUDTRecordInfo);
if still problem persists ...need more info .. >>>>
cheers
vibhash
|
|
|
|
|
hi,
thank you for the reply!
(un)fortunately, it was my fault, because I have currently 2 versions of this project (the MFC and the Service ones), that are slightly different, and I used the wrong type library...
Thanks again!
|
|
|
|
|
Hi All, there is Strange problem that i am facing?
i am interested in COM?
i have a n/w server application (Say Server A)that registers component in ROT say CompA ( Apartment, created and registered from MainThread ).
The responsibility of this component is to query some results (one by one )from an Out-Proc Component (service, STA). The result fetching happen in 3 steps ( open, next, close).
now if the request comes to the Server A, the server spawns a new thread, the thread function gets the interface pointer from ROT ( item moniker ) and uses CompA to service.
calling CoCreateInstance per request, and the interface pointer is stored in map, mapped with request id, which is used by the client to fetch result thru the next([in]reqid, [out]result) fn..
the requst id is uniq and sent in all function calls, so that the CompA maps the result and client correctly..
now the problem is :
1. if the server is servicing for only one client, the results are proper.
2. if the server tries to service more than one client at the same time, the results are insconsistent (or) not getting partial results.
this seems to be a mind bender for me ??
by - Thanks in advance
redCat
what could be the problem?
is it a threading issue ?
moniker concept is used in wrong manner which goes inconsistent ?
hence i am using map inside the CompA - i have to used Critical Sections ?
is there any problem with RPC Channel (hence we are object is created from Moniker) ?
this seems to be a mind bender for me?
thanks in advance
- redCat
|
|
|
|
|
hi i want to know about the base classes or the obejects i declare in my class to make a transform filter with one input and 2 outputs.
|
|
|
|
|