|
if you can use Boost, there's a threadpool[^] extension which might help, too.
|
|
|
|
|
Simply. You can consider to pass a pointer to an object instead of Window1. The object that wraps window handle value, should be managable by your main thread.
class AClassName
{
public:
HWND hWindow;
};
AClassName* pACN new AClassName;
pACN->hWindow = Window1;
theApp.m_pThreads [0] = AfxBeginThread(Thread, pACN);
Then you can refer to pACN->hWindow in your thread function appropriately.
You may have to employ some synchronization technics, too.
|
|
|
|
|
You can use PostThreadMessage to pass in the window handle to the thread to switch from one window to another.
And never pass the window object from one thread to another. Always pass the window handle and attach it to a new window object using CWnd::FromHandle inside the thread. A window handle and its object is managed by MFC using a map which is valid only for the current thread.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
It seems that will be my best choice for now. I can't find any articles or demo's on a thread pool using vc++. All I have seen so far are in C#.
|
|
|
|
|
Hi all,
Is it ok if we write thousands of key-value entries into registry? How it will effect the performance of the system? Please suggest me..
(i know, this question is not related to this forum, but, i dont know where can i get exact information about this. i googled before posting the message to this forum, but, could not get proper information )
|
|
|
|
|
ramana.g wrote: Is it ok if we write thousands of key-value entries into registry? How it will effect the performance of the system? Please suggest me..
Probably not a good idea. Why not put them in a file, maybe (something like) a SQLite database or an XML file?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Registry size is limited (to 25% of the paged pool). this can be changed by the user, though it's not obvious to most people how to do it. so, it's probably much better if you just write your data to a file.
|
|
|
|
|
I think it depends on how often does an ordinary user access registry.
When it is used only during the application initialization it is relatively fast. Of course it has hardware constrains, but again, to the average user (word processing, e-mail etc.) with GB’s of RAM it should make little difference. My “ancient “ PC with circa 380 MB of RAM and 1 GHz processor struggles when I do key searches.
I know this is not what you are asking. I guess to get a real answer you need to write a test program to really find out how registry interact with running application.
Good luck.
Cheers Vaclav
|
|
|
|
|
I have a program that write to other process's memory, but some part of that memory is NOT writeable. Can anyone tell me how to write to that part of memory, without changing the actual physical file?
Thanks and regard !
|
|
|
|
|
How exactly are you writing to the other process' memory, and why? How are you accessing the memory? how are you getting its address?
If you need to write to some memory area, e.g. a buffer, then it shouldn't be protected, so you shouldn't have problems.
If you're trying to write to protected memory, well, in general, you can't.
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
Actually, this is what i'm doing:
First, I use CreateProcess(...) to execute an application.
Then WriteProcessMemory(...) to write to that process's memory.
But in fact, some part of that process's memory space is NOT writeable. So what I want is a mechanism to write to protected memory.
|
|
|
|
|
What are you trying to do in fact ? Ok, please don't answer something like "I want to write the memory of a process"... I would like to know the higher level reason why you are trying to do something like that (specially when you want to write somewhere you don't have access to).
|
|
|
|
|
It's not a project in fact
I just wonder why a debugger can access and change any memory location of any (may be not some critical ) process that it's debugging.
Then I study and find out the way to access other process's mem, but hooked up with some location that CAN'T be write (with my mechanism of course ).
But a debugger still can write to that location. So there must be a solution or an other mechanism to do that?
|
|
|
|
|
A debugger is effectively the same process as the program it's debugging (OK, this is a very big generalisation) so it can access the memory without any problems. However, in a debugger, e.g. Visual Studio, you'll find that you still get errors if you try to access protected memory, like memory in a completely different process.
Debuggers aren't doing anything special, it's just the way they interact with the program being debugged that makes it look like they are.
edit : Actually, I think a lot of these kinds of questions come down to low-level stuff like assembler and computer architecture not being taught any more. Knowing what goes on under the hood can help you understand things a lot better, and often help you write better code. I've even had someone (a graduate, believe it or not) ask me "When you call a function, how does it know where to return back to?".
There are three kinds of people in the world - those who can count and those who can't...
|
|
|
|
|
You might be able to with some kernel level driver? However, if some part of the virtual memory space has been marked as read-only, that's controlled by the memory management unit of the processor, so good luck with changing that....
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
We usually dont need to access such privileged area if we do not intend to create some virus or malware thing.
But some hint in the suitable situations; Generally, higher privileged process (like memory manager of os) can change the permission of the memory attributes.
And another solution can be done like an os loader. Some debugger dose it so, I think.
Good luck hacker.
|
|
|
|
|
Hi
There are some setting in the project property like:
$(IntDir)\
$(TargetPath)
$(OutDir)\$(ProjectName).exe
Where are they defined? How can I change and add some more?
Best regards,
|
|
|
|
|
transoft wrote: Where are they defined?
See here.
transoft wrote: How can I change and add some more?
For VS6, open Project Settings (Alt+F7). Click the Custom Build tab. Click the Directory and Files buttons.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
$(IntDir) and $(OutDir) are defined in the General section of your project's properties by the 'Intermediate Directory' and 'Output Directory' properties respectively.
$(TargetPath) is the 'Output File' property in the Linker->General section of the project properties.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
How can I use string constant as parameter to function requiring wchar_t* ?
#define MYSTR "abc"
wstring x(MYSTR);
thank you
|
|
|
|
|
This MAKELONG macro definition will work for you.
#include <string>
#define MYSTR "abc"
#define MAKELONG2(S) L##S
#define MAKELONG(S) MAKELONG2(S)
std::wstring a(MAKELONG(MYSTR));
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
great, thank you
I was trying just 1st macro before and I was getting the macro's name in my string
|
|
|
|
|
Yup - been there, done that
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
use
#define MYSTR _T("abc")
and then accordingly define (or not) the UNICODE symbol.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi All,
i am using xmlhttp request method to get some xml data from server but i am not even able to create instance of xmlhttp object.
hr=pIXMLHTTPRequest.CreateInstance("Msxml4.XMLHTTP.4.0");
above hr is returning false. Please give some solution.
Thanks A Ton
Ash_VCPP
walking over water is just knowing where the stones are.....
|
|
|
|