|
Hi,
I am making a program to print out both UTC time and local time.
But, I am having the same time.
Do I have to save UTC time before 'ptrLocalTime = localtime(&localtimer);'?
/* This program shows UTC time, and local time in 00:00:00 */
#include <stdio.h>
#include <time.h>
#define PST (-8) //Pacific Time Zone
#define CST (-6) //Central Time Zone
int main ()
{
time_t timer;
time_t localtimer;
tm* ptrUTC;
tm* ptrLocalTime;
time ( &timer ); //Set timer to the number of seconds elapsed since 00:00 hours,
//Jan 1, 1970 UTC from the system clock.
time(&localtimer);
ptrUTC = gmtime ( &timer ); //Converts timer to tm structure adjusting to UTC
//(formerly known as GMT) timezone.
ptrLocalTime = localtime(&localtimer);
printf ("UTC Time: %2d:%02d:%02d\n", ptrUTC->tm_hour, ptrUTC->tm_min, ptrUTC->tm_sec);
printf ("Locat time : %2d:%02d:%02d\n", ptrLocalTime->tm_hour, ptrLocalTime->tm_min, ptrLocalTime->tm_sec);
return 0;
}
Please!
Yonggoo
|
|
|
|
|
The gmtime, mktime, and localtime functions use the same single, statically allocated structure to hold their results. Each call to one of these functions destroys the result of any previous call.
Please check the address stored in ptrLocalTime and ptrUTC. Both are same.
So you have to make a copy before calling another function.
|
|
|
|
|
Hello,
I would like to backup and restore registry keys to and from a .reg file like the one that regedit.exe creates when you export registry keys, and i was wondering whether there was an API or COM function that would do this for me without having to code it myself.
I have tried looking but don't have a clue where to start, if someone could point me in the right direction it would be much appreciated.
Thanks a lot
|
|
|
|
|
sschilachi wrote: I have tried looking but don't have a clue where to start...
Start with RegSaveKeyEx() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
|
Hello,
Using MIB_IPADDRTABLE structure, you can retrieve IP addresses associated with every networks adapters. But what about retrieving a description of those network adapters (Bluetooth, Wi-fi, Ethernet...) Which function to use?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
Hi All,
I am having trouble resolving the following error.
error C2039: 'AddString' : is not a member of 'CString'.
Thanks in advance
C++Prog
|
|
|
|
|
I got it Thanks....
C++Prog
|
|
|
|
|
Hi,
I need to programmatically launch Winamp. But I don't get a clue how to do that.
Can somebody help?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
|
Thanks for replying.
But in order to use ShellExec or CreateProcess, I need to know where to find the Winamp executable installed on the user's computer. How can I find this path?
Thanks,
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
The first thing to look for is does the exe support OLE automation - If it does you should use COM to launch it. I'm no WinAmp expert but after looking in the registry of my computer I knocked up the following program which launched WinAmp:
#include "stdafx.h"
#include <objbase.h>
static const CLSID CLSID_WinAmp =
{ 0x46986115, 0x84D6, 0x459c, { 0x8F, 0x95, 0x52, 0xDD, 0x65, 0x3E, 0x53, 0x2E } };
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
CoInitialize(NULL);
IUnknown *pUnk;
if ( SUCCEEDED(CoCreateInstance(CLSID_WinAmp, NULL, CLSCTX_ALL, IID_IUnknown, reinterpret_cast<void**>(&pUnk))) )
{
pUnk->Release();
}
CoUninitialize();
return 0;
}
NOTES:
I hardcoded the CLSID which I got from the registry - There is probably an SDK that can be used. This would also contain interfaces which would enable to control the instance of WinAmp launched.
Steve
|
|
|
|
|
Thanks for your reply.
However, I've never done OLE programming before. Is the CLSID the same for every computer running Winamp?
Thanks
Allad
----
Navigator - Your best alternative to Windows Explorer
|
|
|
|
|
In general that's the idea - But I hacked this CLSID out of the registry; It wasn't sourced from any official documentation.
Steve
|
|
|
|
|
I have a CDialog based class and I put a CListCTrl on it then did the cTRL-W thing (VC6) to make a new class out of it. Now I realize I want more controls on it. IF I just draw them on, I dont get any thing mentioned in the class cpp file (I even rebuilt). So is it a fact that you have to have your design completely done before you make a class out of it?
|
|
|
|
|
ns wrote: So is it a fact that you have to have your design completely done before you make a class out of it?
No, not at all. You can open ClassWizard as many, or as few, times as you want.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Hi,
This is my second post about this subjet...
I whant to send a CDC to another computer via network...
and it is for creating a remote desktop application.
If there is a btter way (FASTER WAY) please help me. I don't want to send a whole picture to another computer bcuz it is slow and ridiculous.
Thanks
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
The C in DC stands for context, which infers that it is only meaningful in a specific context for a specific device. Sending that to another computer makes no sense. You can, however, send the screen data in chunks to the other computer. The Terminal Services API might be required, but I really don't know for sure.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I'm trying to track down an error where a message box comes up "Attempt to open busy clipboard window, OK to resume". Anyone see this before??
Thanks - harrier
|
|
|
|
|
What are you doing that causes this message to appear?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
This is partly the problem, no clear repro on it. When it happens it's frequent but not consistent. Most of the time it's the main app window becoming the active window.
harrier
|
|
|
|
|
So do you have code someplace that it interacting with the clipboard?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Probably. Not my code. Inherited. I try to find a repro before digging through code. I've googled all sorts of keywords and only found one non-english site with the same error message. Now here I am hoping someone who actually has written code for the clipboard knows what this means. I could try looking through code but I don't know what I'm looking for.
- Harrier
|
|
|
|
|
Here's the code I added to my CDialog
public:
virtual void OnInitialUpdate();
and
void CTargetInfo::OnInitialUpdate()
{
if(NULL != m_listTgtInfo.GetSafeHwnd())
{
(void)m_listTgtInfo.SetExtendedStyle( LVS_EX_FULLROWSELECT );
m_listTgtInfo.InsertColumn(0,"Keywords",LVCFMT_LEFT,800);
m_listTgtInfo.SetExtendedStyle(LVS_EX_CHECKBOXES);
m_listTgtInfo.InsertColumn(1,"Options",LVCFMT_LEFT,800);
}
}
It nevers enters the OnInitialUpdate
The way I am creating the dialog is
m_tgtInfo = new CTargetInfo(this);
if(!m_tgtInfo) return CDialog::OnCommand(wp, lp);
m_tgtInfo->Create(IDD_DLGTGTINFO, (CWnd*)this);
m_tgtInfo->ShowWindow(SW_SHOW);
Is there something else I need to do?
thanks,
sb
|
|
|
|
|
OnInitialUpdate() is for a view, not a dialog. Override OnInitDialog() instead.
ns wrote: The way I am creating the dialog is
m_tgtInfo = new CTargetInfo(this);
if(!m_tgtInfo) return CDialog::OnCommand(wp, lp);
m_tgtInfo->Create(IDD_DLGTGTINFO, (CWnd*)this);
m_tgtInfo->ShowWindow(SW_SHOW);
Why not create a modal dialog instead:
CTargetInfo dlg;
dlg.DoModal();
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|