|
In fact I was first thinking about ini files but this will be too much complicated and far too less secured (I don't want anybody to change parameters inside). Everything must be configurated inside the program.
Serialization, not because I want to have more access to what I'm doing and I'm not really saving 'pure data'. What I'm saving is configurations (but very complicated configurations ).
|
|
|
|
|
The idea you have is good, or else you can create a keyed file...
[object size][object type][object data]
Your file ends up looking like this sequence of data:
<dword><dword><datastructure><dword><dword><datastructure>
This allow you to add different structures into your file and to skip those you do not recognize.
Of course, you can not randomly seek into your file any more if you do this.
|
|
|
|
|
I've seen many ways to do this, not all are compatable. Some that I've seen:
Best: don't write out structs. Write XML or some other text format that is [partially] human readable.
Each struct starts with two fields, majic and version. magic is a number (often someone's birthday), choosen so that no two structers magics will ever be reused. Math people sometimes statisticly find some bit pattern that is unlikley to be hit randomly, so they can detect file corruption and the like.
#define MYSTRUCT_MAGIC 0x19540331 // mom's birthday
struct mystuct {
LONG magic;
LONG verion;
... // all data
}
When loading you check magic and version. If they are recognized you load, if the version is old you may reorginize things, and such.
It is a good idea to start your files with a simple string that says what recorded it.
save(struct myDataList *data) {
fd = open(...);
write(fd,"myApp Version 1.x",16);
... // write all the structs out here
}
I don't really like your idea. It doesn't deal with the case where you delete a member, or change the meaning of a member.
|
|
|
|
|
Henry miller wrote:
It is a good idea to start your files with a simple string that says what recorded it.
Yes I already thought about that (I will add this for future modifications ).
Henry miller wrote:
I don't really like your idea. It doesn't deal with the case where you delete a member, or change the meaning of a member.
Here this is not a problem because I won't delete any members. Everything will go in the other direction: add member but never delete or change existing memebers.
|
|
|
|
|
Yeah, thats what they all say. Then someday in the future someone does so anyway. It always happens that the things you least expect to happen are the ones that happen first.
Of course if this is a personal project that isn't much an issue. If this is any bigger though you have to expect that someone else will do something to your code without understanding why you didn't. They will notice that you always write a zero someplace, and never do anything with it so they remove it. And it works until someone trys to load data saved 3 versions ago which had the same size...
|
|
|
|
|
Ok, thanks to everybody for your advices. There are some good suggestions. And also that gave me good ideas for new projects (like saving in XML format)
|
|
|
|
|
i'm using visual c++ .net 2003 and already have some previous code which puts data into a UCHAR variable (dataBuffer[512]). then, what i want to do is pick out certain bytes and display them in a textbox. i'm able to take the bytes and display them to a textbox by using the ToString() method but the problem is that instead of the letter A, the number 65 is printed (instead of the character the ascii code is printed). need help on this...
|
|
|
|
|
I'm not sure, but how about using ToCharArray() instead? or putting the bytes in a 'string' first, then using ToCharArray()?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
my code goes a little something like this
UCHAR dataBuffer[512];
.
. //processes stuff and puts
. //data inside dataBuffer.
.
for (a=0;a<4;a++)
{
display->AppendText(dataBuffer[a].ToString());
}
. //display is the name of my textBox.
.
.
|
|
|
|
|
I'm using FindWindow(),(just testing some stuff), and it doesn't seem to work for some of the windows I'm trying to get pointers to. For instance, this doesn't seem to work:
CWnd* pButton = this->FindWindow("Button","start");
if(pButton)
{
pButton->SetWindowText("Finish");
AfxMessageBox("found window");
}
but it works for me changing the caption of "Visual FoxPro" to "Visual CrapPro". (I HATE FoxPro).
Does anyone know what I'm doing wrong?
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
Have you verified (using Spy++) that a window exists that has a "start" caption and belongs to the "Button" class?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Yes, I drag the 'Window Finder' utility icon onto the start button, and that's what I get. The 'start' is in quotes and the 'Button' classname is not, but both parameters in the FindWindow() are specified as taking strings, so I put quotes around the 'Button' parameter also. It still returns a NULL pointer.
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
After reading the documentation on the function more carefully, I found that FindWindow only works on parent windows. So this is what I did, and it works. First I used FindWindow() to find the start button's parent (Shell_TrayWnd), then used that window's hWnd as the parent hWnd for my call to FindWindowEx().
CWnd* pShell = FindWindow("Shell_TrayWnd",NULL);
if(!pShell)
return;
CWnd* pButton = this->FindWindowEx(pShell->m_hWnd,NULL,"Button","start");
if(pButton)
{
pButton->SetWindowText("Finish");
AfxMessageBox("found window");
}
If I write code in my sleep, does that make me brilliant, or just a lazy programmer?
My articles
www.stillwaterexpress.com
BlackDice - the programmer formerly known as bdiamond
|
|
|
|
|
I am binding a user with correct password to active directory(SSL enabled). The user's attribute “User Must Change password at next logon” is set (i.e.pwdLastSet=0).
lderr = ldap_bind_s(ld, (char *) (LPCTSTR) szPath,(char *) (LPCTSTR)
szPassword, LDAP_AUTH_NEGOTIATE);
ldap_get_lderrno(pld->m_pLdap, NULL, &szErrmsg);
I get:
1. lderr = 49
2. szErrmsg = "8009030C: LdapErr: DSID-0C0903E2, comment:
AcceptSecurityContext error, data 0, v893"
Problem :
The error message I got is same when I try to bind a user with wrong password and whose attribute pwdLastSet= -1.
How will I distinguish that user login is rejected due to bad password or pwdLastSet=0 ?
I am sure there is no problem with SSL or other AD configuration.
Please Help
|
|
|
|
|
I'am getting crazy.
I work with the CRecorset Class an Access.
Now I want to use MS SQL. New projects work fine, but if i use an older project, there will be a mistake as soon as i use addnew().
i does not matter if i use a snapshot or dynamic cursor.
what makes it worse: if i use the same crecordset-class in an old and a new project the new one will word, the old one not.
please help before i go nuts!!!!!!!
|
|
|
|
|
Does anyone know is there a testing tool available which could do the following:
While running the application (which is tested) in debug mode the tool collects coverage information which can be saved for later purposes. And here is the catch, it should be possible to compare two sets of coverage information and perform logical operations to them. This way I could for example find out which lines of code were performed in a given test run but not in another and vice versa. It would be nice if the tool had a visual interface which would highlight the differences in the test run coverages (bit like in WinDiff).
This kind of tool would be valuable in a situation where a certain way to perform an operation causes an error but another (alternative) way doesn't. With bigger systems it's quite hard to do this manually.
The tool should be usable with VC++ 6.0.
|
|
|
|
|
Hey,
How can i find the status of a thread ( still active or not ) using its handle which i started using AfxBeginthread
thanks
shiju
shijuck
|
|
|
|
|
Try this function ::GetExitCodeThread()
Chris Meech
I am Canadian. [heard in a local bar]
Gently arching his fishing rod back he moves the tip forward in a gentle arch releasing the line.... kersplunk [Doug Goulden]
|
|
|
|
|
can the current Platform DK be used with VC6? Any positive/negative experiences?
we are here to help each other get through this thing, whatever it is Vonnegut jr. boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I'm using it, and so far no problems. That's the Feb 2003 SDK.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
We use the latest SDK (downloaded from the MS site, rather than off the MSDN CDs), with VC6 SP6, and it all works fine.
|
|
|
|
|
|
Hi,
I am working with Serial communication in VC++. I have a message in this format:
Message: "0XD07889ABCDEF47". It is in hexadecimal format.
0XD0 - Header
7889ABCDEF - Data
47 - Checksum
I have to compute the checksum using the formula
(~((Header+Data) & 0X7F) & 0X7F))
What data type can I use to store the Message? How do I compute the checksum using C++ code?
I am new to this exercise.
Can anyone please guide me?
Thanks
Madhavi
|
|
|
|
|
I think an integer in the form \x0D0 should do the job.
EDIT:
Just checked it! Do it like that:
int whatever='\x20';
int whatever2='\x32';
whatever+=whatever2;
Check for (decimal) 82, and you see its correct!
DKT
|
|
|
|
|
Dear friends,
I placed an edit control on dialog, i want some text to be present in edit box by default, so in OnInitDialog(), i did something like this:
SetDlgItemText(ID_MYEIDT, "My sample text");
Now the problem is that when i run the application, the cursor is at the extreme left position of edit box. I want to place the cursor at the end of the written text. How can i do so ??
Imtiaz
|
|
|
|