|
Hello Thomas,
thank for answer!
you mean something like this:
char acContentBuffer[100000];
FILE* pFile;
pFile = fopen(m_csExeFile, "r");
int i = 0;
char ch;
while(EOF != (ch = getc(pFile)))
{
acContentBuffer[i++] = ch;
}
acContentBuffer[i] = '\0';
break;
|
|
|
|
|
break; wrote: while(EOF != (ch = getc(pFile))){ acContentBuffer[i++] = ch;}
Read the file in one big chunk (e.g., fread() ), not one character at a time.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
thank you for answer, this help me!
Now i can read from file all chars, next step is to write back to the same!
And this is my current problem, my *.exe file is not runnable after i write the data back!
And the same file have 1KB more size as before!
When i make changes with an hex-editor manualy character by character it stay all ok!
No size changes and exe run again!
Can give me some suggestion for this, how to write back in to exe?!
(This should be litle function to check identity of an executable, to avoid some manipulations of the same)
thanks in advance
break;
|
|
|
|
|
break; wrote: And this is my current problem, my *.exe file is not runnable after i write the data back!
And the same file have 1KB more size as before!
So what are you doing to the data after it has been read, and what does the "write" code look like?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi, Can I know how can I add image to Button control using WIN32 API not MFC. Thanks In advance.
|
|
|
|
|
priyank_ldce wrote: Hi, Can I know how can I add image to Button control using WIN32 not MFC. Thanks In advance.
BM_SETIMAGE .
|
|
|
|
|
SendMessage(hWndButton,BM_SETIMAGE,IMAGE_BITMAP,(LPARAM)handlebitmap);
|
|
|
|
|
Hi,
how can I use the event in a control Activex
when I add an event to the control I have this method:
void CPrincipale::CardEventItdcinterfacectrl1(short nIndex, LPCTSTR EventBoardIndex, LPCTSTR EventReaderIndex, LPCTSTR EventCardID, LPCTSTR EventDate, LPCTSTR EventTime, LPCTSTR EventStatus)
{
// TODO : ajoutez ici le code de votre gestionnaire de messages
}
|
|
|
|
|
Is there some quick way how to get IE version when I got IHTMLDocument2 interface ?
I know I could try to query for some interfaces supported by some certain version of IE but it could fail also for other reasons than IE version.
Thank you!
rrrado
|
|
|
|
|
rrrado wrote: Is there some quick way how to get IE version when I got IHTMLDocument2 interface ?
You can check the version of the Common control dll version that ships with IE.
I hope I understood your question.
|
|
|
|
|
I just need to know if there is installed IE7 or lower
rrrado
|
|
|
|
|
rrrado wrote: Is there some quick way how to get IE version...
Like looking at the version information within iexplore.exe?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Hello,
I have a app Dialog MFC and it run perfecltly when I compil with static Dll but when I compile with shared dll and try to start my application I get this message:
Aplication can not be started because because MFC80D.dll not found. A new installation should be fixthe problem. (sorry I have translated this text from a other language)
I do not understand because I have think that the MFC80D.dll was or only used for Debug modus.
Wath can I change in my properties to fix this problem.
Thank !
AutreChien
|
|
|
|
|
NorGUI wrote: do not understand because I have think that the MFC80D.dll was or only used for Debug modus
Yes, but did you compile in release mode ? If you compile in debug mode, you'll still use this dll of course (to change the mode, you'll have to go in the project properties, it depends of which IDE you are using).
|
|
|
|
|
I want to use this timer class for precise data sampling and display the sampled data in strip chart of a dialog time by time
such as 10us a data will be display on strip chart.
below is the class code written by Dean Wyant
<br />
<br />
<br />
__int64 CPerfTimer::m_Freq = 100000; <br />
__int64 CPerfTimer::m_Adjust = 0; <br />
<br />
<br />
<br />
<br />
BOOL CPerfTimer::IsSupported()<br />
{
return (m_Freq > 1);<br />
}<br />
<br />
const double CPerfTimer::Resolution() <br />
{
return 1.0/(double)m_Freq; <br />
}<br />
<br />
const double CPerfTimer::Resolutionms() <br />
{
return 1000.0/(double)m_Freq; <br />
}<br />
<br />
const double CPerfTimer::Resolutionus() <br />
{
return 1000000.0/(double)m_Freq; <br />
}
// CPerfTimer - a simple Win32 performance counter wrapper
// by Dean Wyant dwyant@mindspring.com
/*
This class is simple to use. Just declare a variable(s) as type CPerfTimer,
call Start() to start timimg and call Stop() to stop timimg. You can pause a
timer by calling Stop() and then you can call Start() to resume. Retrieve the
elapsed time by calling an Elapsed..() function. Assignment, addition,
subtraction and comparison are supported. There are a few information calls
available also. All calls except Start and Stop can be performed on a timer
without stopping it.
*/
#ifndef __PERFTIMER_H__<br />
#define __PERFTIMER_H__<br />
<br />
class CPerfTimer<br />
{<br />
public:<br />
CPerfTimer(BOOL bStart = FALSE) {Init(bStart);}<br />
<br />
CPerfTimer(const CPerfTimer& Src); <br />
<br />
virtual ~CPerfTimer() {;}<br />
<br />
void Start(BOOL bReset = FALSE);
void Stop();
<br />
BOOL IsRunning();
<br />
BOOL IsSupported();
<br />
const double Resolution();
const double Resolutionms();
const double Resolutionus();
<br />
const double Elapsed();
const double Elapsedms();
const double Elapsedus();
<br />
const CPerfTimer& operator=(const CPerfTimer& Src);
<br />
CPerfTimer operator+(const CPerfTimer& Src) const;<br />
CPerfTimer operator-(const CPerfTimer& Src) const;<br />
const CPerfTimer& operator+=(const CPerfTimer& Src);<br />
const CPerfTimer& operator-=(const CPerfTimer& Src);<br />
CPerfTimer operator+(const double Secs) const;<br />
CPerfTimer operator-(const double Secs) const;<br />
const CPerfTimer& operator+=(const double Secs);<br />
const CPerfTimer& operator-=(const double Secs);<br />
<br />
BOOL operator<(const CPerfTimer& Src);<br />
BOOL operator>(const CPerfTimer& Src);<br />
BOOL operator<=(const CPerfTimer& Src);<br />
BOOL operator>=(const CPerfTimer& Src);<br />
BOOL operator<(const double Secs);<br />
BOOL operator>(const double Secs);<br />
BOOL operator<=(const double Secs);<br />
BOOL operator>=(const double Secs);<br />
<br />
virtual void Lock() const {;}
virtual void Unlock() const {;}
protected:<br />
void Init(BOOL bStart);<br />
void Copy(const CPerfTimer& Src);<br />
<br />
private:<br />
__int64 m_Start;<br />
static __int64 m_Freq;
static __int64 m_Adjust;
};<br />
<br />
class CPerfTimerT : public CPerfTimer<br />
{
public:<br />
CPerfTimerT(BOOL bStart = FALSE)<br />
{<br />
m_hMutex = CreateMutex(NULL,FALSE,"");<br />
Init(bStart);<br />
}<br />
<br />
CPerfTimerT(const CPerfTimerT& Src) <br />
{ <br />
m_hMutex = CreateMutex(NULL,FALSE,"");<br />
Copy(Src); <br />
}<br />
<br />
CPerfTimerT(const CPerfTimer& Src) <br />
{ <br />
m_hMutex = CreateMutex(NULL,FALSE,"");<br />
Copy(Src); <br />
}<br />
<br />
virtual ~CPerfTimerT() <br />
{ CloseHandle(m_hMutex); }<br />
<br />
const CPerfTimerT& operator=(const CPerfTimerT& Src)
{<br />
Copy(Src);<br />
return *this; <br />
}<br />
<br />
virtual void Lock() const { WaitForSingleObject(m_hMutex,10000); } <br />
virtual void Unlock() const { ReleaseMutex(m_hMutex); } <br />
private:<br />
HANDLE m_hMutex;<br />
};<br />
<br />
inline void CPerfTimer::Init(BOOL bStart)<br />
{<br />
if (!m_Freq) <br />
{
QueryPerformanceFrequency((LARGE_INTEGER *)&m_Freq); <br />
if (!m_Freq)<br />
m_Freq = 1;
m_Start = 0; <br />
m_Adjust = 0; <br />
Start();
Stop(); <br />
m_Adjust = m_Start;<br />
}<br />
m_Start = 0; <br />
if (bStart)<br />
Start(); <br />
}<br />
<br />
inline CPerfTimer::CPerfTimer(const CPerfTimer& Src) <br />
{<br />
Copy(Src);<br />
}<br />
<br />
inline void CPerfTimer::Copy(const CPerfTimer& Src)<br />
{<br />
if (&Src == this) <br />
return;
Src.Lock();<br />
Lock();<br />
m_Start = Src.m_Start; <br />
Unlock();<br />
Src.Unlock();<br />
}<br />
<br />
inline void CPerfTimer::Start(BOOL bReset) <br />
{
__int64 i;<br />
QueryPerformanceCounter((LARGE_INTEGER *)&i);<br />
Lock();<br />
if ((!bReset) && (m_Start < 0))<br />
m_Start += i;
else <br />
m_Start = i;
Unlock();<br />
} <br />
<br />
inline void CPerfTimer::Stop() <br />
{
Lock();<br />
if (m_Start <= 0)<br />
{<br />
Unlock();<br />
return;
}<br />
__int64 i;<br />
QueryPerformanceCounter((LARGE_INTEGER *)&i); <br />
m_Start += -i;
if (m_Start < m_Adjust)
m_Start -= m_Adjust;
else <br />
m_Start = 0;
Unlock();<br />
} <br />
<br />
inline BOOL CPerfTimer::IsRunning() <br />
{
Lock();<br />
BOOL bRet = (m_Start > 0);
Unlock();<br />
return bRet; <br />
}<br />
inline const double CPerfTimer::Elapsed()<br />
{
CPerfTimer Result(*this);<br />
Result.Stop();<br />
return (double)(-Result.m_Start)/(double)m_Freq; <br />
}<br />
<br />
inline const double CPerfTimer::Elapsedms() <br />
{
CPerfTimer Result(*this);<br />
Result.Stop();<br />
return (-Result.m_Start*1000.0)/(double)m_Freq; <br />
}<br />
<br />
inline const double CPerfTimer::Elapsedus() <br />
{
CPerfTimer Result(*this);<br />
Result.Stop();<br />
return (-Result.m_Start * 1000000.0)/(double)m_Freq; <br />
}<br />
<br />
<br />
inline const CPerfTimer& CPerfTimer::operator=(const CPerfTimer& Src) <br />
{<br />
Copy(Src);<br />
return *this; <br />
}<br />
<br />
<br />
inline CPerfTimer CPerfTimer::operator+(const CPerfTimer& Src) const<br />
{<br />
CPerfTimer Result(*this);<br />
Result += Src; <br />
return Result; <br />
}<br />
<br />
inline CPerfTimer CPerfTimer::operator-(const CPerfTimer& Src) const<br />
{<br />
CPerfTimer Result(*this);<br />
Result -= Src; <br />
return Result; <br />
}<br />
<br />
inline const CPerfTimer& CPerfTimer::operator+=(const CPerfTimer& Src)<br />
{<br />
CPerfTimer SrcStop(Src);
SrcStop.Stop();<br />
Lock();<br />
m_Start += SrcStop.m_Start;<br />
Unlock();<br />
return *this; <br />
}<br />
<br />
inline const CPerfTimer& CPerfTimer::operator-=(const CPerfTimer& Src)<br />
{<br />
CPerfTimer SrcStop(Src);
SrcStop.Stop();<br />
Lock();<br />
m_Start -= SrcStop.m_Start; <br />
Unlock();<br />
return *this; <br />
}<br />
<br />
inline CPerfTimer CPerfTimer::operator+(const double Secs) const<br />
{<br />
CPerfTimer Result(*this);<br />
Result += Secs; <br />
return Result; <br />
}<br />
<br />
inline CPerfTimer CPerfTimer::operator-(const double Secs) const<br />
{<br />
CPerfTimer Result(*this);<br />
Result += Secs; <br />
return Result; <br />
}<br />
<br />
inline const CPerfTimer& CPerfTimer::operator+=(const double Secs)<br />
{<br />
Lock();<br />
m_Start -= (__int64)(Secs*(double)m_Freq);<br />
Unlock();<br />
return *this; <br />
}<br />
<br />
inline const CPerfTimer& CPerfTimer::operator-=(const double Secs)<br />
{<br />
Lock();<br />
m_Start += (__int64)(Secs*(double)m_Freq);<br />
Unlock();<br />
return *this; <br />
}<br />
<br />
<br />
<br />
inline BOOL CPerfTimer::operator<(const CPerfTimer& Src)<br />
{ <br />
BOOL bRet; <br />
CPerfTimer Temp(Src);<br />
Lock();<br />
if (m_Start <= 0)<br />
{<br />
Temp.Stop();<br />
bRet = (m_Start > Temp.m_Start); <br />
Unlock();<br />
return bRet;<br />
}<br />
else<br />
if (Temp.m_Start > 0)<br />
{<br />
bRet = (m_Start < Temp.m_Start); <br />
Unlock();<br />
return bRet;<br />
}<br />
else<br />
{<br />
Unlock();<br />
CPerfTimer ThisStop(*this);<br />
ThisStop.Stop();<br />
return (ThisStop.m_Start > Temp.m_Start); <br />
}<br />
}<br />
<br />
inline BOOL CPerfTimer::operator>(const CPerfTimer& Src)<br />
{ <br />
BOOL bRet; <br />
CPerfTimer Temp(Src);<br />
Lock();<br />
if (m_Start <= 0)<br />
{<br />
Temp.Stop();<br />
bRet = (m_Start < Temp.m_Start); <br />
Unlock();<br />
return bRet;<br />
}<br />
else<br />
if (Temp.m_Start > 0)<br />
{<br />
bRet = (m_Start > Temp.m_Start); <br />
Unlock();<br />
return bRet;<br />
}<br />
else<br />
{<br />
Unlock();<br />
CPerfTimer ThisStop(*this);<br />
ThisStop.Stop();<br />
return (ThisStop.m_Start < Temp.m_Start); <br />
}<br />
}<br />
<br />
inline BOOL CPerfTimer::operator<=(const CPerfTimer& Src)<br />
{ <br />
return !(*this > Src);<br />
}<br />
<br />
inline BOOL CPerfTimer::operator>=(const CPerfTimer& Src)<br />
{ <br />
return !(*this < Src);<br />
}<br />
<br />
inline BOOL CPerfTimer::operator<(const double Secs)<br />
{ <br />
BOOL bRet; <br />
Lock();<br />
if (m_Start <= 0)<br />
{<br />
bRet = (m_Start > (__int64)(-Secs*(double)m_Freq)); <br />
Unlock();<br />
return bRet;<br />
}<br />
else<br />
{<br />
Unlock();<br />
CPerfTimer ThisStop(*this);<br />
ThisStop.Stop();<br />
return (ThisStop.m_Start > (__int64)(-Secs*(double)m_Freq)); <br />
}<br />
}<br />
<br />
inline BOOL CPerfTimer::operator>(const double Secs)<br />
{ <br />
BOOL bRet; <br />
Lock();<br />
if (m_Start <= 0)<br />
{<br />
bRet = (m_Start < (__int64)(-Secs*(double)m_Freq)); <br />
Unlock();<br />
return bRet;<br />
}<br />
else<br />
{<br />
Unlock();<br />
CPerfTimer ThisStop(*this);<br />
ThisStop.Stop();<br />
return (ThisStop.m_Start < (__int64)(-Secs*(double)m_Freq)); <br />
}<br />
}<br />
<br />
inline BOOL CPerfTimer::operator<=(const double Secs)<br />
{ <br />
return !(*this > Secs);<br />
}<br />
<br />
inline BOOL CPerfTimer::operator>=(const double Secs)<br />
{ <br />
return !(*this < Secs);<br />
}<br />
<br />
<br />
#endif //__PERFTIMER_H__
daemone
|
|
|
|
|
daemone wrote: I want to use this timer class for precise data sampling and display the sampled data in strip chart of a dialog time by time
such as 10us a data will be display on strip chart.
below is the class code written by Dean Wyant
1. This is no good habit to post a complete piece of code into a forum, it is a waste.
2. And your question is ...?
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
Oh, sorry, I will be care next time!
My question is that I want to use CPerftimer class instead of System timer(using Settimer()), because I want to sampling data very precisely.
As we all know, We use OnTimer() function to handle the System timer overflow message, and in Ontimer function, we can add our code. but for a CPerftimer , it is created by user, how to handle its overflow function, so that I can add my sampling data instrunction into the handle function.
|
|
|
|
|
What your problem? and I think its not good idea to post a long code
|
|
|
|
|
Hello,
I was hoping you could help explain my compile error in using 'const'.
I have an array defined as
<br />
const char* const letters[] = {"one", "two"};<br />
where 'const char*' means I have my elements as constant charcter ptrs (so they can't point to anything else) and 'const letters[]' meaning I have an array of fixed length (I hope that that was correct?).
So I wish to define a ptr at the 1st element and I use
<br />
const char* i = letters;<br />
meaning I want a constant ptr of type char pointing to the 1st element. But I keep getting this compiles error
"cannot convert from 'const char* const[2]' to 'const char*'
If anyone can give me an explanation then that would be great.
Thanks !
|
|
|
|
|
This is not because of the const keyword but because the two types are unrelated: char* i is a pointer to a char array and char* letter[] is an array of pointer to char arrays. So you one is a simple pointer and this other one is an array of pointer. You should do something like this: const char* i = letters[0]; instead
|
|
|
|
|
Thank you for that. It worked! I was wondering was I right in my comments on the 2 uses of const in the array def.?
|
|
|
|
|
minkowski wrote: I was wondering was I right in my comments on the 2 uses of const in the array def.?
Yes, it is correct.
~RaGE();
I think words like 'destiny' are a way of trying to find order where none exists. - Christian Graus
|
|
|
|
|
But I thought that if you refer to an array without the [] its just referring to the 1st element in the array which is equivalent to writing
<br />
const char *p = arr;<br />
which is the same as
<br />
const char *p = arr[0];<br />
but I get a compile error ![Confused | :confused:](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_confused.gif)
|
|
|
|
|
minkowski wrote: But I thought that if you refer to an array without the [] its just referring to the 1st element in the array
Not at all: you refer to the address of the first element, which is totally different.
Example: if you have an integer array:
int pIntArray[5];
for (int i=0;i<5;i++)
pIntArray[i] = i;
int Test = pIntArray[0];
int Test2 = pIntArray;
|
|
|
|