|
Hello!! how can i use void pointers in a parameter in a funcion of COM class??
I try this:
..........MyFuncion([out,retval] void * pResult)
and when i compile it CRASHHHHHHHH!!!!!!!!!
please help me...
my email is jsanchez@cie.com.mx
|
|
|
|
|
Hi,
The problem with any kind of pointers is that you can't return or pass it without marshaling the data it points to. If you are using the pointer to the well-known types, such as Long, BSTR, ... the default marshaling can be used. If you use an array of objects or void pointer you must provide additional information for marshalling. Have a look at the length_is() and other array related attributes of the IDL file. You also can return an array of data using a variant with SAFEARRAY. This is the best thing you can do if you are going to use the component in VB.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hi Jafet,
There are several techniques you can use and returning the VOID pointer is not one of them. There is a VERY nice article by Don Box in MSDN explaining your options and advantages/disadvantages.
The name of the article is "OLE Q&A". There are several articles with this name and I add the beginning of the article, so it will be easier to find.
Regards,
Alex Gorev,
Dundas Software.
------------------------------------------------------
"
OLE Q&A
Don Box
Don Box has been working in networking and distributed object systems since 1989. He is currently chronicling the COM lifestyle in book form for Addison Wesley, and gives seminars on OLE and COM across the globe. Don can be reached at dbox@braintrust.com.
QI am using dual interfaces to expose my objects to both C++ and Visual BasicТ clients. Designing the interfaces was relatively painless once I passed simple data types as method parameters. I now need to pass user-defined structures as parameters and can't get it to work. Any suggestions?
....
" -- MSDN.
------------------------------------------------------
----- Original Message -----
From: Jafet Sanchez Rodriguez <jsanchez@cie.com.mx>
To: <alexg@dundas.com>
Sent: Tuesday, July 04, 2000 11:42 AM
Subject: Re: [CodeProject] Re: void* in a parameter in COM function
> Hi Alex!!
> I want to pass a struct from vc to vb ..
>
> struct A
> {
> int a;
> int b;
> float c;
> }
>
> MYSTRUCT A;
>
|
|
|
|
|
guy's please help me with this one as i am new to COM
|
|
|
|
|
I use it:
BSTR sMyBSTR;
sMyBSTR = "Hola que onda!";
CComBSTR sCad;
sCad.Append(sMyBSTR);
|
|
|
|
|
Hi,
Variants store the strings as BSTRs. You can work with BSTR strings using the standard string functions if you convert it using the OLE2A(...) macro.
USES_CONVERSION;
char *p = strstr(OLE2A(m_bstrData), "Data=");
If you have a lot of string operations I recommend you to use the WTL's CString class. It's a light weight template, which duplicate the functionality of the popular MFC's string class.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
How to add a custom color property entry in PROP_DATA_ENTRY macro - what should be the vt value?
|
|
|
|
|
Hi,
If it possible use the wizards to add the property and specify the OLE_COLOR as a data type. When a property is declared as OLE_COLOR, the Properties window will display a color-picker dialog that allows the user to select the color for the property visually, rather than having to remember the numeric equivalent. Internally it's treated as a Long.
Regards,
Alex Gorev
Dundas Software.
|
|
|
|
|
Hi,
Thanks for replying.
The reason why I need the PROP_DATA_ENTRY is to persist the property. I have added properties using the wizard already. When I add an entry like...
PROP_DATA_ENTRY("Start Color", m_clrStartColor,VT_UI4)
the VB client gives invalid property when being persisted.
Please clarify.
Thanks & regards,
V.Lakshmi Narasimhan
|
|
|
|
|
Hi,
First of all if you have a Set/Get functions for the property and it's part of any property page it's better to use PROP_ENTRY macro. Even if you don't use the property page you can always set it to CLSID_NULL.
BEGIN_PROP_MAP(...)
PROP_ENTRY("StartColor", DISPID_START_COLOR, CLSID_NULL)
END_PROP_MAP()
The other thing I've noticed is that you use a space in the name of the property. Never use it in the name of the properties, it can cause all kind of problems.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hi...
While developing ASP Components in VC, is there any restriction to use MFC in it? Should we use MFC or not? If answer is "Yes" then explain it and if answer is "No" then explain it also
Thanks!
|
|
|
|
|
Hi,
There are no any restrictions... but ASP components do not have any GUI, so there is no any reason to use MFC. If you need a good string class use WTL instead.
So my answer is NO. Because you don't need MFC and it will affect the size and performance of the component comparing to ATL & WTL.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
HI HI HI
Need to now how to make com object to save an error to file so the client can't see any msgBox but i can view the errors from the file any time i want.
|
|
|
|
|
Hi,
I don't think it's possible to do... If the component shows the dialog on error there is no way ho hide this dialog and to get the error text, except if there are special methods/properties for that. Only if the standard IErrorInfo interface is used than you can change the component container behavior.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
Hi again
How about just make a com object to save the errors that comes up to file??
regard
Bjarni
|
|
|
|
|
Hi,
Is it a third party COM object, or you designed it by yourself? If you don't have the source code just the DLL file I don't see any ways to MAKE the COM object to write the error messages in the file.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
And how Visual Basic ActiveX DLLs get the reference to Component Manager
which implemented by client in order to display modeless forms in the
ActiveX DLL.
Thanks for any suggestion?
|
|
|
|
|
I beleive its Components Services in Win2000 in 98 or NT4
its where you make your packages ,you should definitly get the Platform SDK CD or download it from microsoft it'll give ya your answer,cause quite frankly I am not sure that I understand your question we'll at least I tried
Steeves ,C++ programmer
|
|
|
|
|
Hello,
I want to create an Apartment threaded compoent server which will be used by the main thread client.How do i go about doing this?Any tips will be of help!1
Best Regards,
R Acharya
|
|
|
|
|
Hi,
I don't understand what problems do you have... To create an Apartment threaded component just select the Attributes page of the ATL Object Wizard Properties and make sure that Threading Model is set to Apartment. It's a default value, so usually you don't have to change anything.
Regards,
Alex Gorev,
Dundas Software.
|
|
|
|
|
HI
I was wondering how a Client can see if a COM server that belongs to him exists in the registry. If an server exists I would like to add an item in the Client's menu.
Thank you for your time.
|
|
|
|
|
First you need to know either the CLSID or the ProgID of the server. If you know the CLSID then convert the CLSID to a string using StringFromCLSID. Then attempt to open the following registry key:
HKEY_CLASSES_ROOT\CLSID\"Your server's CLSID as a string"
If the key exists then the server has been installed on this machine.
If you have the ProgID, you can use CLSIDFromProgID() to get the CLSID and then proceed as indicated above.
The other option, is to use CoCreateInstance() to see if you can actually create the object and then shut it down. However, that might affect performance of your app unacceptably.
|
|
|
|
|
Call CoGetClassObject() and test to see if it fails with the REGDB_E_CLASSNOTREG error:
IClassFactory* pCF = NULL;
HRESULT hResult = CoGetClassObject(CLSID_TheObject, NULL,
CLSCTX_WHATEVER_YOU_WANT_TO_USE, (void**)&pCF);
if (FAILED(hResult))
{
if (hResult == REGDB_E_CLASSNOTREG)
{
// the server's not registered properly...
}
}
|
|
|
|
|
Hi,
I'm writing an add-in in Visual C++. I'd like to attach my own docking dialog bar and child window
to Visual C++ so it will look like an intergral part of it. I haven't been able to do that, and even though
MSDN says that you can create modeless dialogs (because they don't have their own message pump),
I HAVE seen an add-in called RadVC which similated a Visual Basic environment in Visual C++ - which
indicates that it IS possible to do what I want.
How can I do it then? Is there a specific COM interface for doing that?
Thanks.
|
|
|
|
|
Hi
I've implemented some code that adds an item to the context menu , but I need to add two subitems for that item.
Can you please help me ?
Thanks
|
|
|
|