The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
listen go to bios setting and there is a hardware password option select it and then give the password which u feel like and save and exit . The next time you boot in first u will have to enter password and your windows will boot.try it i have done it
I have a structure, suppose USER_INFO. When my program starts it serializes this structure from an archive file. My program uses these values, modifies few of them and when my program exists it serializes all values to that file again which it can read again on next start up. This way I stores the state of the application.
Now the problem is that when I add a new field (or structure member variable) to structure. It can not read the old values from the file because structure size is now changed. I want a solution to overcome this problem. Currently an alternative way which I am using is introducing a new structure, read the old data in old structure, copy old data from old structure to new structure and write the new structure to the file. But it is not a good solution. Can Sqlite db give a better solution because adding a new filed in db is not a big problem?
Looks like it can be helpful. I can specify schema version in that and at them time of reading I can check for the schema version. However I was storing whole cmap<cstring, structure=""> into file. I am not using << or >> operators to read and write each element one by one. So using schema version I can detect version but still I need to create another structure to load new schema version data while old schema data can be loaded into old structure. I want a solution in which I can read old schema data into new structures. So that I don't have to keep both structure versions in code. It should eliminate copying from one structure(old structure) to another structure(new structure).
The only problem I see is the non-portability of writing the structure to the file instead of individual items. That is compiler structure [type] alignment dependent and may change from one compiler to the next or one version of the compiler to the next.
Your solution sounds like a simple application of the KISS principle and avoids the problems of more complex solutions. Just add a header of some kind to the file. The header should contain an identifier, marking the file as the correct type, and a version number indicating the format type (a.k.a. data type [structure type]). This also has the advantage of being cross-language and cross-platform supportable.
It sounds like all the data is read into memory at start up. In that case you only need one method (function) to read the file and convert it to the internal data structure at start up and one for writing it (if it has changed) out when shutting down.
I used the above method in a commercial application (originally written in C) that supports file formats going back over 20 years. This is comparable to reading and writing Word or other document types that contain version specific format support.
"Program testing can be used to show the presence of bugs, but never to show their absence." - Edsger Dijkstra
"I have never been lost, but I will admit to being confused for several weeks. " - Daniel Boone
Hi, I have been looking for the answer to this for a long time using google and everything.
I may have found some postings, but those didn't fully help me to understand this.
So I checked CStringT and CSimpleStringT, and what I found is that there is only this, "operator PCXSTR()"
This seems to say that CString, which is simply CSTringT<TCHAR>, can be converted ONLY to PCXSTR.
Because I use the AfxGetMainWnd but AfxGetMainWnd() to get CMainFrame, when compiling no error show. When running, I found that that m_hwnd of (CMainFrame*)AfxGetMainWnd is 0x00000000, I think that if the compiler can give a exception when compiling, it can save much time for me .
As you can see here[^] AfxGetMainWnd() returns a CWnd* i.e. a pointer to a CWnd object. In your call you actually want a pointer to your CMainFrame object, so you have to use the cast to let the compiler know that the return value will actually be a pointer to a different object type than described in the function definition. Remember also that you can only cast to an object that derives from the original, and since CMainFrame derives from CWnd this will work OK.
You are using a C style typecast here. By doing so you tell the compiler taht YOU know that the variable you're casting is in truth of the type you are casting to. The compiler will therefore ignore any other information and believe you.
The compiler is simply doing what you tell it: ignore the stupidity of the cast.
Maybe you can take one lesson from this: never use C-Style type casts. They are almost always an error!
Check out GotW # 17 to learn more about type casts and how (not) to use them.