|
Steen Krogsgaard wrote:
I just don't see the sense of putting the template definition/implementation in a dll library if it is never being instantiated in the library.
I do this because I package all my dlls with their own installer and it makes it easier to use and keep only one version of the templates if they are packaged with related classes. In general the classes of the dll may use the templates internally but for the most part they don't use them externally.
Steen Krogsgaard wrote:
The internal compiler error (C1001) is confirmed by MS and documented in Q179271.
I'll take a look at that. I find it hard to believe that I don't have more than one explicit instantiation somewhere in my dll interface code but its possible.
John
|
|
|
|
|
John M. Drescher wrote:
I'll take a look at that. I find it hard to believe that I don't have more than one explicit instantiation somewhere in my dll interface code but its possible.
It's only a problem in VC++ 5.0 and 6.0, the problem was corrected in VC++.NET (mentioned in Q179271 available online. The one I quoted was from my October 2001 MSDN CDs).
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
I have a multiple object solution. How do I call from project2 a method in
project1? I thought it is project1.method1();. Also, do I need to add
header and other stuff to project1 so that it knows how to find method1?
If there is some sample code available on line, that would be easiest.
The projects are a mixture of C#, C++, and C. I am most interested in the
C or C++ angle.
I would have search for the solution, but I have no idea what keyword to begin with. Thanks.
glam
|
|
|
|
|
I meant multiple project solution.
glam
|
|
|
|
|
> How do I call from project2 a method in project1?
In C/C++ CreateRemoteThread should do it.
> Also, do I need to add header and other stuff
> to project1 so that it knows how to find method1?
Simply pass the address of ThreadFunc from project1 to project2 via some kind of IPC (Interprocess Communication).
RK
|
|
|
|
|
I have created a DDB bitmap of size (1024x2048) and have selected it into a
compatible DC. Here is the code:
hdc = GetDC (hwnd);
hBitmap = CreateCompatibleBitmap (hdc, 1024, 2048);
hdcMem = CreateCompatibleDC (hdc);
SelectObject( hdcMem, hBitmap);
ReleaseDC (hwnd,hdc);
My problem is when I draw on the hdcMem and then bitblt it to my Window DC.
Everything works fine until I try a bitblt with an X coordinate (hdcMem)
greater than 800. My current screen Resolution is 800x600. Why is this?
How can I fix it? This is not a problem for the Y axis. I suspect that the
hdcMem has some sort of limitations based on the current resolution, but I
can't figure it out.
What happens is that the bitmap seems to be cut in half. The bitmap displays fine up to the 800 point, but after that, it doesn't show at all.
|
|
|
|
|
try on using stretchblt()
Hello World!
|
|
|
|
|
Say I know the address of a function (does this help), I want it to call my copy of the function, and then the original function.
I want to do it without making a wrapper, and without hooking GetProcAddress because I can already do it that way, but i'd like a much more direct way possibly involving inline asm etc.
Any help + ideas is appreciated.
|
|
|
|
|
> I want to do it without making a wrapper, and without hooking GetProcAddress ...
You have to modify the entry point of the original function so that it first executes a JMP instruction to your implementation.
Check this link:
http://www.fengyuan.com/article/wmprint.html[^]
There you will find a nice user32!BeginPaint hook implementation. However, because most user32 and kernel32 functions call an appropriate function in ntdll.dll, rather than executing the 0x2E interrupt directly (like BeginPaint does), your implementation will probably differ somewhat too; it will always depend on how the entry point of the original function looks like.
More useful links:
1. Intel OpCodes[^]
2. Api Hooking Revealed[^]
3. API Spying Techniques for Windows 9x, NT and 2000 [^]
Regards,
RK
|
|
|
|
|
Hi!
How can i handle the click over a system tray baloon tip?
Thanks for your answer!
|
|
|
|
|
Hi,
check out this article. Beyond your question it provides a handy class to use message balloons in the system tray.
Peter Molnar
|
|
|
|
|
|
|
I am trying to create my first a multi-threaded dev-studio library project.
Is there a way to register a thread "cleanup" function that gets called each time a thread exits?
Here are some constraints for any suggestions you provide me:
1) I think I want my library statically linked. I see that for DLLs, DllMain() gets called each time a thread "detaches". This might be an appropriate place for me to stick my clean-up code if I were writing a DLL, but I don't think I want a DLL.
2) I don't want users of my library to have to write any code to get the cleanup function called. It should all be completely hidden.
3) I really only need my cleanup function executed for exiting threads that previously used particular functions from my library. So I do have a place to register the thread-exit function if there is a way to do that at all.
Thanks much for your help.
Matt Busche
|
|
|
|
|
> Is there a way to register a thread "cleanup" function
> that gets called each time a thread exits?
Hm..the first solution that comes to my mind: Call GetExitCodeThread periodically.
DWORD dwExitCode;
GetExitCodeThread( hThread, &dwExitCode);
if( dwExitCode == STILL_ACTIVE )
else
Anyway, why don't you simply call the cleanup routine at the end of ThreadFunc (just before calling return )?
DWORD WINAPI ThreadFunc( LPVOID lpParameter )
{
MyCleanUpRoutine();
return 0;
} Regards,
RK
|
|
|
|
|
Robert,
I guess I'm not a big fan of polling. As for your second suggestion: I'm trying to write a library that other developers will use. My library won't be spawning threads -- the application written by someone else will. So to pursue your suggestion, I'd have to include in my library notes, "oh, and be sure to call MyCleanUpRoutine() before your thread exits. Don't really care for that either. I guess I'm going to have to figure out how to get a DLL to work for me instead.
Actually, I think a DLL will work for me, but my initial attempts to create a DLL have not gone so well -- having problems getting global data from the DLL to link.
Thanks much for your response.
Matt Busche
|
|
|
|
|
A *.dll would perfectly suit your needs. What you have to do is:
1.Create a *.dll and export all the functions you want your users to call
2.Make sure that the global data (if any) that simultanious threads can access (i.e. if two or more users at a time call the same function) is protected with syncronization objects like Critical sections
3.If your user calls LoadLibrary, your DllMain gets called with DLL_PROCESS_ATTACH, do some initialization, maybe keep reference count of attached clients, when your user calls FreeLibrary your DllMain gets called with reason DLL_PROCESS_DETACH. This is the place to call your CleanUpFunction()
Summary: your user has only to call LoadLibrary on your *.dll, GetProcAddress on the function, and FreeLibrary to get detached from your lib.
Peter Molnar
|
|
|
|
|
Peter,
Thanks for your reply. I actually started to do this and only just now discovered that this only works for RUN-TIME dynamic-linking of a DLL. (I.e., where you use the LoadLibrary call just like you said.) I saw some sample code on how to use LoadLibrary and GetProcAddress to call a single simple function from a DLL, but I'm not exporting a single simple function, I'm exporting a handfull of C++ concrete and abstract classes (along with all their numerous member methods and overloaded operators). It is not clear to me how you'd use run-time linking for such a library. Supppose Peter, you inherited from one of my abstract base-classes, then when you wrote your constructor, how would you call my base class constructor that is exported from my DLL?
And even if it's possible, my whole objective is to make my software as easy as possible to use. I certainly wouldn't want my users to have to jump through any flaming hoops to call a base class constructor or call the "=" operator for a class.
Here's a thought. What if I had two libraries? Library ALPHA has all my user visible software and could be built arbitrarily for either dynamic or static linkage. If built as a DLL it would be expected to be used with load-time dynamic-linkage. DLL BETA has nothing in it but a DllMain. Now, here's the trick: suppose DLL ALPHA secretly does a LoadLibrary call on BETA via some singleton constructor found in ALPHA. This singleton is instantiated the first time a user of ALHPA references resources that require thread initialization and cleanup activities. Then, I would presume that every subsequent thread spawn and delete would cause this DllMain in BETA to be invoked, would it not? I presume also that DllMain in BETA could invoke methods defined in ALPHA (to effect thread initialization and cleanup.)
I'm going to investigate this idea further and maybe try it out.
Let me know if I misunderstood the implications of your email. I've been battling this silly problem for a week now. If I don't come up with a better solution soon, I'll have to simply publish a threadCleanup method that must be called by users of my library on thread exit, but I really don't want to have to do this.
Once again, thanks sincerely for your help.
Matt
|
|
|
|
|
Peter,
OK, forget what I just wrote. If just found some words in the MSDN that would seem to imply that DllMain is used even if you use load time dynamic linking of the library. (Which I guess means that LoadLibrary must be invoked for you if you use load-time dynamic linking?)
Let me know if I'm lost. Let me know if I'm not lost. I'm forging ahead.
Matt
|
|
|
|
|
Hi
I have an application running with 2 forms.
however when i run it i get the following error:
c:\.......\stdafx.obj': <unknown>
Possible cause
If the message says "bad file number", the file may have been closing in the foreground while compiling in the background.
it seams there is a problem with #include "StdAfx.h"
at the begining of my plc.cpp class file. I have plc.h, and plc.cpp !!!
can someone please help me?
|
|
|
|
|
Is this a compile error or run error? Where are you getting the error message from?
John
|
|
|
|
|
it is a faltal error. it seams to be the run error.
|
|
|
|
|
Then a message box pops up with the error? The reason why I ask is I have seen this as a compile error and the fix was to do a clean build by deleting the release and debug folders and recompile however if it is a runtime error I am not sure if this could be the problem.
John
|
|
|
|
|
I'm pretty sure he's getting a compile time error and does not understand what you're asking him.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|