|
You probably have to create a drawing in your application, say, AcadApp.NewDrawing() (just guessing here, though it may be a model then a drawing) then in your created Drawing do Drawing.AddLine(pt1, pt2)
|
|
|
|
|
Hi,
Are you sure the AutoCAD.AcadLine is COM object? You can check in Registry if you not able to find any where else and look for this ProgID.
-
|
|
|
|
|
I wrote managed C++ code to call a COM methods. I got message "cannot convert parameter 1 from 'double *' to 'double %'" from Visual Studio compiler. Does anybody know what is the type 'double %'?
|
|
|
|
|
This is the wrong forum.
% in C++/CLI is a managed reference.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
«_Superman_»:
Thanks. But how to call a function with parameter of managed reference type? For example,
COM:
STDMETHODIMP CTester::Total(DOUBLE* a, LONG count, DOUBLE* total)
{ ... }
Client:
int main(array<system::string xmlns:system="#unknown"> ^args)
{
double a[] = { 1.0, 2.0};
long count = 2;
double total;
ManagedReferenceComLib::TesterClass tester;
tester.Total(a, count, &total);
return 0;
}
Compiler gave
error C2664: 'ManagedReferenceComLib::TesterClass::Total' : cannot convert parameter 1 from 'double [2]' to 'double %'
Larry
|
|
|
|
|
Hi everyone,
I'm trying to send a COM object over a MSMQ message in C++. This is my object :
class ATL_NO_VTABLE CAnalisis :
public CComObjectRootEx<ccomsinglethreadmodel>,
public CComCoClass<canalisis,>,
public ISupportErrorInfo,
public IDispatchImpl,
public IPersistStreamInit
{
private:
typedef struct {
DOUBLE size;
float color;
float light;
BSTR imgName;
BSTR uname;
} Image;
Image img;
</ccomsinglethreadmodel>
Everything goes fine and I can get the whole object but the BSTR types. Floats and integers are properly sent and received. But the BSTR types dont work. I'm trying to send strings and can't find the way. I did try with VARIANT instead and the result was wrong too. Somehow, it looks like the strings are not serialized.
These are some of the get and set functions for my ATL component:
This one works fine:
STDMETHODIMP CAnalisis::getLight(FLOAT* light)
{
*light=img.light;
return S_OK;
}
STDMETHODIMP CAnalisis::setLight(FLOAT light)
{
img.light=light;
return S_OK;
}
This one doesn't :
STDMETHODIMP CAnalisis::getImgName(BSTR* imgName)
{
*imgName = img.imgName;
return S_OK;
}
STDMETHODIMP CAnalisis::setImgName(BSTR imgName)
{
img.imgName=imgName;
return S_OK;
}
and this is the way I create the MSMQ message and fill the values in my producer :
IMSMQQueueInfosPtr pQueueInfos;
IMSMQQueueInfoPtr pQueueInfo;
IMSMQQueuePtr pQueue;
IUnknownPtr pIUnknown;
IMSMQQueryPtr pQuery(__uuidof(MSMQQuery));
IMSMQMessagePtr pMessage(__uuidof(MSMQMessage));
IAnalisisPtr pAnalisis(__uuidof(Analisis));
WCHAR * imagen;
imagen = L"imagen1.jpg";
pAnalisis->setImgName(imagen);
(...)
pAnalisis->setFruitSize(20.00);
(...)
pQueueInfo = new IMSMQQueueInfoPtr( __uuidof(MSMQQueueInfo) );
pQueueInfo->PathName = "MYCOMPUTER\\private$\\myprivatequeue";
pQueue = pQueueInfo->Open(MQ_SEND_ACCESS, MQ_DENY_NONE);
pMessage->Body = static_cast<iunknown*>(pAnalisis);
pMessage->Send(pQueue);
If I get the BSTR value in the producer (before serialization), pAnalisis-getImgName() , it works fine. In contrast, when I try to get it in the consumer, after reading the message from the queue, it doesn't return anything. The other values, such as the size, are returned with no trouble.
The thing is: does anyone know how to send a BSTR value inside a COM object through MSMQ ?
I've tried to find some similar examples but unfortunately totally in vain.
PLEASE HELP!!!
thanks.
|
|
|
|
|
Hi,
There's an example in the book Wrox Proffessional DCOM Application Development. The object sent inherits from IPersistStreamInitImpl<cmyclass>, defines all it's private BSTRs as CComBSTR rather than BSTR.
private:
CComBSTR m_bstrCustomerID;
CComBSTR m_bstrArtist;
...
Then in a property map:
BEGIN_PROPERTY_MAP<cmyclass>
PROP_ENTRY("CustomerID", 1, CLSID_NULL)
PROP_ENTRY("Artist", 2, CLSID_NULL)
....
END_PROPERTY_MAP()</cmyclass>
Then declares put_ and get_ methods for the above:
STDMETHOD(put_CustomerID( BSTR newVal);
STDMETHOD(get_CustomerID( BSTR* pVal);
STDMETHOD(put_Artist( BSTR newVal);
STDMETHOD(get_Artist( BSTR* pVal);
In the IPersistStream method it has:
public:
STDMETHOD(GetSizeMax)(ULARGE_INTEGER* pcbSize)
{
pcbSize->QuadPart = sizeof(DWORD)
pcbSize->QuadPart +=
SizeOfBSTR(m_bstrCustomerID) +
SizeOfBSTR(m_bstrArtist) +
...
return S_OK;
}
Thre's more of course but this seems to be the basics. If this helps let me know if I've missed anything.
|
|
|
|
|
|
Great. Just for your information, if you inherit from IPersistStreamInitImpl and use the ATL property map, which contains, say a BSTR then call:
hr = pIPersistStreamInit->Save (pIStream, FALSE);
This ends up calling:
CComBSTR bstrWrite;
bstrWrite.Attach(*(BSTR*)pData);
hr = bstrWrite.WriteToStream(pStm);
which calls:
ULONG cb;
ULONG cbStrLen = CComBSTR::GetStreamSize(m_str) - sizeof(ULONG);
HRESULT hr = pStream->Write((void*) &cbStrLen, sizeof(cbStrLen), &cb);
if (FAILED(hr))
return hr;
return cbStrLen ? pStream->Write((void*) m_str, cbStrLen, &cb) : S_OK;
so ATL already provides the code which does what your solution suggests.
|
|
|
|
|
Ok mate. I'll be back to this in a few days. Now I'm busy with another project, but I'll try what you say, it looks cleaner and not as tricky as the given solution, though have to check it out.
|
|
|
|
|
I've got MSHTML calling my IAuthenticate interface to get the username/password when it's downloading stuff that needs authentication, but how do I know if it worked?
I have a username/password that will be correct *most* of the time but if it's not, I want to disable calls to my IAuthenticate so that the browser will revert to its normal behaviour i.e. show a dialog asking for authentication details. It'd be nice if I could also instruct the MSHTML instance to retry without using the credentials I supplied.
But to do any of this, I need to know if the username/password I gave worked. Just checking for a HTTP 401/3 might not work since I sometimes seem to get a "This page cannot be displayed" error.
I enjoy occasionally wandering around randomly, and often find that when I do so, I get to where I wanted to be [^].
Awasu 2.4 [^]: A free RSS/Atom feed reader with support for Code Project.
|
|
|
|
|
how to handle flow control without using MSCOMM control?
there is no such flow control property...
|
|
|
|
|
Am I right in thinking you are using VB6.0?
|
|
|
|
|
hello all,
i want to customize the context menu which appears when one clicks
on to a mail-id(in front of From: or To .
there are 2 ways of doing this either via xml or via dll's.
i have chosen to write a dll for it as it offers much more flexibility,but the real problem is using what i should write a dll .NET(vb,c# etc) or using unmanaged code(vc++). & what are the problems that could arise by using unmanaged code.
you can reply me at: n.chudekar.31@gmail.com
thanks n regards,
nikhil.
|
|
|
|
|
I have a method that accepts a VARIANT by value using [in] attribute in my IDL file.
Do I need to do a VariantClear () within my implementation method. Please
help. Thanks in advance.
B2C
|
|
|
|
|
Perhaps, it really depends on what's in your VARIANT. If it contains, say, an Int or a BSTR there's really no need. Once you have a VARIANT that contains a pointer to something else it can get a bit more complicated.
|
|
|
|
|
is it possible to write a program which can register activex in windows vista automatically?(in fact i want find a way to register activex in vista when i wasn't administrator)
|
|
|
|
|
I've never tried it but read a recomendation[^] to use HKCU\Software\Classes instead of HKCR or 'side-by-side' COM to do away with registration.
|
|
|
|
|
|
Hi
i read your link, but i don't know how can i do that? (to use HKCU\Software\Classes instead of HKCR)?
would you tell me more about this? thank you
Zo.Naderi-Iran
|
|
|
|
|
As I said I've never tired it and just read a recomendation. I did a search for 'HKCU Software Classes' etc on Code-Project and there seems more there than I could pass on here.
|
|
|
|
|
oh, thank you
Zo.Naderi-Iran
|
|
|
|
|
I want to write to a bmp file and read from it from a COM dll, kindly give me a quick solution.
|
|
|
|
|
There is nothing COM related here.
You can still use CreateFile , ReadFile , WriteFile for one.
You could also use fopen or fstream etc.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
i need its source file
Sujit Sahu (Cruel Handsome)
|
|
|
|