|
Thank you.
You flew my trouble.
now I'm happy
goodday~
|
|
|
|
|
I would like to use a COM interface in a multithreaded project. Is there a sample available any where ? Any tips/pointers would be helpful. Thanks.
|
|
|
|
|
See this
Marshall, GIT
and if you care, this
GPF with atl and vb
Cheers,
Joao Vaz
A person who is nice to you, but rude to the waiter, is not a nice person - Natalie Portman (Padme/Amidala of Star Wars)
|
|
|
|
|
'Gpf with Atl and VB' is a good example. Thanks Vaz!!
|
|
|
|
|
Hi All,
I have a dll that works great in VB/ASP, but when I created an .idl file, I get an error when compiling:
.\test.idl(31) : error MIDL2025 : syntax error : expecting a type specification near "<"
.\test.idl(31) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation
below is where it is happening:
NOTE: On the following line, I had to put quotes in the code so you could see the code because it looked like a TAG in HTML...("<"GetRefTypeInfo failed">"**)
HRESULT GetItem([in, out] VARIANT* Server,
[in, out] VARIANT* Category,
[in, out] VARIANT* CType,
[out, retval] ("<"GetRefTypeInfo failed">"** );
The idl file was generated by OLE View (cut/paste) to test.idl and compiled with "C:>MIDL test.idl /h test.h"
Can anyone tell me why this is giving this error
Regards,
Dan
|
|
|
|
|
What's worng with the following code. I am getting
"Unhandled exception in XYZ.exe (OLE32.DLL):0xC000005: Access Violation"
(Note: This message board is eating off any thing within < > and hence you will find << >> instead of < > to avoid it)
#import <<comapp.dll>> no_namespace
class CMyClass :: public CWinApp
{
....
public:
CWinThread *m_Thread;
static UINT WorkerThreadProc(LPVOID pParam);
IComAppPtr g_pIComApp;
...
};
CMyClass::CMyClass()
{
g_pIComApp = *(new IComAppPtr(__uuidof(ComApp)));
g_pIComApp->XYZ();
m_Thread = AfxBeginThread((AFX_THREADPROC)WorkerThreadProc, static_cast<<lp_void>>(this), THREAD_PRIORITY_ABOVE_NORMAL, 0);
};
UINT CMyClass::WorkerThreadProc(LPVOID pParam)
{
CMyClass *mPtr = static_cast<<cmyclass *="">>(pParam);
/*******************************
// Whats wrong here? When I call the following function
// I get ACCESS VIOLATION OLE32.dll
mPtr->g_pIComApp->XYZ();
//******************************************
};
Thanks for your help.
|
|
|
|
|
If you want to use an interface from a worker thread you must marshal that interface. This makes sure that if the worker thread and the object exists in two different appartments, then the method will be invoked in the proper appartment.
Take a look at the global interface table for an easy way to marshal interfaces.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I am new to COM etc and I don't have no knowledge of Marshaling etc.
I have noticed some code "CoCreateFreeThreadedMarshaler(..) etc" created by MFC. Is that what you are talking about ? Please confirm. Or any other pointers or samples would be helpful.
Thanks a lot.
|
|
|
|
|
You'll also have to initialise the COM library by calling CoInitialize or CoInitializeEx
|
|
|
|
|
A confusion has prevailed for quite some time for me now that what exactly is the COM status in .NET like how can we create COM components in .NET and what r the similarities and dissimilarities in COM components coded b4 and now in .NET?
Zaki
|
|
|
|
|
I disagree that there is any confusion except by naysayers wanting to dropkick MS and/or .NET
COM is very much alive and well in .NET. In fact, my Inside C# book has over a 100 pages dedicated to the subject of COM interop!
Here's what Don Box had to say aobut the future of COM development regarding .NET
“Virtually all aspects of the COM programming model have survived (interfaces, classes, attributes, context, and so on). Some may consider COM dead simply because common language runtime objects don't rely on IUnknown-compliant vptrs/vtbls. I look at the runtime as breathing new life into the programming model that I've spent the last seven years of my life working with, and I know there are other programmers out there who share this sentiment" - Don Box
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
|
|
|
|
|
i am not trying to paly down the .NET here, the only reason i have posted this question was that we here in pakistan dont have the access to the newer books on .NET , and the one i got had potryed this concept which i mentioned in my question
i am working in .NET so i had to confirm what i had read and also get some views on it from other ppl
|
|
|
|
|
zakimurtaza wrote:
i am not trying to paly down the .NET here,
You misunderstood, mate. I was referring to the information you were getting from other sources. I've, myself, read many articles saying things like COM is dead under .NET and was really just letting you know that this rumours are greatly exaggerated.
zakimurtaza wrote:
I am working in .NET so i had to confirm what i had read and also get some views on it from other ppl
That is the way to learn and certainly the approach I take.
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
|
|
|
|
|
how to load a conventional DLL in a COM Server?
|
|
|
|
|
The same way as you would in any other application. You can use LoadLibrary or link the .lib file, COM makes no reserve on this...
At least I hope so - the COM server I'm building for work does it
Dylan Kenneally
London, UK
|
|
|
|
|
What I want to know is how to set the path of DLL?It seems that I cannot locate the DLL.I wrote the full path in the LoadLibrary,but it failed.
|
|
|
|
|
What message did it fail with? It's not something silly like not having your path wrapped in quotes ("\"c:\develop\my dll\lib.dll\"") when theres a space in the path is it?
Dylan Kenneally
London, UK
|
|
|
|
|
can anybody tell me how to register a com dll with c++ code? better give me some piece of code, thanks!;P
Richy
|
|
|
|
|
Load the dll into your process with load library, then call GetProcAddress for DllRegisterServer and call that function. This is how regsvr32 registers the DLL.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
typedef HRESULT (STDAPICALLTYPE *CTLREGPROC)() ;
HMODULE hModule = ::LoadLibrary(m_strPathName);
CTLREGPROC DLLRegisterServer = (CTLREGPROC)::GetProcAddress(hModule,"DllRegisterServer" );
DLLRegisterServer();
::FreeLibrary(hModule);
Regards
Carlos Antollini.
www.wanakostudios.com
Sonork ID 100.10529 cantollini
|
|
|
|
|
I'm a newbie and have just read one whole entire book on COM and part of another. I understand most but not all of it. I might have missed this but if I want to develop a COM object or ActiveX control for use by Visual Basic, do I have to use variant data types (in my Visual C++ server code) or will it get automatically converted from the type library? I guess I'm talking about for automation purposes/late binding. Though, I'm not sure.
|
|
|
|
|
You can use any automation types.
soptest
|
|
|
|
|
Ok. Thanks. Yes, now I recall the other automation data types. I think I got confused with example in book saying something about using Variants was better for automation late binding...maybe it was referring to the script languages.
|
|
|
|
|
Yes, variants for scripts.
soptest
|
|
|
|