|
\\m_sTime is the local computer time
\\m_strOn1 -> m_strOn8 are edit box's that a user can enter time's into
the problem is the if statment keeps returning true,varibles m_strOn1 too m_strOn7 are all the same,but m_strOn8 is different and the secondif statment should return true not the first.
obviously im doing something incorrect here,can anybody help?
if(m_sTime == m_strOn1 && m_strOn2 && m_strOn3 && m_strOn4 && m_strOn5 && m_strOn6 && m_strOn7 && m_strOn8 )
{
Out32(0x378,255);
m_Pin1 = TRUE;
m_Pin2 = TRUE;
m_Pin3 = TRUE;
m_Pin4 = TRUE;
m_Pin5 = TRUE;
m_Pin6 = TRUE;
m_Pin7 = TRUE;
m_Pin8 = TRUE;
UpdateData(false);
MessageBox("11111111","here",MB_OK);
}
else
if(m_sTime == m_strOn1 && m_strOn2 && m_strOn3 && m_strOn4 && m_strOn5 && m_strOn6 && m_strOn7 != m_strOn8)
{
Out32(0x378,254);
m_Pin1 = TRUE;
m_Pin2 = TRUE;
m_Pin3 = TRUE;
m_Pin4 = TRUE;
m_Pin5 = TRUE;
m_Pin6 = TRUE;
m_Pin7 = TRUE;
m_Pin8 = FALSE;
UpdateData(false);
MessageBox("11111110","here",MB_OK);
}
|
|
|
|
|
thes3cr3t1 wrote: if(m_sTime == m_strOn1 && m_strOn2 && m_strOn3 && m_strOn4 && m_strOn5 && m_strOn6 && m_strOn7 && m_strOn8 )
You have to check all the variables like
m_sTime == m_strOn1 && m_sTime == m_strOn2 && m_sTime == m_strOn3 ... etc.
- NS -
|
|
|
|
|
NS17 wrote: m_sTime == m_strOn1 && m_sTime == m_strOn2 && m_sTime == m_strOn3 ... etc.
Easy when you know how,it worked perfectly thankyou very much!
Chris
|
|
|
|
|
thes3cr3t1 wrote: \\m_sTime is the local computer time
In what kind of variable ? A char*, a CString, a DWORD, ... ?
thes3cr3t1 wrote: \\m_strOn1 -> m_strOn8 are edit box's that a user can enter time's into
Not the edit boxe classes but a string variable (CString) associated to the control ? Right ?
thes3cr3t1 wrote: if(m_sTime == m_strOn1 && m_strOn2 && m_strOn3 && m_strOn4 && m_strOn5 && m_strOn6 && m_strOn7 && m_strOn8 )
What are you trying to do there ? You want to compare the m_sTime string (if it is a string) to all of the other strings ? You cannot do it that way. And also you probably have a problem with operator precedence.
I think you need to revise a little bit how to use operators in C++. The way to do it is:
if ( (m_sTime == m_strOn1) && (m_sTime == m_strOn2) )
(and you continue for all the variables you want to test). Otherwise, in your case, you will check if m_strOn1 is true (and I even wondering how it does compile ).
|
|
|
|
|
Okay let me explain, i have a electronic circuit board with eight relay switches on it, it is connected to my computer via the parrallel port,i am trying to code an aplication that can
1)individualy turn on and off each relay
2)turn on\off one or more of the eight relay's at a certain time
To that end i have a timer that gets the current time (m_sTime) and updates every second
i have 16 editbox's that are CString varibles that a user can enter time's into,eight for on time,eight for off time.
then on every clock tick i want to check if any of the user inputted times match the realtime i.e m_sTime.
i need to know which of the user inputted times match, e.g if all of the times match i need execute binary 11111111, "Out32(0x378,255);.
or if say m_strOn1 and m_strOn2 match and all the others do not match i need to send binary 00000011, "Out32(0x378,3);" by converting binary to decimal
there must be a easier way of achiving what im trying to do,currently im having to use a binary conversion table to calculate ever posibility of on/off sequnces
and hard code them into my aplication
I hope this makes a little more sense to you,im in the army so coding has become just a hobby as work dominates my weekday time.
many thanks chris
|
|
|
|
|
int timerPinout = 0;
void CChrisRelayDlg::CheckTimers()
{
if (m_strOn1 == m_sTime)
{
m_Pin1 = TRUE;
timerPinout |= 0x1;
}
if (m_strOn2 == m_sTime)
{
m_Pin2 = TRUE;
timerPinout |= 0x2;
}
if (m_strOn3 == m_sTime)
{
m_Pin3 = TRUE;
timerPinout |= 0x4;
}
if (m_strOn4 == m_sTime)
{
m_Pin4 = TRUE;
timerPinout |= 0x8;
}
if (m_strOn5 == m_sTime)
{
m_Pin5 = TRUE;
timerPinout |= 0x10;
}
if (m_strOn6 == m_sTime)
{
m_Pin6 = TRUE;
timerPinout |= 0x20;
}
if (m_strOn7 == m_sTime)
{
m_Pin7 = TRUE;
timerPinout |= 0x40;
}
if (m_strOn8 == m_sTime)
{
m_Pin8 = TRUE;
timerPinout |= 0x80;
}
if (m_strOff1 == m_sTime)
{
m_Pin1 = FALSE;
timerPinout &= 0xFE;
}
if (m_strOff2 == m_sTime)
{
m_Pin2 = FALSE;
timerPinout &= 0xFD;
}
if (m_strOff3 == m_sTime)
{
m_Pin3 = FALSE;
timerPinout &= 0xFB;
}
if (m_strOff4 == m_sTime)
{
m_Pin4 = FALSE;
timerPinout &= 0xF7;
}
if (m_strOff5 == m_sTime)
{
m_Pin5 = FALSE;
timerPinout &= 0xEF;
}
if (m_strOff6 == m_sTime)
{
m_Pin6 = FALSE;
timerPinout &= 0xDF;
}
if (m_strOff7 == m_sTime)
{
m_Pin7 = FALSE;
timerPinout &= 0xBF;
}
if (m_strOff8 == m_sTime)
{
m_Pin8 = FALSE;
timerPinout &= 0x7F;
}
if (m_strOff6 == m_sTime)
{
m_Pin6 = FALSE;
timerPinout &= 0xDF;
}
Out32(0x378,timerPinout);
m_iCout--;
UpdateData(false);
}
|
|
|
|
|
Gentlemen,
I am reworking on a japanese database project which was previously done.
Instead of using ms-access database, they used their own defined database with *.cho as extensiion not *.mdb, and this database is using jet engine and MFC wrappers.
How could one create database with custom extension and communicate with jet engine using Dao MFC wrappers?
Padam Raj Gurung
|
|
|
|
|
Hi!
i know virtual address of code section (of an exe) is 401000 (for example).
when this exe is running, how do i get real address with virtual exe?
i want to determinate which exe call my function (my function is in other exe).
in my function, i pop of stack, this value is virtual address of exe that call my function. but real address?
Zo.Naderi-Iran
|
|
|
|
|
Well, you can use LoadLibrary(...) to load an executable into your address space. If you know the relative offset of the code you are trying to execute, you should be able to calculate the offset after loading it into your address space (and knowing where it was loaded at).
Getting the offset in the other running executable may be possible via injection or using CreateRemoteThread(...) . How to inject into running processes and/or use CreateRemoteThread(...) is a whole series of articles in itself.
If the function is exported via an export table (yes, EXEs can export functions just like DLLs), you can just use GetProcAddress(...) after calling LoadLibrary(...) , just like a normal DLL.
Note that even though you will be running code in the other executable, you will not be able to share data easily between the two because they are running in completely separate address spaces.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi,
I execute the lines of code below
<br />
#include "ATLComTime.h"<br />
<br />
COleDateTime tmVal = COleDateTime::GetCurrentTime();<br />
CString tmStr = tmVal.Format(LOCALE_NOUSEROVERRIDE, LOCALE_NEUTRAL);<br />
On executing tmVal will be say 39391.729583333.
tmStr give me the current time in the format tmStr = "11/5/2007 5:30:36 PM" (Current time).
Now assume, I have only tmStr value of "11/5/2007 5:30:36 PM", can I get the tmVal of 39391.729583333 from tmStr.
Are there any api's which will help me with this conversion?
|
|
|
|
|
I do not know of a standard Parse(...) function that will do it all for you. You can, however, manually parse out the parts of the datetime string and then feed the values one of the versions of the COleDateTime construtor.
For example, the datetime string is formatted as MM/DD/YYYY HH:MM:SS XX , which can be parsed easily using functions like _stscanf(...) - look it up for info on how to create the format string to parse out those values. Something like:
%02d/%02d/%04d%c02d:%02d:%02d%c%c%c Might be able to parse it correctly. The formatted character specifiers will read the space characters and the "M" part of AM/PM and can be discarded.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hi,
Got the solution
<br />
COleDateTime tmVal;<br />
tmVal.ParseDateTime(tmStr);<br />
will get back my tmVal.
I have another issue.
Are there any API's which will tell me the time format set by the user in
Control Panel -> Region and Language Options -> Custom -> Select Time Tab, in this dialog, please refer to the "Time Format" Combo.
Basically the combo i am refering to above lets me set the format in which time/ date has to be shown to me i.e, by appropriately setting, I can view my current date as either MM/DD/YYYY or YYYY/MM/DD etc.....
Are there any API's which will tell me the current display format set by me?.
I need this info, because I store the string tmStr which I get from the code below.
<br />
COleDateTime tmVal = COleDateTime::GetCurrentTime();<br />
CString tmStr = tmVal.Format(LOCALE_NOUSEROVERRIDE, LOCALE_NEUTRAL);<br />
Depending on the time format selected by the user, I have to accordingly manipulate the string and display it to the user.
Thanks.
|
|
|
|
|
Hi,
I want to measure elapsed time of a function in microsecs how to do that.
I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++?
Thanks
|
|
|
|
|
shir_k wrote: I tried with clock()(output is in seconds/ millisec),GetTickCount() (in millisec) the output is in secs or millisecs,i need in microsecs.Is there any function in VC++?
try QueryPerformanceCounter (Multimedia Timers)
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Not without calling QueryPerformanceFrequency(...) first to make sure that [1] the HR timer is available and [2] that it supports microsecond-level resolution...
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
James R. Twine wrote: first to make sure that [1] the HR timer is available and [2] that it supports microsecond-level resolution...
right as usual
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
You may also be able to get suitable timing information using the RDTSC instruction. Google for it for more details. If the function will not be running across multiple physical or logical CPUs (its affinity is locked to one CPU, or it is running in a single-CPU system), and will not be running across a sleep/hybernation operation, it should be accurate enough.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hello every body,
I am encountering a problem. I have a piece of code written by some other person. The intention is to display the Protected operating system files in my application, even if the option is checked i-e Organize->Folder and search options-> view and "Hide Protected operating system files". [At the moment I have Vista o/s]
if (pParentFolder->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS |
SHCONTF_INCLUDEHIDDEN, &pEnumIDList) == NOERROR)
Above is the already coded line and I have searched there is no flag for o/s files in the structure. I will be thankful if anybody could help me. Thanks in advance.
Best Regards,
Yasir Nisar
|
|
|
|
|
Hello
My application works only with administrative login because it has to access keys under HKLM in the PC and also works on process's to get their information like the process name and its other details.
But though I have an administrative login in one of the PC's the RegOpenKeyEx() API with KEY_READ flag fails to read a particular key under HKLM (a key which is by default present on a PC installed with windows XP)
Also, when I try to open a process using OpenProcess( PROCESS_QUERY_INFORMATION |PROCESS_VM_READ,FALSE, ProcessID), this API fails to open the process inspite of having SE_DEBUG_NAME privilege.
What could be the reason for this? Is it possible that though a user has Admin privileges, access to the registry can be denied?
Thanx.
|
|
|
|
|
What are the error codes?
Do the errors go away if you run the app as an administrator?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all....
How can I verify the memmory left on a hard disk?
|
|
|
|
|
Use GetDiskFreeSpace, GetDiskFreeSpaceEx .
Regards,
Paresh.
|
|
|
|
|
Arish rivlin wrote: How can I verify the memmory left on a hard disk?
GetDiskFreeSpaceEx[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
This[^] blog entry is interesting when you're into that theme.!
Let's think the unthinkable, let's do the undoable, let's prepare to grapple with the ineffable itself, and see if we may not eff it after all. Douglas Adams, "Dirk Gently's Holistic Detective Agency"
|
|
|
|
|
I'm using CreateRemoteThread to do some code injections:
taget.exe; load.exe(call CreateRemoteThread); code.dll
I want to use load.exe to call CreateRemoteThread, the thread function is RemoteThreadProc, then in RemoteThreadProc, load code.dll.
But now I have a problem of debugging. How can I see the code runing step by step in RemoteThreadProc()? I can't set a break point there! and then, now can I run the code step by step in code.dll?
|
|
|
|