Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting a "time_t" character to an int, char *

Status
Not open for further replies.

Guest_imported

New member
Joined
Jan 1, 1970
Messages
0
Hi:

Is there a way to convert from a time format to an int, double or a char*?

Like:

time_t t1;
time(&t1);

char timeToday = (char *)t1 // which gives error ofcourse


Any suggestion will be appreciated!
 
Also is there a was to get the current date into a single variable and add say 7 or 30 days to it. Any add function with Date in visual c++? ..... Thanx much.
 
If you want to add/subtract something to/from a time variable have a look at CTime and CTimeSpan (MFC classes).

/JOlesen
 
I figured the time add+ sub part. thank you for the suggestion though.

Antoher Question: I am trying to write that value to a registry and then re-read it. But I always get a ZERO read in even when the value in registry is NOT ZERO. (and this is to save the time in registry). Any ideas? Thank you.

here's my code to read in from the registry.... by the way it does work if I read in a LPCSTR type. but that doesn't work for date????

char defvalue[1024];
HKEY hkey2;
HKEY hkey1 = HKEY_CURRENT_USER;
LPCTSTR lpSubKey1 = "Software\\Testing";

error_value = RegOpenKeyEx( hkey1, lpSubKey1, 0, KEY_READ, &hkey2 );

ret_Val = RegQueryValueEx(hkey2, keyname , NULL,
&Type, (LPBYTE)&defvalue,
&size1);

 
I figured the time add+ sub part. thank you for the suggestion though.

Antoher Question: I am trying to write that value to a registry and then re-read it. But I always get a ZERO read in even when the value in registry is NOT ZERO. (and this is to save the time in registry). Any ideas? Thank you.

here's my code to read in from the registry.... by the way it does work if I read in a LPCSTR type. but that doesn't work for date????

char defvalue[1024];
HKEY hkey2;
HKEY hkey1 = HKEY_CURRENT_USER;
LPCTSTR lpSubKey1 = "Software\\Testing";

error_value = RegOpenKeyEx( hkey1, lpSubKey1, 0, KEY_READ, &hkey2 );

ret_Val = RegQueryValueEx(hkey2, keyname , NULL,
&Type, (LPBYTE)&defvalue,
&size1);

 
I figured the time add+ sub part. thank you for the suggestion though.

Antoher Question: I am trying to write that value to a registry and then re-read it. But I always get a ZERO read in even when the value in registry is NOT ZERO. (and this is to save the time in registry). Any ideas? Thank you.

here's my code to read in from the registry.... by the way it does work if I read in a LPCSTR type. but that doesn't work for date????

char defvalue[1024];
HKEY hkey2;
HKEY hkey1 = HKEY_CURRENT_USER;
LPCTSTR lpSubKey1 = "Software\\Testing";

error_value = RegOpenKeyEx( hkey1, lpSubKey1, 0, KEY_READ, &hkey2 );

ret_Val = RegQueryValueEx(hkey2, keyname , NULL,
&Type, (LPBYTE)&defvalue,
&size1);

 
I figured the time add+ sub part. thank you for the suggestion though.

Antoher Question: I am trying to write that value to a registry and then re-read it. But I always get a ZERO read in even when the value in registry is NOT ZERO. (and this is to save the time in registry). Any ideas? Thank you.

here's my code to read in from the registry.... by the way it does work if I read in a LPCSTR type. but that doesn't work for date????

char defvalue[1024];
HKEY hkey2;
HKEY hkey1 = HKEY_CURRENT_USER;
LPCTSTR lpSubKey1 = "Software\\Testing";

error_value = RegOpenKeyEx( hkey1, lpSubKey1, 0, KEY_READ, &hkey2 );

ret_Val = RegQueryValueEx(hkey2, keyname , NULL,
&Type, (LPBYTE)&defvalue,
&size1);

 
sorry for the muliple posting ..... dunno what happens .... it seemed like it froze on me and then I see 4 postings.
 
sorry for the muliple posting ..... dunno what happens .... it seemed like it froze on me and then I see 4 postings.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top