|
Good to know! Thanks for the update!
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hi all,
I want to know that which is the better and faster way to access, read and write configuration settings: .ini files or windows registry. Speed matters much for me.
Please help me.
Anurag Gandhi.
|
|
|
|
|
Anurag Gandhi wrote: Speed matters much for me.
It sounds as though you need some other storage mechanism then. Neither INI files nor the registry are meant for heavy-duty (constant) access where speed is critical.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for reply.
But then, tell me the better way of storing the congiuration settings.
Thanking you in advance.
Anurag Gandhi.
|
|
|
|
|
Anurag Gandhi wrote: But then, tell me the better way of storing the congiuration settings.
By "congiuration settings," I assume you mean settings that are read once at program startup, and written once at program shutdown or via some Properties dialog?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Exactly.
Any idea about that? Which method is faster?
Anurag Gandhi.
|
|
|
|
|
Unless you have a gazillion settings, speed and performance is not really important for that.
Me think you need to spend your effort somewhere else.
|
|
|
|
|
Anurag Gandhi wrote: Any idea about that? Which method is faster?
No idea. It's never been important enough to matter. I would guess a difference of a few ms. Ini files are easier moved to other computers, whereas registry items can be secured. Speed would be the short pole in the tent.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
When I faced a similar problem a few years ago I went for a binary file with fixed size records. Essentially you lay out your configuration settings in a struct and then read and write them as a simple binary record to an offset in the file based on size * record_number. I needed multiple records that could be read and written simultaneously. I had multiple copies of the software sharing the file over a network so I also used partial file locking to lock the individual records to prevent corruption. It all depends what sort of configuration data you want to store.
Obviously this method doesn't lead to portable or human readable/editable config information. If this is important you could use an ini file read once on startup and written once on shutdown with the same data. This way you get configuration backup and crash corruption protection as well
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks Matthew.
It seems to be a good solution.
Anurag Gandhi.
|
|
|
|
|
Program settings should
0) Be user-specific
1) Should be saved in the registry if at all possible
2) and if #1 isn't possible, saved in a file in the user's appropriate application data sub-folder.
3) "Data" is not the same as "settings". "Settings" are rarely written, and typically only read at startup, eliminating the need for much more performance than we already get by reading/wqriting to the registry. "Data" on the other hand is read/written all the time, hence the need for better performance.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I'm looking for a VS2005 add-in to auto increment the build number each time I compile.
Anyone know of a working VS2005 add-in? What do you use/do to accomplish this task?
Patrick
|
|
|
|
|
Does this meet your needs?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Actually, I was able to get that mostly working, but had some problems.
First, it doesn't update the product number. I could probably fix that as he provides the source, but the second problem lead me to continue for more of an "add-in" solution.
The 2nd problem is that this results in a file that has the version set in the properties, but if you mouse over it, the hover text always says, 1.0.0.0. That would just confuse my users.
So, I'm searching for something someone has turned into a drop-in add-in, or something that doesn't have these issues.
Also, I prefer to have the .rc2 VERSIONINFO be the source, vs. another file, although that is really nothing, I can edit either easily.
Patrick
|
|
|
|
|
How can i convert a string ( "1234.5") as a double =1234.5
I know only to convert number to string
str.Format( _T ("%f") ,double );
how i do the reverse?
|
|
|
|
|
double atof( const char *string );
[edit]
I assume that the one who voted my post '1' is unfamiliar with the basic standard library functions in C/C++. atof() is declared in stdlib.h.
To get a double from a CString would look like this:
CString str = "12345.6";
double value = 0.;
value = atof( str ); Further information can be found here[^].
[/edit]
-- modified at 13:44 Thursday 31st May, 2007
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
|
Immunity18 wrote: PS. i didnt vote
Don't worry about it.
Regardless of who it was, it made me clarify my post in a way that I should have done from the start. :->
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
how can i convert CString variant to double like this?
i mean cut off the zero
example:
CString ---> double
1.020000 ---> 1.02
|
|
|
|
|
Can someone remind me what the required step is so that if you add in a header and source file from an article here to be included in your project (eg MFC dialog), you get the class members to pop up when you hit a "." or "->" operator on an object.
t.i.a
|
|
|
|
|
Nothing special is required. You may need to rebuild the .clw file, however.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
hmm, I tried this but no joy so far. I've added Cedric Moonens CCHartCtrl files to my project and make use of them on a dialog with a graph. I know it all works properly, but for example where I have
CChartSerie* pLineSerieCol = m_ChartCtrl.AddSerie(CChartSerie::stLineSerie);
pLineSerieCol->SetName("Energy Data");
pLineSerieCol->SetColor(0x00ff0000);
at the "->" it refuses to pop up the available methods of the class. I've manually deleted the .clw file, tried rebuild all and also opened class wizard with the clw file missing to force it to rebuild and checked that the source files are all included, but no joy as yet.
I wonder if it is humanly possible to feel more like a muppet than I do today
|
|
|
|
|
ldsdbomber wrote: ...at the "->" it refuses to pop up the available methods of the class.
I've had this happen in a few instances where the method that I was currently in had not yet been added to the class. For example:
void MyClass:DoSomething( void )
{
CChartSerie* pLineSerieCol = m_ChartCtrl.AddSerie(CChartSerie::stLineSerie);
pLineSerieCol->SetName("Energy Data");
pLineSerieCol->SetColor(0x00ff0000);
} If the DoSomething() method had not yet been added to MyClass , then Intellisense would fail to work. This does not appear to be the case with you however.
ldsdbomber wrote: I wonder if it is humanly possible to feel more like a muppet than I do today
Only if you are you sprouting fur in odd places.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
It's not easy being green.....
A small tribute to Jim Hanson who made us happy without computers, cell phones and other gizmos.
|
|
|
|