|
Rajesh R Subramanian wrote: The console app must be notified of the progress of this lengthy operation periodically.
Mailslots, sockets and named pipes.... all for a simple integer percentage value? SendMessage returns a value in its LRESULT which can be used in the console application to retrieve small values such as percentage complete.
Something like this:
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <conio.h>
#include <windows.h>
#include <Psapi.h>
#pragma comment(lib, "psapi")
#define WM_PERCENTAGE WM_USER + 1033
BOOL CALLBACK GetPercentageProc(HWND hWnd, LPARAM lParam)
{
int nLen = GetWindowTextLength(hWnd);
TCHAR szTitle[MAX_PATH];
GetWindowText(hWnd, szTitle, MAX_PATH);
if(_tcsstr(szTitle,_T("YourApplicationTitle")))
{
DWORD dwPID;
TCHAR szModule[MAX_PATH];
HMODULE hModule;
DWORD dwNeeded;
GetWindowThreadProcessId(hWnd,&dwPID);
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,FALSE,dwPID);
if(EnumProcessModules(hProcess,&hModule,sizeof(hModule),&dwNeeded))
{
GetModuleFileNameEx(hProcess,hModule,szModule,sizeof(szModule));
}
else
{
GetProcessImageFileName(hProcess,szModule,sizeof(szModule));
}
TCHAR * p = _tcsrchr(szModule,_T('\\'));
if(0 == _tcscmp(++p,_T("YourExecutable.exe")))
{
LRESULT dwPercent = SendMessage(hWnd,WM_PERCENTAGE,0,0);
DWORD dwP = dwPercent;
}
}
return TRUE;
}
int main()
{
EnumWindows(GetPercentageProc, NULL);
_getch();
return 0;
}
Note that its recommended to use RegisterWindowMessage [^] for IPC although I did not use it in my example.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi David,
Isn't SendMessage going to be blocking? I was looking for something that would be asynchronous. (OK, I can use a thread, but I am just asking). I'll try this as well.
Thank you for your suggestions.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
1) There is some LIB project, with function doing some math, estimating ticks of the function and saving them to file.
2) There is DLL that exports just single function calling the one from LIB
3) There is console application compiled with 2) to invoke the function
4) There is console application compiled with 1) to invoke the function
5) There is some GUI application compiled with 2) to invoke the function
I encounter differences in timings outputed by 5) during the day. It changes from say 2100ms to 1000ms. This morning it run at 1500ms, but this afternoon it runs at 1780ms.
As at the same time 2) runs with exactly the same DLL at 1100ms.
But 4) always runs faster than the rest at say 900ms.
Has anyone encountered such abnormalities. Are they affected at some extent by host project taking the DLL?
Чесноков
|
|
|
|
|
There is an undocumented effect of Earth Nutation's on the Microsoft DLL calls binding time. Such phenomenon was first theorized by the eminent astrologer Pallinus.
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]
|
|
|
|
|
I heard that if you are using satellite DLLs, the Sun's harsh rays can slow them down.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Yeah, Sun rays are very selective in targeting Microsoft DLLs.
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]
|
|
|
|
|
Chesnokov Yuriy wrote: Has anyone encountered such abnormalities.
No, but this is actually possible. Multimedia timer functions such as timeBeginPeriod[^] will effect the entire operating system. There are *many* applications in the wild which call this function and the authors probably thought it would only have an effect on their application. It effects calls to both timeGetTime and QueryPerformanceCounter because the kernel scheduler itself has been modified.
Call timeBeginPeriod(1) at the beginning of your math function and timeEndPeriod when you are finished.
Best Wishes,
-David Delaune
|
|
|
|
|
I made one simple client server program.
Server Socket created without any error but client program returns WSAECONNREFUSED error.
For one confirmation i create another one server socket with same port at that time it's not gives any error.
I get confused because it creates two sockets for same port without any error. But this also client gives same error
please help me to get out from this issue.
Server:
m_pserversock = new CServerSocket(this);
bsucessflag= m_pserversock->Create(m_portno,SOCK_STREAM,NULL);
status=m_pserversock->GetLastError();
if(bsucessflag)
{
bsucessflag= m_pserversock->Listen(5);
if(bsucessflag)
{
m_display.SetWindowText("Server Listening\r\n");
}
else
{
m_display.SetWindowText("Unable to Listen\r\n");
OnDisconnect();
}
int a=m_pserversock->m_hSocket;
}
else AfxMessageBox("Unable to Create");
CSocket *temp;
temp = new CSocket;
bsucessflag=temp->Create(m_portno+1,SOCK_STREAM,NULL);
if(!bsucessflag)
AfxMessageBox("Error");
CServerSocket,CClientsock is from CSocket.
Client:
m_pClientsock = new CClientsock(this);
if(m_pClientsock->Create())
{
if(m_pClientsock->Connect(dlg.m_Servername,dlg.m_Portno))
{
AfxMessageBox("Connected to Server");
Init();
m_bIsConnect = TRUE;
m_Username = dlg.m_Username;
}
else
{
int istatus=m_pClientsock->GetLastError();
AfxMessageBox("Not able to Connect Server");
delete m_pClientsock;
m_pClientsock = NULL;
}
}
else
AfxMessageBox("Not able to Create");
|
|
|
|
|
hi,
im newbie to MFC can u suggest me any Good book(in which all MFC Classes are explained in detail..So that i will be able to know how to use the classes depends on the requirement...) to start with...im using vs2003
|
|
|
|
|
|
Thanks for ur suggestion....
but when i referred jeffprocise i didn"t find the description of all MFC classes
Pls correct me if im wrong...
|
|
|
|
|
It is good enough to start with, and I don't know what do you mean by "all" classes. I reckon that book covered every aspect of programming with MFC and is a very good book.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
Google is your best friend.
|
|
|
|
|
He is just asking for book suggestions, which is fairly acceptable.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
you get links to a lot of books in Google. i personally don't think that was a bad answer.
|
|
|
|
|
Chandrasekharanp wrote: you get links to a lot of books in Google.
Yep, and that's the problem. Because how to filter out the good ones out of this full list ?
|
|
|
|
|
Possibly statistically.
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]
|
|
|
|
|
He isn't asking code to do something strikingly obvious that can be Googled.
The OP mentioned that he is new to MFC and he is looking for experienced people to recommend MFC books to him, and to help such people is the very purpose of the existence of forums like this. IMHO, people here will be able to recommend books better than Google can.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
|
p_1960 wrote: MFC Classes are explained in detail
How about having a look at the hierarchy chart in MSDN[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
_AnsHUMAN_ wrote: How about having a look at the hierarchy chart in MSDN[^]
That's pretty old. The latest chart (three parts) is here[^]
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
On the link that I provided it is written - This page is specific to Microsoft Visual Studio 2003/.NET Framework 1.1
p_1960 wrote: ...im using vs2003
The OP had mentioned
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Ah! You cut me low.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
"The MFC Answer Book" by Eugene Kain
"Beginning Visual C++ 6" by Ivor Horton (also available for VC++ 2005 and VC++ 2008)
|
|
|
|