|
Are you opening the file each time you write to it? If so, you might consider keeping the file open for the duration of the whole scanning process. This should speed your app up by orders of magnitude.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
If your opening the file each time then that woudl slow it down. Just open at the begining of your app and close at the bottom.
ofstream outFile("estimated.txt");
and then close it
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
yes.. i do open the file very top and close it after tree travesal, and calculation for all has finished.
but thanks i have another file which is getting the size of the file open and close for each file. i will put that into array and read it from array. hope that will speed my estimate page function.
thanks guys
|
|
|
|
|
Win wrote:
i will put that into array and read it from array. hope that will speed my estimate page function.
Try using a vector... itmight work quicker than an array. Especially if your filling it with lots of info... and it's dynamic too [and genreic]
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
oh.. i was trying to use it.. can you check my post which way is better.. no. let me post it back here again.
i have a structure, call
<br />
struct FileType<br />
{<br />
char type[_MAX_EXT];<br />
char size[20];<br />
<br />
};<br />
<br />
and the text file that looks like
.txt 4140
.tif 4100
.doc 21000
.pdf 3459
.
.
.
so i want to read from the text file and put it into array.
so used vector.
<br />
#include <vector><br />
typedef vector<TypeSize> typeNsize;<br />
<br />
TypeSize typeNsize;<br />
<br />
ifstream filelist("TableOfType.txt",ios::in);
while(!filelist.eof())<br />
{<br />
filelist>>typeNsize.filetype>>typeNsize.size;<br />
<br />
}<br />
filelist.close();<br />
my application is dialog base.
and i have following errors
<br />
<br />
SMPprojectDlg.cpp<br />
E:\SMP\SMPprojectDlg.cpp(2161) : error C2143: syntax error : missing ';' before '<'<br />
E:\SMP\SMPprojectDlg.cpp(2161) : error C2143: syntax error : missing ';' before '<'<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2065: 'TypeSize' : undeclared identifier<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2146: syntax error : missing ';' before identifier 'typeNsize'<br />
E:\SMP\SMPprojectDlg.cpp(2163) : error C2065: 'typeNsize' : undeclared identifier<br />
E:\SMP\SMPprojectDlg.cpp(2168) : error C2228: left of '.filetype' must have class/struct/union type<br />
E:\SMP\SMPprojectDlg.cpp(2168) : error C2228: left of '.size' must have class/struct/union type<br />
Error executing cl.exe.<br />
<br />
SMPproject.exe - 7 error(s), 0 warning(s)<br />
i was thinking to use CStringArray like read the sentence like
<br />
char info[50];<br />
filelist.getline(info,50,'\n');<br />
CString infoline = (const char*)info;<br />
CStringArray array;<br />
array.add(infoline)<br />
if i do so , i have to separate the string into two parts, type and size, again. i dont' want to do that..
do you have any idea better than what i have right now?
|
|
|
|
|
Try this
================================================
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
/*
Other code here
*/
struct FileType
{
char type[_MAX_EXT];
char size[20];
};
/*
other code here
*/
vector<FileType> v_filetypes;
ifstream filelist("TableOfType.txt", ios::in); //ios:in is optional
while(!filelist.eof())
{
filelist >> v_filetypes.type >> v_filetypes.size;
}
filelist.close();
================================================
That should work fine... I think.. but my brain isn't working the best
|
|
|
|
|
wow!!!
i use cstringarray to store files types and sizes
as follow:
<br />
char info[50];<br />
CStringArray array;<br />
ofstrea filelsit.open("type.txt");<br />
while(!filelist.eof())<br />
{<br />
filelist.getline(info,50,'\n');<br />
CString infoline = (const char*)info;<br />
array.add(infoline)<br />
}<br />
guess what it only tooks 16 sec to read and estimate page to print for all 350000 files.
compare to old function, way way faster. old function took 10 mins and now only 16 sec.
i say WOW
let me try to use vector.. i think vector might be faster because i dont' have to separator type and size again.
|
|
|
|
|
Win wrote:
way way faster. old function took 10 mins and now only 16 sec
I'd say thats a good improvement!!!
"When a friend hurts us, we should write it down in the sand, where the winds of forgiveness get in charge of erasing it away, and when something great happens, we should engrave it in the stone of the memory of the heart, where no wind can erase it"
Nish on life [methinks]
|
|
|
|
|
|
Since a process can have multiple heaps, load DLL's at rather high addresses (eg kernel32.dll is loaded somewhere at 0x77xxxxxx IIRC) I think it's a rather unusable piece of information.
If you on the other hand was interested in what address (and with what length) a PE was mapped at you can use VirtualQuery(). To see what heaps a process has (and how large they are ...) you can use GetProcessHeaps() + HeapWalk().
|
|
|
|
|
Hi.
I would like to limit the number of characters a user make enter at any given time to a finite integer. For example, let say I have an edit box in a dialog box for entering zip code. I would like to limit the number of characters to *exactly five*.
I have tried using DDV verification feature in a dialog box. However, I found that the user can overflow the edit box. For example:
limit: 500
User: 500000
If the user overflow the edit box, for DDV will consider the data entered as being valid. I believe the problem has something to do with overflowing a datatype.
Nonetheless, what is the best way to limit the number of characters/digits entered in an edit box?
Thanks,
Kuphryn
|
|
|
|
|
Have a look at Alvaro Mendez' article Validating Edit Controls. He provides several CEdit -derived controls for limitting user input --I guess they can serve your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
You just go to ClassWizard, go to member variables sheet,
you can see at the bottom of sheet, there is a property:
Maximum character !!!!!!!
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
|
Look up the CEdit::SetLimitText function
Michael
Errata 1: p. 154, section 'Defusing'. For 'red wire' read 'blue wire'.
|
|
|
|
|
Okay.
The solution is to use a CString variable holding the value of the edit box. I am referring to the example of the five digit zip code. For example, lets consider that the variable is an int. If the variable is declared as an int, there will be an overflow if the user enters 99999999999999. The solution I came up with is to define it as a CString. Here is the verification part.
-----
void CMyDlg::OnEnChangeMyEditBox()
{
UpdateData(TRUE);
// the length must be exactly five
// the value must be between 10000 and 91000
if (m_EditPortListen.GetLength() == 5 &&
atoi(static_cast<lpctstr>(m_MyEditBox)) >= 10000 &&
atoi(static_cast<lpctstr>(m_MyEditBox)) <= 91000)
SetModified(TRUE);
else
{
m_MyEditBox.Format("%d", 10000);
UpdateData(FALSE);
SetModified(FALSE);
}
}
-----
The code above works well.
Kuphryn
|
|
|
|
|
Any code to deal these answers:
-Set Editbox or Listcontrol's font to Unicode ?
-UpdateData() to get some string in Editbox and ListControl to a CString var ?
-Compare 2 CString vars containing Unicode string ?
Thanks.
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
If you want to create a UNICODE version of a control, you will need to user CreateWindowW instead of the plain CreateWindow which is converted by the preprocessor to a CreateWindowA call if you are using ansi.
You will then have a window that can handle UNICODE fonts, however, if you want to load a font from a different locality you will have other issues to work through. If this is what you want post another question and I will try to help you.
If you are not compiling your application in UNICODE, then you will be out of luck getting UNICODE data into a CString unless you have version 7.0 of the CString class. All versions prior to 7.0 compile with either chars or wchar_t, but you can not use both at the same time. Version 7.0 parameterizes the string and allows you to define the type that you want to create.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
How can I get coordinates of the current character (in current line) in a rich edit control ?
I'm tired with LineIndex, LineCount, GetCharPos, Get...get..
but cannot find solution.
Hung Son
A Vietnamese student
i-g.hypermart.net
dlhson2001@yahoo.com
|
|
|
|
|
Make sure you are using the correct version of richedit control. Version 1 does not support the character position functions. Use version 2 or above. It should be defined in one of your header files.
|
|
|
|
|
Hi all,
I searching the code for retrieve the data traffic of a computer(of a local network) using IP address, anyone could help me?!
I find the code for retieve computer name and ip address and now i would retrieve the traffic.
Thanks and sorry for may terrible english.
Ciao!
|
|
|
|
|
I don' tknow if this is more than you need, but try looking up Layered Service Providers for winsock 2.0.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
But is not possible retrieve information about traffic using function like Ping?! I try to create a program like a sniffer but I don't want to retrieve data but only the quantity of data that transit on a IP address, only the traffic.
|
|
|
|
|
I'm trying to make a simple menu, with a Listbox and a butten..
The Listbox will contain a lists of programs, and the button will execute the program selected on the list box..
I created a simple Dialog base App(no mfc)
But I can figure out how to input data in the list box..
Like.
LIST_GAMES
----------
Quake
DOOM
Half-Life
How to do this ?
Thanks
|
|
|
|
|
For add a string into ListBox try:
ListBox.InsertItem(0,"you string");
If you want scan a directory, find files and add this in the ListBox:
CFileFind finder;
BOOL bWorking;
CString fullpath;
strPath = strPath + "*.*";
bWorking = finder.FindFile(strPath);
while (bWorking)
{
bWorking = finder.FindNextFile();
if ( !finder.IsDirectory())
{
CTime FileTime;
CString strFileName,strFileTime;
strFileName = fullpath+finder.GetFileName();
finder.GetLastWriteTime(FileTime);
strFileTime = FileTime.Format("%Y/%m/%d %H.%M");
SHFILEINFO shinfo;
SHGetFileInfo( strFileName,
0,
&shinfo,
sizeof( shinfo ),
SHGFI_ICON |
SHGFI_SMALLICON );
int j = InsertItem(0,finder.GetFileName());
SetItemText (j,1,strFileTime); //2nd column
}
} //end while
|
|
|
|