|
Hai all,
Im planning to do a project which can remotely access a pc. For that i want to find, whether there is any change in the clients display.
But when i hook WM_PAINT, a lot of paint messages are comming even if the machine is idle.
Can anyone tell me an idea to solve this ? thanx in advance.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Have you tried the WM_DISPLAYCHANGE message?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Dear Greeeg,
Thanx a lot for your valuable reply. But one doubt. When i tried to spy the WM_DISPLAYCHANGE message using Spy++, i can't find any WM_DISPLAYCHANGE message generating, when i open/move/close windows. Please clear this doubt.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Unless you are doing this as programming excersize, I could recommend forgetting it. Either use existing tool(RAdmin, NetMeeting, PCAnywhere) for your own needs, or find another tool to create for selling.
Catching image is just a beginning, and if you have problems with it, probably you are not good enough to do it. No offences, I'm also not qualified enough. But you will have to find a way for real-time image differencing and packing. Or did you think you could get enough perfomance by sending full screen/window image over a network? Think again. And finally you will stuck at what a friend of mine did, he made all this path, only to find out that to get true speed he have to develop special screen driver (as far as I understood), which market leaders already have. Otherwise you have speed limit that you will reach by making a screenshot - just consider copying, comparison and packing of 1024x768x16bit = 1.5 Mg image and do it 10-20 times per second.
PS. WM_DISPLAYCHANGE comes when screen resolution changes.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
Dear Igor,
Thanks for ur valuable reply. Im just doing this project for improving my knowledge. And now i understood that the full screencapture method was utter foolishness.
And will you please explane that screen driver method, more clearly ? is that hooking the display driver ? or something like that ? Can you please provide me some helpful links about that ?
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
No, sorry, I don't know the details myself. But for your own needs screen capturing is good enough. As far as I could understood, that 'driver' just provide you direct access to screen picture, which let you skip one step from process - preparing and copying picture to intenal bitmap. Still you have to do all differencing and packing yourself.
Igor Green
http://www.grigsoft.com/ - files and folders comparison tools
|
|
|
|
|
okay Igor... Thanx a lot.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
<br />
typedef struct{<br />
char buff[20];<br />
} my_struct;<br />
<br />
my_struct my_arr[1000][30][10][10][3];<br />
<br />
int main(){ <br />
for ( int a = 0; a < 1000; ++a ) <br />
for ( int b = 0; b < 30; ++b ) <br />
for ( int c = 0; c < 10; ++c ) <br />
for ( int d = 0; d < 10; ++d ) <br />
for ( int e = 0; e < 3; ++e ) <br />
{ <br />
my_arr[a][b][c][d][e].buff[0]='0';<br />
my_arr[a][b][c][d][e].buff[19]='9';<br />
}<br />
return 0;<br />
}<br />
In previous thread, I have asked about the problem when using large data. Thanks so much for all of your replying.
I based on yours comment to check my code again and I found that I had a mistake. Yes, the program run normally.
Here I had changed code to another type:
<br />
typedef struct{<br />
CByteArray buff;<br />
} my_struct;<br />
<br />
typedef struct{<br />
my_struct dat[30][10][10][3];<br />
} data;<br />
<br />
CArray<data, data&> my_arr;<br />
In CWinApp::InitInstance():
<br />
int n=1000<br />
my_arr.SetSize(n);<br />
for ( int a = 0; a < n; ++a ) <br />
for ( int b = 0; b < 30; ++b ) <br />
for ( int c = 0; c < 10; ++c ) <br />
for ( int d = 0; d < 10; ++d ) <br />
for ( int e = 0; e < 3; ++e ) <br />
{ <br />
my_arr[a].dat[b][c][d][e].buff.SetSize(1);<br />
}<br />
}<br />
I tested n from 100 to 1000 and CArray seem to be not effective. When n>=500, the program run more slowly. And when n=1000, the system alerted that out of virtual memory.
Please note that the buff size is only 1 (beside 20 in previous version)
In my project, buff size is varying.
n is about 300-800
All remaining size of array are const
Here are my questions:
In this case, which is my best solution (Using CArray or not)?
If anyone has experience in using CArray and processing large data, please give me a hint.
Thank you very much.
|
|
|
|
|
nguyenvhn wrote:
typedef struct{
CByteArray buff;
} my_struct;
typedef struct{
my_struct dat[30][10][10][3];
} data;
CArray<data, data&> my_arr;
From a cursory glance at MFC code, and unless I made a severe mistake:
You are aware that every element in my_arr is of type data , which is holding nine thousand CByteArray's? CByteArray's which each are of size 20 bytes and requires construction, including construction of parent class object CObject? So just one single instance of data at minimum requires 180.000 bytes.
For 'n' in your code you are:
1. Creating m = n * 9000 CByteArray's, for a total of at least m * 20 bytes.
2. Iterating over those m ByteArrays, calling SetSize for them, which allocates at least 16 (or is it 32, I really don't remember the allocation granularity of the SBH) bytes each, for a size of m*16 or m*32 bytes.
This becomes m*(20+16) or m*(20+32) bytes, minimum.
If n=1, you allocate at least 324.000 bytes.
If n=1000, you allocate at least 324.000.000 bytes.
Should SBH allocation granularity be 32, then you would get a memory load of about 446MB just to hold those nine million bytes. Should you use the debug heap, I think you can safely add another m*16 or m*32 bytes (for a memory load between 446 and 720MB respectively).
Just to create the nine million *holders* of the data, not the data itself, for the n=1000 case, you use 180 million bytes.
In my project, buff size is varying.
I suggest you at minimum should stop using MFC for collections (CByteArray even have a vfptr!), and start using a custom allocator.
In this case, which is my best solution (Using CArray or not)?
Not.
To be completely honest I'd say using any MFC collection class is almost always the wrong thing, but that's a completely different discussion.
|
|
|
|
|
Thank you very much.
I have no knowledge about custom allocator. Could you tell me more about it?
In addition, Could you give me an article to make more clearly that "using any MFC collection class is almost always the wrong thing"? And so that, what is the true replacement? Please, I am using Visual C++ and MFC as the main programming framework.
I hope to get lot of useful information from you.
Thanks again.
|
|
|
|
|
nguyenvhn wrote:
Could you give me an article to make more clearly that "using any MFC collection class is almost always the wrong thing"?
Once you gain more experience in C++, It'll come to you.
But to give a starting place, you might want to Google some news.
And so that, what is the true replacement?
There is no silver bullet.
|
|
|
|
|
I don't remember anything about the MFC collection classes, and I plan for it to remain that way.
Can you tell us something about your application?
Paul
|
|
|
|
|
Thanks for your replying.
In before, my application has done well. But now the size of data is increase very high. My application must deal with its but I dont want to write new application from scratch. I want to update from old source code.
In old version, I used the following declare:
my_struct my_arr[C][W][D][P][S] with my_struct's size is 20 bytes as mention in previous thread.
C, W, D, P, S are const and C=120.
Now C can be 1000. I think my data structure may be too large.
Could you give me any idea or example to solver this kind of problem?
Thank you.
|
|
|
|
|
If your 'my_struct' can remain 20 bytes then the following works for variable 'C', I don't recommend any type of container since the overhead of managing it and implementing 'operator[]' is probably going to be significant.
The total allocation is 180MB, this is much less than commonly fitted as main RAM to modern PCs so the quantitiy per se isn't too much. You do need to consider how you access it in order to work with the CPU data caches rather than against them, but without knowing what you do to the data I can't help there.
struct my_struct
{
char buff [ 20 ] ;
} ;
typedef my_struct my_struct_array [ 30 ][ 10 ][ 10 ][ 3 ] ;
const unsigned my_arr_size = 1000 ;
int main()
{
my_struct_array * my_arr = new my_struct_array [ my_arr_size ] ;
for ( unsigned a = 0; a < my_arr_size; ++a )
for ( unsigned b = 0; b < 30; ++b )
for ( unsigned c = 0; c < 10; ++c )
for ( unsigned d = 0; d < 10; ++d )
for ( unsigned e = 0; e < 3; ++e )
{
my_arr [ a ][ b ][ c ][ d ][ e ].buff [ 0 ] = '0' ;
my_arr [ a ][ b ][ c ][ d ][ e ].buff [ 19 ] = '9' ;
}
delete [] my_arr ;
return 0;
}
Paul
|
|
|
|
|
So good. I found an idea to solver my problem based on your code.
Thank you very much.
I will post more thread in this forum. If you see, help me.
|
|
|
|
|
hay all
can any one tell me What is hash table how can i use it in a clint server aplication
|
|
|
|
|
I suggest :-
1) learn how to spell/type
2) following this link http://www.brpreiss.com/books/opus4/html/page203.html[^]to learn about hash tables in general
3) doing some google searches to get the basic questions out of the way.
The answer to Princess Anastasia wrote:
how can i use it in a clint server aplication is 'boundless' - since you provide no useful information that would allow someone here to help you.
There are also client-server examples here on CP, try looking for them and see if they meet the criteria you're looking for.
4) most people won't respond to your question because it sounds like a 'homework'/'assignment' question - if you do have such, and want an answer, then try posting some code that proves you've at least attempted something for yourself.
Sorry to be harsh
Garth
|
|
|
|
|
Good Reply. 5!
God is Real, unless declared Integer.
|
|
|
|
|
A Hash Table is a data structure where you input elements by a key value. Even though the other response you got was horribly rude and unwarranted, he was right that you should probably look it up to determine how you might want to write this table. They can be as simple as an array, and as complex as multi-dimensional arrays with lists, or whatever. If you plan on putting a lot of elements into your table, you should probably read up on MSDN about efficiency in design. If you use dynamic memory in your hash table (which you probably will), then you will most likely be causing the operating system to page fault as it passes between links. If this is the case, then while a hash table is supposed to be fast, it will actually be no better than a linked list.
After you get a hash structure, you can use it to store socket connections. You've probably got a lot of reading to do to be ready to design this application.
And ignore it when you get somebody responding like you've done something wrong by asking a question. Some people forget that these forums are set up for asking questions and getting advice.
|
|
|
|
|
I'm sorry if you think my reply was rude and unwarranted - I'm not an a**ehole, despite appearances, and, I definately havnt forgotten that these forums are set up for asking questions and getting advice (else how myself would I have learnt anything, except by the generosity of the people here)
rude - no, I was more polite than a lot of people can be - you should see the typical reply to some such questions - at least I gave a pointer to some info on hash tables - good work from you to point out how they may be used in a client-server situation.
unwarranted - depends on how many times you've done someones homework for them I guess - Im quite prepared to help people, when someone has tried to do some pre-reading, and info on hash tables per se is available all over the net ..
I'd prefer to try to teach a person how to fish, rather than spoon feed them.
I'll accept your criticism - maybe next time my response will be different.
may your god go with you.
Garth
|
|
|
|
|
Garth J Lancaster wrote:
...info on hash tables per se is available all over the net ..
Keep in mind that not everyone is as net-savvy as yourself. They may have simply stumbled upon the CP site, or linked to it from the school's site. In any case, you can't assume that everyone knows about Google, Jeeves, Yahoo, MSDN and other search engines. Adhere to the "Teach a man to dish..." proverb and leave the criticism at home.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
hi,all:
i create a service,and my service must depend on two other service.
in function CreateService():
SC_HANDLE CreateService(
SC_HANDLE hSCManager,
LPCTSTR lpServiceName,
LPCTSTR lpDisplayName, // pointer to display name
DWORD dwDesiredAccess, // type of access to service
DWORD dwServiceType, // type of service
DWORD dwStartType, // when to start service
DWORD dwErrorControl,
LPCTSTR lpBinaryPathName,
LPCTSTR lpLoadOrderGroup,
LPDWORD lpdwTagId,
LPCTSTR lpDependencies, // pointer to array of dependency names
LPCTSTR lpServiceStartName, // pointer to account name of service
LPCTSTR lpPassword );
the Parameters of lpDependencies means:
lpDependencies
Pointer to a double null-terminated array of null-separated names of services or load ordering groups that the system must start before this service. Specify NULL or an empty string if the service has no dependencies. Dependency on a group means that this service can run if at least one member of the group is running after an attempt to start all members of the group.
You must prefix group names with SC_GROUP_IDENTIFIER so that they can be distinguished from a service name, because services and service groups share the same name space.
but i don't know how to do?who can give me a example.
appreciate any help!!!
|
|
|
|
|
I have a problem,
I am trying to write a function that reads a file, maipulates the data inside and then call it to the main() for an output.
okay the question looks something like:
1. There is a file say "filee.dat" it has 5 columns of numbers 1st column from 0 to 300. the rest correspond to it. 1st column is time,, the next is distance, the thrid is speed etc.
The thing is i need to write a function that calls this file and finds the time at which the distance starts decreasing (i.e the car is going forward but then after one high point, starts going back (so the distance decreases)).
SO from the main the output should be the time that corresponds to the the point where the distances starts to decrease.
Thansk!!
|
|
|
|
|
the file must have some structure.
a) the columns has a fixed size
b) the date is delimited with a special char maybe a ;
so yu have to read your file in a way, you can access the different values.... depending on the layout of your file.
|
|
|
|
|
so what would the code look like? there are columns for t,z,v,a and at places there are no values the but it goes from 0 to 300 with an interval of 0.5
the code is the thoing i am not clear of as in how to read it and how to acces the desired values.
|
|
|
|
|