怎么在一个Utility Project的运行中显示的信息 怎么在一个Utility Project的运行中显示的信息 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我建立了一个Utility project,目的是初始化数据,现在我要在初始化之前提示用户是否初始化,但是我不知道怎么把信息显示出来 #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;} ::MessageBox(NULL, "初始化否?", "请问", MB_OKCANCEL); if( IDOK == ::MessageBox(NULL, "初始化否?", "请问", MB_OKCANCEL) ){ ...}else{ ...} 楼上的大哥不行啊,有3个错误啊nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadexDebug/Utility.exe : fatal error LNK1120: 2 unresolved externals 这是另外一个问题如果没有用到MFC就在Project Setting/General 里选 "Not using MFC"如果用到了就在Project Setting/C/C++/Code generation 里选择multithreaded ocx调节IE百分比花屏问题 _cdecl修饰名的问题 求一个可改变ListView单行颜色的方法 如何给CTreectrl加上边框? 求教 代理服务器的实现原理? 怎样实现 AVI动画 的鼠标光标???? 在线等!小问题:如何在sql语句中用程序中的变量,以及多表查询问题(MFC+ODBC+Access) 高分求DL-103规约通信的例子程序 如何取得ms级系统时间和程序运行时间? 关于用winsock传文件的问题 怎样获得Bitmap的RGB buffer, 而不用GetPixel()每个pixel的获得? ON_COMMAND和N_UPDATE_COMMAND_UI的区别区别是什么?
是否初始化,但是我不知道怎么把信息显示出来
#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;
}
{
...
}
else
{
...
}
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