|
He need ebooks or article and you gave him link that is not freeware and both link is helpful from my point of view.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
raju.k wrote: i dont know how to use API's .
So tell us what you do know. It really does you no good for us to suggest a book/site when it is potentially over your head.
Learning to program (in a procedural language) is one thing (e.g., concepts), while learning to program in C is simply learning a particular syntax.
"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
|
|
|
|
|
What do you need and what do you want to do exactly?
|
|
|
|
|
I need to output a group of curves (y(i,j) with the same x-axas x(i)). Each iteration, I need to write each column of y(i,j) into the same file like:
x(1) y(1,1) y(1,2) y(1,3)...
x(2) y(2,1) y(2,2) y(2,3)...
x(3) y(3,1) y(3,2) y(3,3)...
x(4) y(4,1) y(4,2) y(4,3)...
The length of each column may be different depending on a condition for termination of each iteration.
After each iteration, one column of y will be added.
Please help me on how to handling the file.
Thanks
|
|
|
|
|
See if this helps:
CStdioFile csf;
CFileException cfe;
CString str, sTemp;
CStringArray csa, csa2;
int iSize=0;
int n=3;
for(int i=1; i<=n; ++i)
{
sTemp.Format(_T(" (%d,%d)"),i,n);
csa2.Add(sTemp);
}
if ( !csf.Open(_T("E:\\Some.txt"), CFile::modeReadWrite, &cfe) )
{
AfxMessageBox(_T("Failed to open the file"));
return;
}
int iLoop = 0;
while(csf.ReadString(str))
{
str.Format(_T("%s%s"),str, csa2.GetAt(iLoop));
csa.Add(str);
++iLoop;
}
csf.SeekToBegin();
iSize = csa.GetSize();
for(int j=1; j<=iSize; ++j)
{
sTemp.Format(_T("%s\n"), csa.GetAt(j-1));
csf.WriteString(sTemp);
}
csf.Close();
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Rajesh,
Thank you very much for the help.
I am using the
CString file_now;
FILE *f_ptr1;
f_ptr1 = fopen(file_now,"r");
//
fprintf (f_ptr1, "%s\n", tittle);
fprintf (f_ptr1, "%i\n", n_monitor );
.....
.....
Do you think I can implement your above code in this FILE system ?
Thanks
|
|
|
|
|
Thanks. It seems to me that the above code is not dealing with different lengths of different different columns ??
Each time I need to write two columns of data of the same length, but next two columns may be of different length, e.g.
x1 y1 xx1 yy1
x2 y2 xx2 yy2
x3 y3 xx3 yy3
xx4 yy4
Each column of the data may have different lenthes.
If you can clarify further that would be great to me. Thanks.
modified on Monday, February 11, 2008 6:19 PM
|
|
|
|
|
mrby123 wrote: x1 y1 xx1 yy1
x2 y2 xx2 yy2
x3 y3 xx3 yy3
xx4 yy4
Look at the first for loop. Try modifying the line
sTemp.Format(_T(" (%d,%d)"),i,n); That's where the array element which fills the CStringArray is being built. Should be easy. Think about a solution and try. If you have a problem, write again.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
The following is what I tried, but not work.
x-xy[i], y_z[i] are two new columns to be appended to the previous file "some.txt".
n is the number of elements in a column.
Please correct my code. Thanks
-------------------------------------------------------------------------------------
//Create a CStringArray which would hold the new column to be added
for(i=0; i<n; ++i)
{
sTemp.Format(_T(" (%d,%d)"),x_xy[i],y_z[i]);
csa2.Add(sTemp);
//AfxMessageBox(sTemp);
}
if ( !csf.Open(_T("some.txt"), CFile::modeReadWrite, &cfe) )
{
AfxMessageBox(_T("Failed to open the file"));
return;
}
int iLoop = 0;
while(csf.ReadString(str))
{
str.Format(_T("%s,%s"),str, csa2.GetAt(iLoop));//Read each and every line in the file
csa.Add(str);//and append the new column to each line
++iLoop;//loop through each line
}
csf.SeekToBegin();
int iSize = csa2.GetSize();
for(int j=0; j<iSize; ++j)
{
sTemp.Format(_T("%s\n"), csa2.GetAt(j));
csf.WriteString(sTemp);//Finally write it to the file
}
csf.Close();
|
|
|
|
|
Hi,
Can anyone let me know how to identify whether an exe (which is not already running) is a service or non-service application?
I am writing a program which will run any application after getting a command.
I understand that if an application is a normal app.(non-service), I can start it using CreateProcess(). But if its a service I need to use OpenSCManager(), StartService() etc..
For this, i first need to know if an application is a service or not.
Please confirm my understanding and also how to identify if an application is service or not (when it is not running).
Thanks in advance,
Manasi
|
|
|
|
|
Manasi D wrote: But if its a service I need to use OpenSCManager(), StartService() etc..
I think u meant services already install in the Service control manager database.
If the service is already installed, u can query for the services installed using EnumServicesStatusEx and get the binary file name for the service using QueryServiceConfig and compare it. This is not an optimised solution
|
|
|
|
|
I used to use the LPT port in a program in Windows XP. In order to get access to the port, I used TotalIO.
Now I am using Windows Vista 32-bit, but I can't get TotalIO to work. It says the service is loaded successfully, but I still do not get access to the x86 assembly in and out instructions. I still get the priveledged instruction error. I have even tried running as Admininstrator with XP compatibility.
Has anyone had any success with getting port access in Vista that has any tips?
Please note: I want to avoid using inpout32.dll; although if it is the only option I will. The reason is, in my experience, TotalIO is MUCH MUCH faster than inpout32.dll.
modified on Thursday, February 7, 2008 9:03 PM
|
|
|
|
|
It seems strange that it worked on XP: the in and out instructions are privileged in XP too and so can only be executed from kernel mode (i.e. by drivers, for example.)
Steve
|
|
|
|
|
Stephen Hewitt wrote: It seems strange that it worked on XP: the in and out instructions are privileged in XP too
that is why he is using TOTALIO, a driver which changes the priviledge bit to give direct access to hw port to the application.
|
|
|
|
|
|
Stephen Hewitt wrote: I would assume the driver is not compatible with Vista,
I too.
|
|
|
|
|
Using such a driver is reckless, to say the least. It affects every process running on the system. This means that a badly written process (perhaps not even the one that installed the driver) can trash the system instead of just terminating with an exception, and Microsoft would probably cop the blame!
Steve
|
|
|
|
|
Stephen Hewitt wrote: and Microsoft would probably cop the blame!
How so?
If they would refrain from promising infinite compatibility, no one would come to blame them when there is none.
MacOS has changed its API (and broke compatibility) two times now.
Linux constantly changes its internal APIs and drop outdated ones (SysFS, still remembered?).
Yet both are on the rise, while MS declines...
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"
|
|
|
|
|
jhwurmbach wrote: How so?
Because in modern operating systems user programs can’t directly access the hardware of the machine, this is the job of a device driver. TOTALIO gives user programs access to the in and out instructions; any user program. This means that installing TOTALIO allows a badly written application to crash the whole system instead of just crashing itself. This is obviously the kind of thing that needs to be stopped. When a user’s computer blue screens Microsoft will cop the blame when the fault really lies with the software that installed TOTALIO.
Steve
|
|
|
|
|
Yes, obviously.
x87Bliss wrote: in my experience, TotalIO is MUCH MUCH faster than inpout32.dll.
I think this is because direct execution of instruction rather than deep path to kernel mode driver like inpout32.dll.
I would suggest that he can increase the performance by decreasing the number of calls through inpout32.dll (buffered commands), if the frequency of the call is high. inpout32.dll source is available for him to experiment on.
|
|
|
|
|
Thank you all for your info and security concerns. This is just a personal program, I am not designing it for public release. I only allow TotalIO to run during the timeframe that I need it. I will have to give GiveIO a try, since that should be much more secure, thanks for that tip. And Steve's info on the allowed port range also clears it up: "up to about 0xf00". As my LPT port is on port 0xCD00 - thanks to the add-on card. It's no wonder TotalIO "isn't doing it's job" if you will.
Again, thank you all. TotalIO's failure, and your comments, is like a wake-up call to stop doing the I/O the quick and dirty way.
|
|
|
|
|
|
I have a series of radioboxes (not grouped); and I can find out which one is selected by the ON_BN_CLICK, but exactly how do you uncheck that radio button? the MSND is confusing on that issue to me.
I need to be able to uncheck a user's prior selection. IDC_WORK_TYPE (radio button).
A C++ programming language novice, but striving to learn
|
|
|
|
|
non-MFC - send the BM_SETCHECK message with the state as BST_UNCHECKED
MFC - button.SetCheck (BST_UNCHECKED)
Judy
|
|
|
|
|
I would also look at CheckRadioButton. This is MFC and not-MFC.
After all, it's odd to have NO radio options selected. If that's really what you want, you can have a final radio option labelled (eg) "None". Otherwise, it will just get confusing.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|