|
There is a service pack available, and the comments below concerning COledateTime are no longer completely correct, but there are issues that we encountered that everyone should be aware of.
If you use any CRT functions, be prepared to see dozens - if not hundreds or thousands - of warnings regarding deprecated code. The easy fix is to add a compiler definition (_CRT_SECURE_NO_DEPRECATE) to your project settings, and that will address almost all of those. The hard fix is to actually replace all of those deprecated function calls to the secure versions. This will take a lot longer than a simple compiler directive.
VS2005 also flags other things that VC6 ignores, such as const definitions that don't have a specified type. VC65 defaulted such items to int , but VS2005 throws up a warning about it.
Another bugaboo is handling of for loops. The loop control variable is scoped more tightly (and according to the ANSII standard) so that you are required to re-declare the variable for each for loop. So, this:
for (int i = 0; i < 5; i++)
{
}
for (i = 0; i < 5; i++)
{
}
will generate and compile error. You need to do it this way:
for (int i = 0; i < 5; i++)
{
}
for (int i = 0; i < 5; i++)
{
}
or this way:
int i;
for (i = 0; i < 5; i++)
{
}
for (i = 0; i < 5; i++)
{
}
There are MANY changes to MFC. The most damaging involves COleDateTime. It seems MS decided that a m_dt value of 0.0 (12/31/1899) is now COleDateTime::invalid, despite the fact that COleDateTime supports dates all the way back to 12/31/100 (generates a negative value for m_dt). What a pain in the ass.
There are also many deprecated functions, and the compiler doesn't like some ported message handling code due to its more strict type compliance.
The IDE is NOT friendly to unmanaged C++/MFC programmers. In a word, it SUCKS.
In closing, I think the compiler helps you to fix things in your code that would never have been found with VC6. There are now "secure" versions of most of the CRT string-related functions that help to prevent buffer overflows. I think it's a good idea to port to VS2005 because you should always use the latest tools when developing apps. Make double-damn sure you regression test EVERYTHING, *especially* if it involves date handling, and before porting, install the service pack so you only have to deal with date problems one time.
"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
|
|
|
|
|
|
John Simmons / outlaw programmer wrote: There are MANY changes to MFC. The most damaging involves COleDateTime. It seems MS decided that a m_dt value of 0.0 (12/31/1899) is now COleDateTime::invalid, despite the fact that COleDateTime supports dates all the way back to 12/31/100 (generates a negative value for m_dt). What a pain in the ass.
This has been fixed.
"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
|
|
|
|
|
As noted at the very top of my original post.
BTW, directly setting the member variables in COleDateTime can really hose up your code. Unfortunately, the guy that wrote our code didn't realize it, so now we have dates that have a valid m_dt value, but the status is sometimes null, or invalid. This will throw asserts in the COleDateTime class every time you try to use a date that is null or invalid (because instead of setting/getting the value through the accessor functions, he checked the value of m_dt to indicate validity. I'm in the process of evaluating each date reference in a 300,000 line project (and there's a LOT of date references) because of this issue.
This is my hell.
"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
|
|
|
|
|
John Simmons / outlaw programmer wrote: This is my hell.
Still there. huh?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
It's an even bigger hell than you might imagine. :/
I'm compiling in a VM under Virtual PC2007 and using sourceoffsite to do check-ins/outs on the desktop, transferring the files into the vm and back out (it won't compile if you use a shared drive). VPN from a DOD network is involved too.
"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
|
|
|
|
|
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Exactly - I'm gonna update my monster.com profile this weekend.
"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
|
|
|
|
|
Hi All,
I have an application which is running as service.
I have written the code for starting service ,where i have used APIs like OpenSCManager ,OpenService and StartService ,with error handling.
For stopping the service also i used ControlService API and programatically there is no wrong.
When i am toggling between Start and Stop. On Stop it is crashing.
Any Suggestions... ??
Thanks in advance.
Appu..
"My blood group is not B+.But I have it my blood"
|
|
|
|
|
What's crashing? Your service control app or the service itself?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
My Service is crashing.
Appu..
"My blood group is not B+.But I have it my blood"
|
|
|
|
|
Have you debugged it? Use "Debug/Processes..." in visual studio to attach to the running
service. Then toggle the service state and when it crashes you'll be able to trace the problem
in the debugger.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I have added a small Sleep in stop.
Now it is working fine.
Thanks.
Appu..
"My blood group is not B+.But I have it my blood"
|
|
|
|
|
I used CreateFile() API to open a hard drive in raw format. But it failed. What are the correct parameters for the API ? Please help me.
|
|
|
|
|
Srinivas Kaparthi wrote: to open a hard drive in raw format
What do you mean opening a hard-drive ? You mean opening a file, right ? And what is raw format ? Binary mode ?
Srinivas Kaparthi wrote: But it failed
What failed ? What happened exactly ? It crashed, it didn't compile, ... ? What messages did you get ? What did you expect and what happened ?
And also, post the code you use to open the file.
|
|
|
|
|
Hello,
Thank you for your reply.
Opening a hard drive does not mean opening a file.
raw format means the complete disk/partition is treated as a single file. By opening in raw format, we can read sectors directly. This method is called raw IO. This is also called as Direct Disk/Drive Access. Please refer to the Kakan's reply for my problem. It is working fine.
|
|
|
|
|
Nice, I learned something today
I didn't know that we could open the disk in raw format. Thanks for the tip
|
|
|
|
|
Yes, it's possible to open either a partition or a physical disk (including the partition table). And modify (with the correct access rights of course).
So we got all possibilities to mess things up!
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
I use this code.
Beware, it's C and not unicode compliant. Adjust it if you want to.
m_UseDrive is the drive letter to open, i.e: 'C'
sprintf(Drive,"\\\\.\\%c:", m_UseDrive);
hDrive = CreateFile(Drive, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
But when you read from it, you MUST use a multiple of the sector size. Else, the read will fail. The same goes for seeking.
You can find out the sector size by a DeviceIoControl-call, and get the disk geometry. (Search for documentation of the DISK_GEOMETRY struct).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
I used a dialog based application. For OK Button click handler I wrote the following code as suggested by you. But I could not succeed. Is it that Administrator login is essential? What is meant by UNICODE complianr?
<br />
char Drive[20] , m_UseDrive = 'C' ;<br />
HANDLE hDrive ;<br />
<br />
<br />
sprintf(Drive,"\\\\.\\%c:", m_UseDrive);<br />
hDrive = CreateFile(Drive, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);<br />
if(hDrive == INVALID_HANDLE_VALUE)<br />
AfxMessageBox("Succeeded") ;<br />
else<br />
AfxMessageBox("Drive could not be opened") ;
|
|
|
|
|
Hello.
I always use the "disclaimer" about my source code not beeing Unicode compliant, and has C syntax.
In the past, I've been flamed a number of times, by people who were complaining about my source code. Nowadays, I always use that statement.
About your code example: You have switched your test/texts, so if you get "Drive could not be opened", all is fine, and the drive is open for use!
Just remember, all operations must be done on an even multiplier of the sector size (since a complete sector is the smallest amount that the drive can handle. It's ususally 512 bytes, but can differ).
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
Thanks a lot!
|
|
|
|
|
Under Windows 98, it fails. Is there any solution?
|
|
|
|
|
Hello.
I haven't used that code under "DOS"-Windows (95,98,Me), but as far as I know, it should work.
According to MS, there shouldn't be any limitations for 98/Me, see here[^]
Maybe you should try to change GENERIC_READ | GENERIC_WRITE to just GENERIC_READ.
Or changing FILE_SHARE_READ | FILE_SHARE_WRITE
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
|