|
MSDN says:
//-----------------------------------
SystemTimeToTzSpecificLocalTime
The SystemTimeToTzSpecificLocalTime function converts a Coordinated Universal Time (UTC) to a specified time zone's corresponding local time.
//-----------------------------------
Now I need an inverse function of above, which can convert local time to UTC time.
Is there a function to do that?
modified on Tuesday, June 23, 2009 3:52 AM
|
|
|
|
|
|
many our clients are still using win2k, so I have to make it work on Win2k.
|
|
|
|
|
Well - all TzSpecificLocalTimeToSystemTime is going to do is offset the time by the time offset implied by the timezone you pass into it. So, you just need to do the same.
If you would be passing a null time-zone into that function, then you can do what it does and retrieve the current time zone information using GetTimeZoneInformation[^]. That gives you the current time-zone information, including the biases to be applied to UTC to get local time (or vice versa!). So, all you have to do is work out how to add the suitable number of minutes to your local timke - I'd probably convert the SYSTEMTIME to a FILETIME, do the time biassing and then convert the FILETIME back to a SYSTEMTIME.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
TzSpecificLocalTimeToSystemTime function requires XP, not for Win2k.
I have created 2 functions and solved the problem, the 2 are:
void GreenwichTimeToLocalTime(const SYSTEMTIME&tmSys,SYSTEMTIME&tmLocal)
{
SYSTEMTIME tmS,tmL;
::GetSystemTime(&tmS);
::GetLocalTime(&tmL);
FILETIME ftS,ftL;
::SystemTimeToFileTime(&tmS,&ftS);
::SystemTimeToFileTime(&tmL,&ftL);
ULARGE_INTEGER ulS,ulL;
ulS.HighPart=ftS.dwHighDateTime;
ulS.LowPart =ftS.dwLowDateTime;
ulL.HighPart=ftL.dwHighDateTime;
ulL.LowPart =ftL.dwLowDateTime;
__int64 i64=ulL.QuadPart-ulS.QuadPart;
FILETIME ftSys;
::SystemTimeToFileTime(&tmSys,&ftSys);
ULARGE_INTEGER ulSys;
ulSys.HighPart =ftSys.dwHighDateTime;
ulSys.LowPart =ftSys.dwLowDateTime;
ulSys.QuadPart+=i64;
FILETIME ftLocal;
ftLocal.dwHighDateTime =ulSys.HighPart;
ftLocal.dwLowDateTime =ulSys.LowPart;
::FileTimeToSystemTime(&ftLocal,&tmLocal);
}
void LocalTimeToGreenwichTime(const SYSTEMTIME&tmLocal,SYSTEMTIME&tmUTC)
{
SYSTEMTIME tmS,tmL;
::GetSystemTime(&tmS);
::GetLocalTime(&tmL);
FILETIME ftS,ftL;
::SystemTimeToFileTime(&tmS,&ftS);
::SystemTimeToFileTime(&tmL,&ftL);
ULARGE_INTEGER ulS,ulL;
ulS.HighPart=ftS.dwHighDateTime;
ulS.LowPart =ftS.dwLowDateTime;
ulL.HighPart=ftL.dwHighDateTime;
ulL.LowPart =ftL.dwLowDateTime;
__int64 i64=ulL.QuadPart-ulS.QuadPart;
FILETIME ftLocal;
::SystemTimeToFileTime(&tmLocal,&ftLocal);
ULARGE_INTEGER ulLocal;
ulLocal.HighPart=ftLocal.dwHighDateTime;
ulLocal.LowPart =ftLocal.dwLowDateTime;
ulLocal.QuadPart-=i64;
FILETIME ftUTC;
ftUTC.dwHighDateTime=ulLocal.HighPart;
ftUTC.dwLowDateTime =ulLocal.LowPart;
::FileTimeToSystemTime(&ftUTC,&tmUTC);
}
|
|
|
|
|
You didn't really read my answer, did you. I told you that you could get the required time zone offset by using GetTimeZoneInformation (which is available on Windows 2000) and then emulate TzSpecificLocalTimeToSystemTime.
Never mind.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You could just copy the wine implimentation:
http://source.winehq.org/source/dlls/kernel32/time.c[^]
...cmk
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
|
|
|
|
|
Hi all,
I am using VS 2008 for the first time.I was working with VC++6.0.
And i am trying to compile the project which was done with VC++6.0.
When i am building the project i am getting the error like this
CVTRES : fatal error CVT1100: duplicate resource. type:MANIFEST, name:1, language:0x0409
LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt
I have googled out and found that if Generate manifest option in Project+properties+Linker is set to off this linker error will not come.
But i am not able to run the exe which is generated.
Please help me.
Regards
Deepu.
|
|
|
|
|
you need a manifest in VS2008 by design!!!
Throw out the manifest of the rc File. You can include it in the manifest tool -> additional manifest.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
|
Have you done a Rebuild All with VS2008?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
No.I am searching for how to remove the manifest information from rc file.
|
|
|
|
|
You can turn off the manifest generation step in the linker tool so long as you always distribute the application with the manifest contained in a separate file in the same directory as the executable.
As this page[^] says, Application manifests are copied into the same folder as the application executable file or included as a resource in the application's executable file..
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi Stuart
Thanks for helping me.I didnt understand much about manifest files.
But when i deleted Manifest option in rc file it worked.
Regards
Deepu.
|
|
|
|
|
Hi,
Please suggest me any link for MFC samples in vs2003/vs 2005...
|
|
|
|
|
|
i didn"t find any samples in vs 2003/2005...
|
|
|
|
|
you will get the necessary sample codes in codeproject also.
and when you installed MSDN dint you get samples?
|
|
|
|
|
please suggest me any MFC samples in vs2003/2005 with explanation...
|
|
|
|
|
|
Why you didnt sue of examples on the MSDN?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I would like to conditionally prevent the computer from going into sleep.
I know that I will receive the WM_POWERBROADCAST message with the value PBT_APMQUERYSUSPEND, which means "is it OK to suspend.
If I reply BROADCAST_QUERY_DENY, then it's not going to happen.
I would like to differentiate between 2 events.
1. The user puts the computer into sleep.
2. The computer enters sleep because of a configured timeout.
I "could" check if the computer is IDLE at this moment... that might do it.
Just wondering if there's a better answer?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: I "could" check if the computer is IDLE at this moment... that might do it.
Are you looking for GetLastInputInfo() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Yes -- "idle" detection is not the issue
Is the overall plan good?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
I am trying to create a tool bar using the class CToolBar. Maybe, I should be using the class
CToolbarCtrl. However, I want to understand both so I can make an informed decision what is best for
my application. I wrote the following code:
BOOL status1 = toolBar.Create( this );<br />
BOOL status2 = toolBar.LoadToolBar( IDR_TOOLBAR );<br />
toolBar.SetButtonStyle( 0, TBBS_CHECKBOX );<br />
toolBar.SetButtonStyle( 1, TBBS_CHECKBOX );<br />
toolBar.SetButtonStyle( 2, TBBS_CHECKBOX );<br />
toolBar.SetButtonStyle( 3, TBBS_CHECKBOX );<br />
toolBar.SetButtonStyle( 4, TBBS_CHECKBOX );<br />
toolBar.SetButtonStyle( 5, TBBS_CHECKBOX );<br />
<br />
const UINT idArray[] = {<br />
IDM_LINES, IDM_RECTANGLES, IDM_ELLIPSES,<br />
IDM_ENLARGE, IDM_ORG, IDM_RESET<br />
};<br />
<br />
BOOL status3 = toolBar.SetButtons( idArray, 6 );<br />
toolBar.UpdateWindow();<br />
BOOL status4 = toolBar.ShowWindow( SW_SHOW );<br />
toolBar.Invalidate();<br />
this->Invalidate();
This code runs as part of the function that creates (OnCreate) the main window of the application.
The return values as stored in status1, status2, status3 and status4 are 1, 1, 1, and 4. However
no tool bar is being displayed. Please tell me what I am missing or how I should go about trying to debug this problem?
Thanks
Bob
|
|
|
|