|
Dear Lim,
thank you for trying to help. I caused the problem by not defining the right order of parameters. Vita stated in his posting (one message entry below yours) that "The arguments in the array should be placed from last to first". As soon as I read his posting I understood that I had overlooked this requirement, which for itself is sad enough...! Defining it the proper way fixed my problem.
Thank you again,
Rubi
|
|
|
|
|
Hello Rubi,
No problem and congratulations on discovering the bug. Best of luck to your project.
Regards,
Bio.
|
|
|
|
|
Take a look into MSDN's "Passing Parameters" topic (or search for these words). From there:
typedef struct FARSTRUCT tagDISPPARAMS{
VARIANTARG FAR* rgvarg;// Array of arguments.
DISPID FAR* rgdispidNamedArgs; // Dispatch IDs of named arguments.
unsigned int cArgs;// Number of arguments.
unsigned int cNamedArgs; // Number of named arguments.
} DISPPARAMS;
The arguments are passed in the array rgvarg[ ], with the number of arguments passed in cArgs. The arguments in the array should be placed from last to first, so rgvarg[0] has the last argument and rgvarg[cArgs -1] has the first argument. The method or property may change the values of elements within the array rgvarg, but only if it has set the VT_BYREF flag. Otherwise, consider the elements as read-only.
With best wishes,
Vita
-- modified at 10:36 Friday 11th November, 2005
|
|
|
|
|
Dear Vita ,
thank you so much for helping me solve the problem. The reason was in fact the order by which the args were defined , I had overlooked the requirement that , as you stated : "The arguments in the array should be placed from last to first". After having fixed this , everything works out fine now .
Thank you,
Rubi
|
|
|
|
|
Hi all,
I have a really difficult problem.
I have an MFC application that hosts scripts via IActveScript engine. Inside the script I have created a COM object that exposes some events. The very same object is correctly used in a regular vbs scipt host by WSH:
<br />
Dim obj<br />
Set obj = CreateObject ("cnitfc.myobj")<br />
wscript.ConnectObject obj, "myobj_"<br />
<br />
Sub myobj_Event (nParam)<br />
msgbox "event fired"<br />
End Sub<br />
and myobj_Eventis is invoked when myobj fires "Event" event.
How to implement the very same "ConnectObject" method that is built-in into wscript object?
Thanks a lot in advance.
Regards,
Andrea
|
|
|
|
|
Now I'm trying to use IFolderCollection:
struct __declspec(uuid("c7c3f5a3-88a3-11d0-abcb-00a0c90fffc0"))
IFolderCollection : IDispatch
{
...
virtual HRESULT __stdcall get_Item (
VARIANT Key,
struct IFolder * * ppfolder ) = 0;
...
}
In my code, I have got an interface of IFolderCollection. And I want to enumerate the sub folders:
LONG nCount = qSubFolders->GetCount();
...
//
for (INT nLoop = 1; nLoop <= nCount; nLoop++)
{
CComVariant vtKey(nLoop);
vtKey.ChangeType(??????????); //Which type is "Key" type?
CComPtr<IFolder> qFolder;
qSubFolders->get_Item(vtKey, &qFolder); //Always fail!
if (qFolder == NULL)
{
}
...
In VB, I can write "Curfolder = Subfolders.Item(1)", but what about C++?
-- modified at 23:27 Sunday 6th November, 2005
|
|
|
|
|
Do you have access to the get_Item function? It is the only way to know the type. If I correctly undestand
<br />
set Curfolder = Subfolders.Item(1)<br />
works, so it should work in C++ as well, with vtKey.ChangeType (VT_I2), vtKey.ChangeType (VT_I4), vtKey.ChangeType (VT_R4), or vtKey.ChangeType (VT_R8).
You should also get the return code or some error info.
Regards,
Andrea
|
|
|
|
|
Thanks a lot.
I'm sorry that I made a mistake.
I haven't used VB for 2 years, so actually
set Curfolder = Subfolders.Item(1) is only in my memory, it can NOT work.
I found I could only visit this collection via "for each" in VB:
<br />
For Each folderCur In subFolders<br />
Debug.Print folderCur.Path<br />
Next<br />
So what should I do in C++?
Shall I use IFolderCollection::get__NewEnum(IUnknown * * ppenum) method?
How to?
Thanks.
-- modified at 7:54 Monday 7th November, 2005
|
|
|
|
|
I'm not an expert with Enum. I found some info on MSDN, look for IEnumXXXX and IEnumUnknown.
In the C++ client you have to call Reset (), Next () in order to enumerate all the items.
Look at ALCCollection sample, and keyword _Copy, CComEnumOnSTL, ICollectionOnSTLImpl, CAdapt, IEnumVARIANT, std::map, std::string, std::vector
Hope this helps.
Regards,
Andrea
|
|
|
|
|
I have tried out one way to enumerate sub folders:
<br />
...<br />
CComPtr<IUnknown> qUnkown;<br />
qSubFolders->get__NewEnum(&qUnkown);<br />
if (qUnkown == NULL)<br />
{<br />
cout << "Fail to query _NewEnum!" << endl;<br />
return;<br />
}<br />
<br />
CComQIPtr<IEnumVARIANT> qEnumVT = qUnkown;<br />
if (qEnumVT == NULL)<br />
{<br />
cout << "Fail to query IEnumVARIANT!" << endl;<br />
return;<br />
}<br />
<br />
for (INT nLoop = 0; nLoop < nCount; nLoop++)<br />
{<br />
CComVariant vtEnum;<br />
qEnumVT->Next(1, &vtEnum, NULL);<br />
<br />
if (vtEnum.vt == VT_DISPATCH)<br />
{<br />
CComQIPtr<IFolder> qFolder = vtEnum.pdispVal;
<br />
vtEnum.pdispVal->Release();<br />
<br />
if (qFolder != NULL)<br />
{<br />
CComBSTR bstrPath;<br />
qFolder->get_Path(&bstrPath);<br />
...<br />
}<br />
}<br />
}<br />
However, how to use property "Item" in VC is still a question.
Thank you.
-- modified at 12:58 Monday 7th November, 2005
|
|
|
|
|
In my opinion Item can be used "as is" and has little to do with enumeration, so I think the variang parameter can be a string instead of a number. This can be a particularity in your object.
|
|
|
|
|
I feel that this is such a stupid question, but I'll feel even more stupid if I don't ask it...
Let's say I have a DCOM app on server machine 'S'.
I have appropriate entries via DCOMCNFG on client 'C' so that it will (and does) run, and my client can instantiate an object on the server, and call it's methods.
For XPSP2 there are two sets of permissions;
Access
Local Access
Remote Access
Launch/Activation
Local Launch
Remote Launch
Local Activation
Remote Activation
Now, my questions are:
How does Launch differ from Activation?
Which machine(s) do the permissions need to be set on? In other words, if I have set security to deny access on the server, do I need to set security on the client as well, in order to allow the client 'out'?
My better question is 'Where can I get more information on DCOM security that is up to date?', I think!
Thanks in advance for any information/help.
Steve S
Developer for hire
|
|
|
|
|
hi all of u,
i am new to com development,while i am developing a component in c++ it will asks unknwn.h header file . i downloaded the file from microsoft and included it in the component.after that i compiled the component then it will gives the fatal error, how can i overcome this problem,Please help i need the solution,it's very Urgent.
RaviKumar
-- modified at 1:46 Saturday 5th November, 2005
|
|
|
|
|
You will find this files and related files in Platform SDK.
Have a great day ahead!
Regards,
Sohail Kadiwala
(My Blog - http://blogs.wdevs.com/sohail/[^])
modified 21-Apr-21 21:01pm.
|
|
|
|
|
My problem is not the function OleCreateLinkToFile() itself, but the resulting pointer.
ppvObj
[out] Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvObj contains the requested interface pointer on the newly created object.
Is there any way to get the interface-pointer to the "real" com-object itself. For example, if i open a word document can i get the interface-pointer of the shown word.document or running word.application starting from the ppvObj-pointer.
My understanding of OLE is not good enough to see the right way (hope there is one ).
|
|
|
|
|
The second parameter tells the function what interface reference you want to the object. There is no "real" object - there are only interface pointers. If you want another interface of the object, you can always QueryInterface() to get it.
--
Pictures[^] from my Japan trip.
|
|
|
|
|
Hi,
I would like to write a COM server (developed in VC++ 6.0) that returns 2 doubles in the parameters of the method (not as a return value).
In the Automation Tab on the MFC ClassWizard I add a new method with the right Method Name, Return Type (a short) and for Parametrs List I add to parametrs of type double*. So far so good. Then I compiled the server and register the server.
The client (a VB 6 application) I include the server in the Reference window, I define and create a variable of the server type. Then I invoke the method:
Dim x, y as Double
Dim TheServer as Myserver
set TheServer = new Myserver
dim nRes as Integer
nRes = TheServer.MyMethod(x,y)
And when I run the above code I get a "Type missmatch"
I other server that I developed I'm used to send doubles to the server, but now when I'm tring to "get" the doubles I have this problem.
Thanks in advance for any input,
Razvan
|
|
|
|
|
Did you put the [out] attribute in the method IDL declaration?
|
|
|
|
|
Thanks for your reply.
I'm using an automation interface, created by the "MFC ClassWizard". I don't know how to add that property to the parameters. I tought that just choosing the parameters as "double*" it is enough for "ODL" to know that I'm trying to "get" the value from the function.
Best Regards,
Razvan
|
|
|
|
|
I received a VC# COM component from a customer (.dll and .tlb files only) and I would like to use it in my VC++6 application.
Method 1: What I did so far:
1) Utilize the ClassWizard to import the type library file.
2) Two wrapper classes were created IClass and IClassEvents
3) I was able to access the component methods for IClass without any problem. However the COM component (I believe) fires a notification to the client when each method has completed and data is passed back (LPCTSTR data). I looked into the IClassEvents wrapper class that was generated for me by the ClassWizard and there is a CommandCompleted(BOOL success, LPCTSTR data)interface. The question is how can I access "LPCTSR data". I know that you have to implement some kind Sink class that implements the CommandCompleted method and advise the COM component the CommandCompleted interface. But I don't know HOW. Please help...provide example if possible.
Method 2: I have also tried the #import directive "..\..\theCOM.tlb no_namespace name_guids but got as far as the Method 1. This method generates .tlh and .tli. and I am kinda lost looking at the content of these two files.
Any help would greatly appreciated!
|
|
|
|
|
Hi again....
I finished my work, and I tested its modules one by one and they worked well.
Now that I put them together, I went into a trouble: my server acts like a memory-consuming program...
Let me explain.... I open Task Manager (on Win2000 Pro) on the server machine and, as I run the client, I see the memory growing up (both Memory Usage and VM Size) and page faults incrementing in hundreds per second.
When I'm about at half of my test procedure, I see this
Memory Usage: 22,680K
Peak Memory Usage: 164,084K
Page Faults: 512,718
VM Size: 508,640K
Don't jump on your chair, these procedures work with images and send images as arrays, so it's normal to have huge structures on my wires...
So I See that VM is not released, but I don't know why. It seems that function pointer is not well-released (because actual memory usage is normal, but VM no). I tried to AddRef and Release interface pointer in every function, instead of at hte beginning and at the end of the whole program, but it did not change a bit.
What can be the problem?
Thanks in advance,
Morenz.
|
|
|
|
|
|
I got it. I was using malloc instead of CoTaskMemAlloc (and free instead of CoTaskMemFree)
Now I'll change all of my statements (some hundreds!!!) and will try.
Thanks a lot for now!!!
|
|
|
|
|
Hello, everyone!
Please help: I want to know how to convert _bstr_t to wchar_t*?
Thanks a lot!
|
|
|
|
|
er, maybe this is a trick question, but how about:
_bstr_t t(L"test");
wchar_t* p = t;
|
|
|
|