|
|
Hey Guys,
I'm trying to port a plain WIN32 dll over to another system which uses ATL to implement the interface. I know nothing about ATL but I've sort of got it working aside from the fact I can't figure out how to get the HINSTANCE of my DLL.
The DLLmain does the following
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_My_Plugin, CMyPlugin)
END_OBJECT_MAP()
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID )
{
if (dwReason == DLL_PROCESS_ATTACH)
{
_Module.Init(ObjectMap, hInstance);
DisableThreadLibraryCalls(hInstance);
}
else if (dwReason == DLL_PROCESS_DETACH)
_Module.Term();
return TRUE;
}
I can see the _Module gets the HINSTANCE here but how do I get to it from the CMyPlugin class?
Cheers
James
|
|
|
|
|
_Module.GetModuleInstance();)
|
|
|
|
|
Thanks. Didn't realise it was that straightforward.
Cheers
James
|
|
|
|
|
I found a solution to build myDLL, using yourDLL, with /FORCE:MULTIPLE only...hope you got the problem...it was something like /Gw option but I dont have yourDLL code thats why I could this /FORCE:MULTIPLE only.
It kills me every time when I build it by saying" image may not run"
Is there any other solution to this?
part-2------------------------------------------------------------------------
In trying to use yourDLL in myDLL. I've declared it as private member and Initialized it one function, first function. It works fine here. When I call this existing object from second function, it says "cant read the memory". Of Course a test-client calls myDLL to raise these errors otherwise myDLL builds OK.
I'm always wrong....whats appropriate way?
thanx to HELPERS!
I'll pray for YOU!
Swimming in a fish bowl.
|
|
|
|
|
What is the best way to define a map of string to CComPtr<iunknown> using MFC's CMap?
Best regards,
Paul.
Jesus Christ is LOVE! Please tell somebody.
|
|
|
|
|
I'm trying to use a bitset that would be the key for a map.
Something like map< bitset<100>, CMyClass * >
The problem with that the bitset is not LessThan Comparable.
And I have no idea about how to compare two bitsets. I cannot convert to ulong since it is 100 bits! Anybody has already implemented a comparison operator for bitsets?
Help greatly appreciated!
|
|
|
|
|
The following is not the most efficient way, but it should work (not compiled it, expect typos):
template<size N>
int compare(const std::bitset<N>& x,const std::bitset<N>& y)
{
for(size_t s=N;s--;){
if(x[s]){
if(!y[s])return 1;
}
else{
if(y[s])return -1;
}
}
return 0;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, that looks good.
In the mean time, I found the Boost C++ library on http://www.boost.org/ which implements a dynamic_bitset class which supports the lessThan comparison.
They use a method that is close to your sample except that they work on a higher lever (unsigned longs?), not bits which is certainly faster (about 32 times faster ).
I'm not keen about using the whole lib just for this class, so I will try to dig in the STL source code in order to implement something similar.
Thanks for the idea.
|
|
|
|
|
Ok. In the Visual C++ version of STL, there is a undocumented public direct access on the "unsigned longs" that compose the actual bitfield of bitset.
That is the _W(_I) function which we can use to compare two bitset. Here is the struct that compares two bitset. Not fully tested yet but that gives an idea.
template<size_t _n=""> struct LessThanBitset
{
bool operator()(const std::bitset<_N>& bs1, const std::bitset<_N>& bs2) const
{
typedef unsigned long _Ty;
enum
{
_Nb = CHAR_BIT * sizeof (_Ty),
_Nw = _N == 0 ? 0 : (_N - 1) / _Nb
};
// Since we are storing the most significant bit
// at pos == size() - 1, we need to do the memcmp in reverse.
// Compare a block at a time
for (int _I = _Nw; 0<_I ; --_I)
if (bs1._W(_I) < bs2._W(_I)) return true;
else if (bs1._W(_I) > bs2._W(_I)) return false;
return (bs1._W(0) < bs2._W(0));
}
};
|
|
|
|
|
Using the library in this case isn't too painful - most of Boost is like some bits of the STL - you pull in the header file and thats all - for this class, there'll be no object to link in, no DLL to use or anything....go on, do it, you know you want to
In fact, looking at the Boost build files, only these libraries seem to have external code to be built and linked in:
Boost.DateTime
Boost.Regex
Boost.Signals
Boost.Graph
Boost.Python
Boost.Thread
Boost.Filesystem
Stuart Dootson
'Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p'
|
|
|
|
|
hi all,
I am stuck and i need help..I constructed a browser helper object using ATL..and now i want to display a dialog with HTML contents in it when IE fires an event..i cannot find any suitable tutorial or anything that does that..can anyone suggest me anything i can do to accomplish this..any help and pointers are highly appreciated..thanks in advance..
tina
|
|
|
|
|
I have to continue an ATL COM project, wrote by a lazy fellow until now. The problem is that everything compiles ok but when i want to make a change in the IDL - add a method to an interface for example - it still compiles fine, the TLB file is also fine and the DLL looks like nothing happened
It seems that the changes affect anything in the project but the DLL. Have you seen this problem before?
rechi
|
|
|
|
|
First of all, if you change an IDL file, it's going to update these files :
- the .TLB file itself
- in case options are on, the *_h.h, *_i.c files are updated too.
There's nothing wrong with the fact that the DLL is not changed, as long as the .TLB file is not explicitely added to the .rc resource file.
After all, by default, a type-library lives as a separate file.
|
|
|
|
|
Indeed, the cretin had change the TLB file's directory and the DLL remained linked to the old one.
Thank you for the reply
rechi
|
|
|
|
|
Hi,
I'm a novice in STL so my question is very easy.
I have the follows:
typedef multimap<uint, string=""> CLangMsg; // I need to have equal keys
next, I filled the multimap with data (key+value).
I searched in this map and want to get all values with the same keys.
How to do this?
Yours sincerely,
Alex Bash
|
|
|
|
|
Use equal_range to obtain iterators pointing to the range of elements you're interested in.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have defined an enum in IDL and use the import statement in my C++ client. The problem is that when I don't have any COM methods that use the enum directly the enum does not go into the tlh file. I want to pass the enum as a long so I can or several enums together. I guess I can use a type cast but I just wanted to know from the experts how this is done since I have almost no documentation on the subject.
John
|
|
|
|
|
Here's an enum that I did for an EXE server, maybe it'll give you a nudge in the right direction.
library CPWebSvcReaderLib
{
importlib("stdole32.tlb");
importlib("stdole2.tlb");
[v1_enum] enum CPHrCodes
{
CPWEBSVC_S_INITIALIZING = 0x00040200,
CPWEBSVC_S_UPDATEINPROGRESS,
CPWEBSVC_S_OFFLINE_NODATA,
CPWEBSVC_S_OFFLINE_CACHEDDATA,
CPWEBSVC_E_NOTLOADED = 0x80040200
};
...
};
--Mike--
Latest blog entry: *drool* (Alyson) [May 10]
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
Thanks Mike. I solved the problem by making a dummy method (returns E_NOTIMPL) that took my enum as a parameter then the enum ended up in the .tlh file and all was well...
John
|
|
|
|
|
Just put the enum inside the library block!
--
Run around in the radiation
Run around in the acid rain,
On a black, black planet
|
|
|
|
|
Thanks. I guess I should have better documentation but it is hard to find this kind of stuff in ATL manuals they seem all to spend 300 pages talking about threading models and very little on stuff like this...
John
|
|
|
|
|
It was kind of funny though. Michael had the solution for you in his post all along.. notice how his enum is in the library clause?
You need a book on IDL it seems. I'm gonna buy one or two soon, because I believe I only know the tip of the ice berg. Besides, I think it's good bedtime reading.
--
Run around in the radiation
Run around in the acid rain,
On a black, black planet
|
|
|
|
|
Jörgen Sigvardsson wrote:
notice how his enum is in the library clause?
I did not know that made a difference. I am very much a newbie when it comes to ATL or com.
Jörgen Sigvardsson wrote:
You need a book on IDL it seems.
I guess I do. I don't directly edit IDL files for the most part unless I want to change or add a parameter on a method.
John
|
|
|
|
|
Can I fire events in ATL so as to be consumed in internet explorer?
I want to send notifications to the IE, whenever a condition becomes true.
Is it possible to use ATL events for the purpose such that whenever the condition becomes true an event is fired by the DLL/Control, which can be captured in the IE
|
|
|
|