Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Datediff function on Message box to mention how much days left for Olympic
Posted

I don't think that C++ offers this feature, you will need to use one or more of the Time Management[^] functions. You should also consider upgrading from VC++ 6 to 2010.
 
Share this answer
 
This is not a question, it's a random collection of words. There are many date formats in C++, and all have methods to calculate the difference between two dates. Hard to say more, based on this snippet.
 
Share this answer
 
Comments
Vijay Pate 27-Jul-11 10:21am    
It has been 10 years and lost touch withVC++ 6.0
Christian Graus 27-Jul-11 10:28am    
Richard is right, you should update, except from VC6, there's a good chance your code won't compile. You still didn't tell us how you're getting the date, in what format.
Vijay Pate 27-Jul-11 10:34am    
any solution on line to find out "How much time remains" in Message box
Vijay Pate 29-Sep-11 9:20am    
I am working on project require to get TIME DIFFERENT between two dates. I have software will expire in 30 days and I need to show on messagebox that end user has 30 days to 29 days and son as day passes. I have worked on following code to justify my work.

I also need to register this software with install date which will use as startDate and end date is 30 days which will give me SPANDATE any idea;

COleDateTimeSpan as follow:First Sets of code is for TIMESPAN:

COleDateTime timeStart; COleDateTime timeEnd;

COleDateTimeSpan timePassed;int daysLeft = 3;

timeStart = COleDateTime::GetCurrentTime(); // Date and time of the installation.

timeEnd = COleDateTime::GetCurrentTime();

timePassed = COleDateTime::GetCurrentTime() - timeStart;

daysLeft = 30 - static_cast<int>(timePassed.GetTotalDays());CString strMessage;

if (daysLeft > 3 && daysLeft <=3){

strMessage.Format("ADDapt was not activated within 30 days of \n"

"installation and currently not function. \n"

"To activate, please call Avtron Field Service \n""at 226-542-1230 ext 1214.\n"

"The %d" " days trial period started on the day you installed ADapt.\n"

"Do you want to Proceed?", daysLeft);}// AfxMessageBox(strMessage);else {

strMessage.Format(_T("ADDapt is operating under a trial license. \n")

_T("You have %d" " days to activate ADDapt with valid license.\n")

_T("To activate, Please call Avtron Field Service at 226-542-1230 ext 1214. \n")

_T("Do you want to Proceed?"), daysLeft);/*

strMessage("You have 00%d" " days to activate ADDapt with valid license.", daysLeft);

*/}AfxMessageBox(strMessage, MB_OKCANCEL);

2nd sets of code is for registry entry but it is not working in VC++ 6.0 environment but it is working in VC++ version VS2010

using namespace System;using namespace System::Security::Permissions;

using namespace Microsoft::Win32;int main(){

// Create a subkey named Test9999 under HKEY_CURRENT_USER.

RegistryKey ^ test9999 = Registry::CurrentUser->CreateSubKey( "Test9999" );

// Create two subkeys under HKEY_CURRENT_USER\Test9999.

test9999->CreateSubKey( "TestName" )->Close();

RegistryKey ^ testSettings = test9999->CreateSubKey( "TestSettings" );

// Create data for the TestSettings subkey.

testSettings->SetValue( "Language", "French" );

testSettings->SetValue( "Level", "Intermediate" );

testSettings->SetValue( "ID", 123 ); testSettings->Close();

// Print the information from the Test9999 subkey.

Console::WriteLine( "There are {0} subkeys under Test9999.", test9999->SubKeyCount.ToString() );

array<string^>^subKeyNames = test9999->GetSubKeyNames();

for ( int i = 0; i < subKeyNames->Length; i++ ) {

RegistryKey ^ tempKey = test9999->OpenSubKey( subKeyNames[ i ] );

Console::WriteLine( "\nThere are {0} values for {1}.", tempKey->ValueCount.ToString(), tempKey->Name );

array<string^>^valueNames = tempKey->GetValueNames();

for ( int j = 0; j < valueNames->Length; j++ ) {

Console::WriteLine( "{0,-8}: {1}", valueNames[ j ], tempKey->GetValue( valueNames[ j ] )->ToString() );

} } // Delete the ID value.

testSettings = test9999->OpenSubKey( "TestSettings", true );

testSettings->DeleteValue( "id" ); // Verify the deletion.

Console::WriteLine( dynamic_cast<string^>(testSettings->GetValue( "id", "ID not found." )) );

testSettings->Close(); // Delete or close the new subkey.

Console::Write( "\nDelete newly created registry key? (Y/N) " );

if ( Char::ToUpper( Convert::ToChar( Console::Read() ) ) == 'Y' ) {

Registry::CurrentUser->DeleteSubKeyTree( "Test9999" );

Console::WriteLine( "\nRegistry key {0} deleted.", test9999->Name );

} else {

Console::WriteLine( "\nRegistry key {0} closed.", test9999->ToString() );

test9999->Close(); }}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900