怎么在一个Utility Project的运行中显示的信息

解决方案 »

  1.   

    我建立了一个Utility project,目的是初始化数据,现在我要在初始化之前提示用户
    是否初始化,但是我不知道怎么把信息显示出来
      

  2.   

    #include "stdafx.h"
    #include <cstdio>
    #include <cstdlib>
    #include <ctime>static void Log(const char* format, ...)
    {
    char logMsg[1024];
    char msg2[1024];
    CTime time = CTime::GetCurrentTime();
    sprintf(logMsg, "%04d-%02d-%02d %02d:%02d\t",
    time.GetYear(), time.GetMonth(),time.GetDay(),
    time.GetHour(), time.GetMinute()); va_list vl;
    va_start(vl, format);
    vsprintf(msg2, format, vl);
    va_end(vl);

    CStdioFile file("RMT_R.log", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite);
    file.SeekToEnd();
    file.WriteString(strcat(logMsg, msg2));
    }char g_buf[129] = "SDKL349FI3402-=78=-=-34=|+_+-)&*(%&^%^$^&*%45jkJKJqjk34d#$#$<><jlojuio?>;>/;>?:;L>:LKP*O)(&&^GHjgyu6523kl#%#$%89&^&*(&*(7!kjhj~`";BYTE z(BYTE x, BYTE y)
    {
        return x * x * x + y * y * y + x * x * y + x * y * y + x * y + x + y + 1;
    }void CalcPattern(const BYTE *buf1, BYTE *buf2)
    {
        for (int i = 0; i < 128; ++i)
        {
            buf2[i] = z(g_buf[i], buf1[i % 16]);
        }
    }int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
        unsigned char buf[512];
        srand(time(NULL));
    //我要在这里显示一个一个MESSAGEBOX,要怎么做??    
        Log("Clear Password.\n");    for (int i = 0; i < 512; ++i)
        {
            buf[i] = rand() % 255;
        }    char password[16] = {0};
        strcpy(password, "123456");
            
        CalcPattern((unsigned char *)password, &buf[133]);    int pwindex = 0;
        pwindex = (rand() % 32) + 60;
        buf[0] = pwindex;
        *((long*)&buf[pwindex]) = 0x32336341;    pwindex = (rand() % 32) + 96;
        buf[1] = pwindex;
        *((long*)&buf[pwindex]) = 0x32336341;    DWORD dwWrite;
        HANDLE hFile = ::CreateFile("RMT_R.dat", GENERIC_WRITE, 0, NULL, 
            OPEN_EXISTING, 0, NULL);    if (INVALID_HANDLE_VALUE == hFile)
        {
            return -1;
        }    ::WriteFile(hFile, buf, 512, &dwWrite, NULL);    ::CloseHandle(hFile); return 0;
    }
      

  3.   

    ::MessageBox(NULL, "初始化否?", "请问", MB_OKCANCEL);
      

  4.   

    if( IDOK == ::MessageBox(NULL, "初始化否?", "请问", MB_OKCANCEL) )
    {
      ...
    }
    else
    {
      ...
    }
      

  5.   

    楼上的大哥不行啊,有3个错误啊
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
    nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
    Debug/Utility.exe : fatal error LNK1120: 2 unresolved externals
      

  6.   

    这是另外一个问题如果没有用到MFC就在Project Setting/General 里选 "Not using MFC"如果用到了就在Project Setting/C/C++/Code generation 里选择multithreaded