|
If you're using MFC you can create two CTime objects from your SYSTEMTIME s, subtract the other from the first and use CTimeSpan::GetTotalSeconds()
|
|
|
|
|
I have used 2 FILETIME objects like this before with the function:
FILETIME current_time ;
FILETIME start ;
::GetSystemTimeAsFileTime(&start) ;
Sleep(100) ;
::GetSystemTimeAsFileTime(¤t_time) ;
double elapsed = CalculateElapsedTime(&start, & current_time) ;
double CalculateElapsedTime(FILETIME *start, FILETIME *current)
{
double elapsed_time ;
__int64 st ;
__int64 ct ;
__int32 *p ;
p = (__int32*)&st ;
*p++ = start->dwLowDateTime ;
*p = start->dwHighDateTime ;
p = (__int32*)&ct ;
*p++ = current->dwLowDateTime ;
*p = current->dwHighDateTime ;
elapsed_time = (double)(ct - st) ;
elapsed_time /= 10000000.0 ;
return elapsed_time ;
}
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Thanx..
|
|
|
|
|
Hi,
I have made a program to hook WH_CBT. The application is
logging the appl name into a log file,
the problem is that i just want the application
name once, where as hooking this WH_CBT is writting
into the log file the application name, number of
times..
How do i do it so that the application name is written
only once
Sameer
|
|
|
|
|
void logAppName()
{
static bool appAlreadyLogged=false;
if(appAlreadyLogged) return;
...
appAlreadyLogged=true;
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
This won't do bcoz, everytime the applcation name
changes
|
|
|
|
|
void logAppName(const char* appName)
{
static std::set<std::string> appsLogged;
if(appsLogged.insert(appName).second==false)return;
...
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi All!
I used CInterSession::OpenURL() to open a TIFF file URL. Then, I used CHttpFile::Read() function to read the TIFF file into a local heap buffer.
About on 100 machines(95/98/NT/XP) it works fine. But on 2 machines (one is windows95 & another windows NT workstn) the Read() returns after just reading the first 263 bytes. What could be the problem??
I checked WININET.DLL versions. On other machines with the same DLL versions, same OS, same SP it works fine. But not on these 2 machines. Its bugging me. Can anybody help please...
|
|
|
|
|
It is ok, you cannot expect to read all the file in one shot. Think that you have a 1Gb file to download
Actually you need to keep reading from file untill the buffer returned is empty. Ammount of bytes read in single operation depends on OS, Connection and settings somewhere in Registry.
Philip Patrick
Web-site: www.stpworks.com
"Two beer or not two beer?" Shakesbeer
Need Web-based database administrator? You already have it!
|
|
|
|
|
Thanks for your response Phil.
But, I have the Read() code in a do-while loop. The first iteration reads 263 bytes and the Read() in second iteration returns a zero, which terminates my do loop.
The algorithem I have is:
int nRead=0;
char szBuffer[1024];
char szBigBuffer[100K];
do
{
nRead = CHttpFile::Read(szBuffer, sizeof(szBuffer)
if(nRead>0)
Append the szBuffer to szBigBuffer
}while(nRead>0);
Sincerely appreciate your help.
-Srini.
|
|
|
|
|
Have you actually looked at what the 263 bytes contain? Perhaps the server is returning a 404 page to you. I've had this happen that the server returns a "valid" web page that is actually not what I was looking for since I got the URL wrong.
Joel Lucsy (jjlucsy@ameritech.net)
|
|
|
|
|
Hi Joel:
Thank God. I am out of this. Your suggestion has really worked for me. Its a Proxy problem. I dumped the 263 byte stream. It has an error message from our production proxy servers.
Thank you verymuch.
Srini.
|
|
|
|
|
i have a dialog based application
i just want to change the color of the controls when mouse moves on and want to capture WM_MOUSEMOVE event on a pushbutton, ListBox, or ListCtrl
but i couldn't. At the rest of the client area it is captured but on these controls it doesn't.
What should i do?
just listening to you...
|
|
|
|
|
When you have an active control in the client area, your control will capture your mouse movement. In order for the control's parent to capture such message, you need to specify "Notify" style for it.
|
|
|
|
|
Dear All,
In a dialog based appliction, i have a 8-bit
bmp image which only have 4-colors. so its
pallete looks like this: white, blue, black, red,
and the remind all are black.
Now i have a new pallete in which 16 colors are
used. I can change the pallete of the original bmp
image with the new pallete by using read and write
pallete functions. If doing so, the display mode of bmp image also changed. But i hope the bmp image displayed same with the original one.
How should i do? rewite the color datas of the bmp file? How to do this?
Thanks in advance!
chen
xyz
|
|
|
|
|
Probaly the easiest way is to reorder the 16-color palette so tat it matches the 4-color one in the critical entries (which probably are the first five), and then do the copying.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks for your reply!
I want to make the original and new bmp image displayed in same way.
So how to change the color data of the original bmp image (because
the pallet have been changed)?
xyz
|
|
|
|
|
I open my applicaiton. and do selecting text other application such as notepad then I press my hotkey such as Control+Tab (I'm not using control C, so it isn't using clipboard) and that selecting text is sending to my application. I has to registerhotkey but how shoud I do for sending that selecting text ?
thank you so much.
|
|
|
|
|
I have a problem on extern function templates. The syntax compiles OK, but gets:
error LNK2001: unresolved external symbol "int __cdecl Next(int)" (?Next@@YAHH@Z)
Only function templates cause such problem; general functions like
int MyFunction(void* p)
does not cause such problem.
My VC++ is 6.0 sp5.
Here is the example code...
In the first file main.cpp:
/* *********************** */
////////////
// main.CPP
#include <iostreamᡊe9ac73-238b-46be-991d-0f050c37248dusing namespace std;
template<class T> extern T Next(T val);
void main()
{
int a = Next(3);
cout << "a = " << a << endl;
}
/* *********************** */
In the second file function.cpp
///////////////////
// function.CPP
template<class Tᡊe9ac73-238b-46be-991d-0f050c37248dT Next(T val)
{
return val++;
}
/* ************ */
Maxwell Chen
|
|
|
|
|
As main.cpp does not see the definition of Next , which is hidden in function.cpp , it is required that function.cpp "exports" the instantiation of this template for int s like this:
template<class T>
T Next(T val)
{
return val++;
}
template int Next(int); This is not a very smart design, as function.cpp has to know in advance for which types Next is going to be used. Usually, it is better to have the definition of all templates inside header files included by the "consumer" .cpp s.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
Sorry guys, but how can i pass a parameter to
the dll which i've hooked to the system
Please help
Sameer
|
|
|
|
|
Export some function to accept the parameters and have them stored in a data shared segment (if you need help about shared segments, check Phil McGahan's article How to share a data segment in a DLL.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
hi,
i did this.. and made a function setfilename(char *)
which changes the filename..
but in my DLL mail i am doing fopen.. but now the
file is not being created
#pragma data_seg (".HookSection")
// Shared instance for all processes.
static HHOOK hHook = NULL;
// Change 2
static char szFilename[_MAX_PATH] = "";
// Change 2
#pragma data_seg ()
|
|
|
|
|
setfilename does a strcpy to szFilename , right? If so, everything should work fine. Check the following:- Make sure the filename is correctly set by displaying it somehow (say with a
MessageBox ) right before calling fopen .
- Maybe the file is being opened in a directry different to what you expected.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Actually i had put that code in DLLMain, but now it
is inside HookProc..
Now the problem is that when i run some application,
lot of entries of the same application are logged on
to my log file.. whereas first it was just one
Sameer
|
|
|
|