|
you can add the monitor number in each caption of your windows or
you create a transparent window with the size of the entire desktop (spreading over all monitors)
an draw the number with GDI in this window
|
|
|
|
|
Hello there.
I'm doing a program that waits for an application being minimized and send it to system tray.
I started using window hooks to intercept WM_MOVE messages, but I had some problems. First problem is that I can't find any documented function that can say if the window is really minimized, so i used the following workaround:
GetWindowRect(HWND(wps->hwnd),&rRect);
if (rRect.bottom=-32000)
other problem is that i cannot find if the hwnd is the main window of the application or any child window. When I minimize Firefox, for example, i get more than 8 icons on tray, depending on the tabs i have opened at the moment.
I was reading about hooks at Microsoft website and they say that we need an 64-bit dll to inject on a 64-bit executable and a 32-bit dll to inject on a 32-bit executable, so i was wondering if it wasn't a better solution to run through every hwnd on the system and see if it is minimized or not. I know it's not the best practice, but just wondering...
Any help will be kindly appreciated.
Best regards
|
|
|
|
|
marcio k wrote: First problem is that I can't find any documented function that can say if the window is really minimized...
What about IsIconic() ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: What about IsIconic()?
That won’t work, since it answers question: is window already minimized.
marcio:
I am not sure what windows hook you are using but from your description I think it is either WH_GETMESSAGE or WH_CALLWNDPROC.
Consider using computer-based training hook: WH_CBT, monitoring HCBT_MINMAX code. Upon receiving this code examine lParam; it should be SW_MINIMIZE if window is minimizing. It will always be a top level window unless some application is trying to minimize child window. You can always verify if it is a top level window
Mind you, it has to be a global hook in a DLL. If you have never used hooks, there are some caveats you have to be aware.
How do you handle your present hook?
JohnCz
MS C++ MVP
|
|
|
|
|
JohnCz wrote: is window already minimized.
Which is exactly what the OP was asking about. His question was past tense (i.e., has already happened).
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: His question was past tense
Well, you have a right to your own opinion but do you really think that following is a past tense?
marcio k wrote being minimized
JohnCz
MS C++ MVP
|
|
|
|
|
The part I focused on was, "...if the window is really minimized."
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I attempted to do this in a DLL and it worked just fine .
However moving the code inside COM exe does not report any error but does not load the information in the registry .
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );
CString strLocalFileName = CString(_T("regedit.exe /s ")) + strRegFileName;
if( !CreateProcess( NULL,
strLocalFileName.GetBuffer(0),
NULL,
NULL,
TRUE,
NORMAL_PRIORITY_CLASS,
NULL,
NULL,
&si,
&pi )
)
{
int error = GetLastError() ;
CloseHandle(pi.hProcess) ;
return false ;
}
else
{
ATLTRACE("GetLastError = %d\n",GetLastError());
WaitForSingleObject( pi.hProcess, INFINITE );
DWORD dwCode = 0;
GetExitCodeProcess ( pi.hProcess, &dwCode);
CloseHandle(pi.hProcess);
}
Any help is appreciated !
Engineering is the effort !
|
|
|
|
|
Try specifying some value other than 0 for si.wShowWindow . That way you can see if an error is popping up (and quickly disappearing).
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
so basically I am trying to create a process to run
regedit /s C:\Program Files\Common Files\MyApp\1.reg
For debugging purposes I removed the /s for regedit and I see that it
chops the path by space
So it keeps asking if I want to enter the entry
C:\Program Files
Common
Files\MyApp\1.reg
Is there a way this can be prevented ?
These files are present in the current working directory of the exe and pro grammatically obtained via GetModuleFileName
Engineering is the effort !
|
|
|
|
|
thanks for steering me into resolving this .
The key was to enclose the file path in quotes before supplying it to regedit.
But I wonder why and how this would be different in a DLL that I developed .
Engineering is the effort !
|
|
|
|
|
This looks strange:
ZeroMemory( p, sizeof(pi) );
|
|
|
|
|
Does anyone know how to get row after reading the text file. I have a code that read the text file but want get each row. Here is my code. Please help.
========================================================
// NewIdea.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
int main()
{
std::ifstream file("C:\\ProjectRead1.txt");
std::string s, s1,s2;
int row = 0;
int col = 0;
while (std::getline(file, s))
std::cout << "Got a line: " << s <<'\n';
=======================================================
I want to get the row here here and process.
========================================================
if (!file.eof())
std::cout << "Error reading file\n";
//return 0;
system("PAUSE");
}
|
|
|
|
|
msogun wrote: I want to get the row here here and process.
You already did, in s .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Instead of reading each row, as you are doing now, and just sending it to the standard output (display), copy them to memory as well, so you can read them latter. The easest way to do that would be to declare a std::vector<std:string>, and just call push_back(s) to add them to it. Then you can read all the lines you want, from memmory, by simply using indexes: myVec[i].
I hope that points you in the right direction.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
How would I use the vector? Any sample? What you mentioned is exactly what I really want to do. Read each row and process it. Then next row and process it.
|
|
|
|
|
|
You've got two problems here. First, how to initiate a process on the target machine. Second, how to communicate parameters to that process, and to get the results back.
Initiating the process:
- Run a service on the target machine. The application runs continuously.
- Use DCOM (distributed COM), which uses the Windows RPC (Remote Procedure Call) mechanism.
- Use the Task Scheduler to start the application remotely.
All three of these options require that you pre-install software of some kind on the target machine. If you want to load and execute arbitrary code on the target machine, that's more difficult.
Communication mechanisms:
- Files in shared folders. Write a parameter file to a shared folder. The verification application reads it and writes a results file, which your local application then reads. Synchronization with this technique can be awkward.
- DCOM. DCOM includes the ability to pass data between the client and server.
- TCP/IP sockets; define your own messages to pass data back and forth.
Any of the initiation techniques can be used with any of the communication mechanisms. Naturally, if you're using DCOM to initiate the process, the easiest way to pass data back and forth is by using DCOM to pass the data as well.
I've used all of these methods at one time or another. They each have strengths and weaknesses. DCOM is the simplest from your application's point of view (DCOM calls look like ordinary function calls), but it has the worst error handling of all. The service and TCP/IP connection combination is the most robust and offers the best performance, but also takes the most effort to get working.
|
|
|
|
|
|
Since the application is running on the remote machine, it will access that machine's registry.
That said, you can use the RegConnectRegistry() [^] function to access the registry on other computers.
|
|
|
|
|
No, you misunderstand the point!
A Module is stored on a Disk on Machine 'A'. It's Location is visible on Networked Machine 'B' When the Module is started up, it reads startup info from the 'local' registry, i.e the module does not queery if it runs on a network, it just does RegOpenKeyEx, RegQueryValueEx etc.
Someone working on Network Machine 'B' because it can see the App stored on Machine 'A' decides to start the App. The question is: Which registry will be queeried for the values for the Module. The registry at Machine 'A' where the module is Stored, or the Registry at Machine 'B' where the module executes.
Regards
Bram van Kampen
|
|
|
|
|
Regardless of where the application's EXE file is stored, it accesses the registry on the machine where it executes.
The person working on machine 'B' runs the application located on a disk on machine A will see values in machine 'B's registry, since that's where the program will run.
|
|
|
|
|
Gary R. Wheeler wrote: Since the application is running on the remote machine, it will access that machine's registry.
Thanks,
For some reason, the above was not shown on my screen when I replied, so your answer made not much sense that it seemed to suggest to use RegConnectRegistry.
Hence my reply at that time.
While on the subject, I have an App that has to run absolutely the same way, independent of whichever user is logged on. Individual User settings for this App are Out of bounds, or, if a setting is applied it must also apply to all and every other user. I was inclined to store the settings under HKEY_LOCALMACHINE\Software\MyApp\...
I read all sorts of reports that under Vista these registry locations can no longer be written to, and are for now diverted to a User Registry key. The type of software I write is meant to take control of the machine, as it is EPOS Software. My software would not expect any external users on the hardware, and, ideed would like to be in a position not to tolerate it!. How do I work this under Vista, if Core Registry Keys cannot be used anymore
Thanks
Bram van Kampen
|
|
|
|
|
Under Windows XP, I would use SHGetFolderPath() to get the path to the common applications directory, and store my settings in a file. This location would be common to all users on that machine. Under Vista, that function has been superceded by SHGetKnownFolderPath() [^].
This doesn't quite address the problem you are having. If I understand correctly, your application is stored on a server machine, but may execute on client machines. You need to access settings from a common location. My suggestion would be to store your settings in a file in a known location on the server machine, and then use a UNC path to access the file. That way, if the application is executing on a client machine, it will still load the settings file on the server. Note that, if your application updates the settings file, you will need to take care to synchronize access to the file if more than one client can be executing the application at a time.
|
|
|
|
|
Thanks, Yes, that's the first part. Now the Second Part:- The 'Known' location is difficult, because that may be different on different Users Networks. That's why at Installation time, I want to write that info to the Registry. Under windows 98->->->XP I use 'HKLM\Software\MyCompany\IniFilePath=C:\...etc. I have also been informed that under Vista this RegKey would be diverted towards some User Key, (and that only for a shortwile). That surely defeats my purpose. because the location of the Ini File, and the info contained therein does not change depending on who is signed on as user.
So, the question becomes, what Reg Key to use in Vista in this case in stead of HKLM\Software
Thanks
Bram van Kampen
|
|
|
|
|