如题.

解决方案 »

  1.   

    不會吧?!能不能把代碼段拿出來看看?我的調用如下:
    SYSTEMTIME systime;
    GetLocalTime(&systime);
    沒有問題!
      

  2.   


    void CTestDlg::OnOK() 
    {
    // TODO: Add extra validation here
    SYSTEMTIME SystemTime; 
    GetLocalTime(&SystemTime); CString str;
    str.Format("%d-%d-%d %d:%d:%d %d",
    SystemTime.wYear,
    SystemTime.wMonth,
    SystemTime.wDay,
    SystemTime.wHour,
    SystemTime.wMinute,
    SystemTime.wSecond,
    SystemTime.wMilliseconds);
    AfxMessageBox(str);
    //CDialog::OnOK();
    }
      

  3.   

    我试过,在我这里没有问题
    rebuild all试试?
      

  4.   

    源码在这:
    #include "stdafx.h"
    #include "resource.h"#define MAX_LOADSTRING 100
    HINSTANCE hInst;
    TCHAR szTitle[MAX_LOADSTRING];
    TCHAR szWindowClass[MAX_LOADSTRING];
    ATOM MyRegisterClass(HINSTANCE hInstance);
    BOOL InitInstance(HINSTANCE, int);
    LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM);
    LRESULT CALLBACK timeClose(HWND, UINT, WPARAM, LPARAM);long time;
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    MSG msg;
    HACCEL hAccelTable; LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
    LoadString(hInstance, IDC_TMECLOSE, szWindowClass, MAX_LOADSTRING);
    MyRegisterClass(hInstance); if (!InitInstance (hInstance, nCmdShow)) 
    {
    return FALSE;
    } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TMECLOSE); while (GetMessage(&msg, NULL, 0, 0)) 
    {
    if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) 
    {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    } return msg.wParam;
    }
    ATOM MyRegisterClass(HINSTANCE hInstance)
    {
    WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX);  wcex.style = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc = (WNDPROC)WndProc;
    wcex.cbClsExtra = 0;
    wcex.cbWndExtra = 0;
    wcex.hInstance = hInstance;
    wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TMECLOSE);
    wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszMenuName = (LPCSTR)IDC_TMECLOSE;
    wcex.lpszClassName = szWindowClass;
    wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex);
    }
    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
    {
       HWND hWnd;   hInst = hInstance;   hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
          CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);   if (!hWnd)
       {
          return FALSE;
       }   ShowWindow(hWnd, nCmdShow);
       UpdateWindow(hWnd); SetTimer(hWnd,10001,100,NULL);
    DialogBox(hInst, (LPCTSTR)IDD_DIALOG1, hWnd, (DLGPROC)timeClose);   return TRUE;
    }
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;
    char *str;
    str=69; switch (message) 
    {
    case WM_COMMAND:
    wmId    = LOWORD(wParam); 
    wmEvent = HIWORD(wParam);  switch (wmId)
    {
    case IDM_EXIT:
       DestroyWindow(hWnd);
       break;
    default:
       return DefWindowProc(hWnd, message, wParam, lParam);
    }
    break;
    case WM_TIMER:
    if (wParam==10001)
    {
    time--;
    } case WM_PAINT:
    hdc = BeginPaint(hWnd, &ps); RECT rt;
    GetClientRect(hWnd, &rt);
    TextOut(hdc,10,10, "还有", 4);
    TextOut(hdc,40,10, str, 2);
    TextOut(hdc,60,10, "分关机", 6);
    EndPaint(hWnd, &ps);
    break;
    case WM_DESTROY:
    PostQuitMessage(0);
    break;
    default:
    return DefWindowProc(hWnd, message, wParam, lParam);
       }
       return 0;
    }
    LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_INITDIALOG:
    return TRUE; case WM_COMMAND:
    if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
    {
    EndDialog(hDlg, LOWORD(wParam));
    return TRUE;
    }
    break;
    }
        return FALSE;
    }
    LRESULT CALLBACK timeClose(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
    {
    switch (message)
    {
    case WM_INITDIALOG:
    return TRUE; case WM_COMMAND:
    if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) 
    {
    EndDialog(hDlg, LOWORD(wParam));
    return TRUE;
    } switch(LOWORD(wParam))
    {
    case IDC_CLOSEDIALOG:
    EndDialog(hDlg,LOWORD(wParam));
    } break;
    }
        return FALSE;
    }
      

  5.   

    哪里有GetLocalTime?
    找不到