B
Benny Van
Hi all!
I have a question regarding a windows operating system function:
I was asked to write a small program for a homework to display the
user name and computer name and the system time out to a console
window: the display would be like:
Hello XXX(user)
Today is XXX(date)
The Time is XXX(current system time)
I was asked to use a Windows System Call---void GetLocalTime(SYSTIME
*lpSystemTime) for the time part. I have done the user and computer
name part, but I don't know how to use that call:
Here is my code for name part:
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_GREEN);
char host[500];
DWORD bufferLength;
GetComputerName(host, &bufferLength);
cout << "Host name is " << host << endl;
GetUserName(host, &bufferLength);
cout << "User is " << host << endl;
SetConsoleTitle("prog2");
}
Anyone could help me with that time part, for I really don't know how
to use that! Thank you very very much!
Sincerely,
Ben
I have a question regarding a windows operating system function:
I was asked to write a small program for a homework to display the
user name and computer name and the system time out to a console
window: the display would be like:
Hello XXX(user)
Today is XXX(date)
The Time is XXX(current system time)
I was asked to use a Windows System Call---void GetLocalTime(SYSTIME
*lpSystemTime) for the time part. I have done the user and computer
name part, but I don't know how to use that call:
Here is my code for name part:
#include <iostream>
#include <windows.h>
using namespace std;
int main(int argc, char *argv[])
{
HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(handle, FOREGROUND_GREEN);
char host[500];
DWORD bufferLength;
GetComputerName(host, &bufferLength);
cout << "Host name is " << host << endl;
GetUserName(host, &bufferLength);
cout << "User is " << host << endl;
SetConsoleTitle("prog2");
}
Anyone could help me with that time part, for I really don't know how
to use that! Thank you very very much!
Sincerely,
Ben