|
Hi all,
Can anybody give me some pointers on how to pass the following
complex type through a COM interface ?
typedef struct ComplexType
{
Type type;
union
{
int intVal;
BSTR strVal;
BYTE* pbyteVal;
AnotherComplexType* pcomplexVal;
};
};
The real type contains different fields but you should get the
idea: it basically is just like a VARIANT only with more levels
of indirection.
I need to pass these structures between my COM component and
non-COM legacy code. Unfortunately, there is a threading issue
that causes a proxy and stub to be created even for in-process
deployment of my component, so simply passing a pointer doesn't
work.
Should I resort to custom marshalling ?
Kind regards,
Alwin!
|
|
|
|
|
Define your type(s) in IDL and it will create marshalling code for it.
--
He just smiled and gave me a vegemite sandwich.
|
|
|
|
|
I've spent a week on making COM+ ManagementTool displaying COM+ Catalog Infomation using COMAdminCatalogCollection.
Currently,I'm using VB.NET to do this job.
Most of infomation I'd like to
find was in COMAdminCatalogCollection.
But I couldn't find a way of retrieving imfomation of state of Object activated. I'd like to know how many Object is Activated as if I see the COM+ Management Tool provided in Windows 2003.
Please,Help me.
Any idea will be helpful.
|
|
|
|
|
I used the Object Viewer tool to generate the IDL file for Shocwave Flash control, it appears to be ok. However, when I use MIDL to generate the header file, the methods in the IShockwaveFlashEvents interface are not generated, even if they are present in the IDL file itself.
Is this standard behaviour or am I just stuck with an amateur mistake?
I can generate my sink class based on the information found in the IDL, but I'd rather use MIDL for the task as I'll be interfacing with other controls in the future and want to learn the ins and outs of Visual Studio.NET.
The event interface is in fact based on IDispatch (i.e. dispinterface), is this the reason the methods are hidden from the generated header file? So, even if the methods are present in the IDL along with their disp ids, they won't be automatically included, but force the developer to query for the methods to find the disp ids.
Then again, should my event sink be based on IDispatch as well or should I manually copy the declarations to form the vtable as defined in the IDL?
Please take the time and guide a COM/ATL newbie to a solution.
Thanks!
|
|
|
|
|
Hi,
I am working on this ATL dll, which has one object that implements
connection points. I added some methods in the event interface that take
VARIANT as parameters, so that I may receive the variants in events when I
use the same from VB.
In IDL file it is like
////////////////////////////////////////////////////
[id(3), helpstring("method SampleRecordPkt")] HRESULT SampleRecordPkt([in]
VARIANT vBytes);
////////////////////////////////////////////////////
Now, I am trying to fire this from my code as follows - (All the hard coded
stuff I did for debug only.)
////////////////////////////////////////////////////
BYTE bytes[] = {5, 123, 9, 0, 5, 0, 0, 191, 157};
COleSafeArray saBytes1;
saBytes1.CreateOneDim(VT_UI1,sizeof(bytes));
for(long i = 0; i < sizeof(bytes);i++)
{
BYTE val = bytes[i];
saBytes1.PutElement(&i,&val);
}
file://fire off the appropriate event
VARIANT var = saBytes1.Detach();
Fire_SampleRecordPkt(var);
/////////////////////////////////////////////////////
However, inside "Fire_SampleRecordPkt(var)", the application crashes. The
crash occurs at the line given below (wizard generated code, when "implement
connection point" is chosen.)
////////////////////////////////////////////////////
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x3, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD,
&disp, &varResult, NULL, NULL);
////////////////////////////////////////////////////
Can some body help me identify where I am wrong? Any help is appreciated.
Thank you
aby
|
|
|
|
|
Hello Aby,
I have some clues as to what might have gine wrong but I need some more information from you first :
Is the events proxy code implemented somewhat like the following ? :
HRESULT Fire_SampleRecordPkt(VARIANT vBytes)
{
CComVariant varResult;
T* pT = static_cast<T*>(this);
int nConnectionIndex;
CComVariant* pvars = new CComVariant[1];
int nConnections = m_vec.GetSize();
for (nConnectionIndex = 0; nConnectionIndex < nConnections; nConnectionIndex++)
{
pT->Lock();
CComPtr<IUnknown> sp = m_vec.GetAt(nConnectionIndex);
pT->Unlock();
IDispatch* pDispatch = reinterpret_cast<IDispatch*>(sp.p);
if (pDispatch != NULL)
{
VariantClear(&varResult);
pvars[0] = &vBytes; // <-- important.
DISPPARAMS disp = { pvars, NULL, 1, 0 };
pDispatch->Invoke(0x1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, &disp, &varResult, NULL, NULL);
}
}
delete[] pvars;
return varResult.scode;
}
Please note the line in which I added the comment "// <-- important.".
Please let me know because I suspect your problem may be a case of wrong code generated by the wizard.
Please revert,
Bio.
|
|
|
|
|
I'm develeping a Free Threaded model COM exe component.
in some functions I want to use _bstr_r wrapper class.
When I use it I get the following error:
Linking...
LIBC.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Release/ExcelExportImport.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.
I don't get the error in debug. Why is that ?
|
|
|
|
|
Your release build flags include _ATL_MIN_CRT. Remove the definition, or alternatively, remove all use of the CRT functions, using equivalent API calls instead (yeah, right!).
See Q291952 at MSDN Online for more details.
Steve S
|
|
|
|
|
Hi Guys!
I'm novice in DCOM and my question will be very easy.
I'm created COM-server and its COM-client. I can successfully run both on the same machine and successufully run
on the separate machine (with modification in dcomcnfg). The code is not changed when remote running.
I used the follows (it works fine):
IEncoder * pEncoder;
HRESULT hr=CoCreateInstance(CLSID_Encoder,
NULL,
CLSCTX_SERVER,
IID_IEncoder,
(void **)&pEncoder);
I'm trying to specify exactrly on which machine COM-server should be run using the follows:
WCHAR *wszMachineName=L"STAR\0";
COSERVERINFO srv;
ZeroMemory(&srv,sizeof(srv));
srv.pwszName=wszMachineName;
MULTI_QI qi;
HRESULT hr=CoCreateInstanceEx(CLSID_Encoder,
NULL,
CLSCTX_SERVER,
&srv,
1,
&qi);
This returns E_INVALIDARG.
What should I do to remotely invoke my COM-server from another machine using CoCreateInstanceEx() ?
Yours sincerely,
Alex Bash
|
|
|
|
|
Have you defined _WIN32_DCOM in your client? Also, you might want to set the MULTI_QI (qi in your case) memeber pIID to the address of the interface you are requesting to be returned and then try calling CoCreateInstanceEx.
Hope this helps.
|
|
|
|
|
Hello,
I have been trying to compile the sample code that comes with "Insdie OLE". Although the code compiles but when i try to run it. It asks for a inole.dll. which i cant find anywhere with the sample code. Can anyone help me with this. Thank you
|
|
|
|
|
Help, guys!
I'm novice in COM and my question is very easy.
I've created my first COM-server (say, Encoder that have produced files Encode_i.c and Encode.h).
Now, I'm writting COM-client for my COM-server. I've created new project (Simple Win32 application), copied
Encode_i.c and Encode.h into project with my COM-client. When I try to compile COM-client, I got the follows:
c:\home\encodeclt\encode_i.c(50) : fatal error C1010: unexpected end of file while looking for precompiled header
directive
Error executing cl.exe.
EncodeClt.exe - 1 error(s), 0 warning(s)
What should I do?
Yours sincerely,
Alex Bash
|
|
|
|
|
Read the C++ FAQ here on CP
You need to adjust the project settings for that particular file so that it does not use precompiled headers, or alternatively, #include it into stdafx.cpp.
Steve S
|
|
|
|
|
I have been given an IStorage pointer as part of a drag and drop operation and I would like to extract the contents into a block of memory. Whats the best way to do this? So far I have used the following method which seems to work but looks a bit naff. Anybody got any comments to make?
<snippet>
<br />
VOID ExtractStorageData(IStorage *pStorage)<br />
{<br />
<br />
WCHAR fspec[MAX_PATH];<br />
CreateTempFilename(fspec);<br />
<br />
<br />
IStorage *pNewStorage;<br />
pStorage->StgCreateDocfile(fspec,<br />
STGM_CREATE | STGM_DIRECT | STGM_READWRITE | STGM_SHARE_EXCLUSIVE,<br />
0,&pNewStorage);<br />
<br />
pStorage->CopyTo(NULL,NULL,NULL,pNewStorage);<br />
<br />
pNewStorage->Release();<br />
<br />
<br />
BYTE buffer[65535]<br />
<br />
HANDLE h=OpenTempFile(fspec);<br />
ReadTempFile(h,buffer,sizeof(buffer));<br />
CloseHandle(h);<br />
}<br />
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
You can read directly into memory without creating tem file:
Instead of "StgCreateDocfile":
1)CreateILockBytesOnHGlobal
2)StgCreateDocfileOnILockBytes
then get a HGLOBAL (GetHGlobalFromILockBytes) and read it
HTH
Edward
|
|
|
|
|
I have a question regarding COM objects.
I have created a COM object (dll) that is used by an ASP page. The thing is that when multiple users call the page with COM, the object can not process multiple requests simoultaneusly.
Why is that ?
I'm using VC++ 6.0
|
|
|
|
|
Is your object STA?
Steve S
|
|
|
|
|
Now my object is Free with Free threaded marshaller.
It works from a .exe test program, but it's still not working from the ASP page.
I think it's something related to ASP.
|
|
|
|
|
Probably. You might do better posting in 'Web Development'
(and I expect the clickety-police to be along any second now...)
Steve S
|
|
|
|
|
Hi,
How to Use C++ code in VB???
please help me inthis regard
Imran
|
|
|
|
|
An easy way to do it is to create OLE automation compatible COM servers.
--
<british-accent>Pass the jam, would you?
|
|
|
|
|
And a good, fast way to create Automation-compatible COM Servers is to use ATL.
- Bio.
|
|
|
|
|
Indeed!
--
<british-accent>Pass the jam, would you?
|
|
|
|
|
|
|