« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
| 公告 |
谦卑,荣誉,牺牲,英勇,怜悯,诚实,精神,公正。 |
Blog信息 |
blog名称: 日志总数:183 评论数量:698 留言数量:7 访问次数:3024166 建立时间:2005年12月29日 |

| |
[我的笔记]笔记 3.8 读书笔记
newqiang 发表于 2006/3/9 10:52:20 |
1.根据 time() 得到的值怎样得到日时和分:
date("Y年m月d日 H:i:s",time());得到时和分的话就是date("H:i",time());time()可以变成你的变量
2. MFC程序中如何创建多级目录 BOOL mkdirEx(const char* lpPath){ CString pathname = lpPath; if(pathname.Right(1) != "\") pathname += "\" ; int end = pathname.ReverseFind('\'); int pt = pathname.Find('\'); if (pathname[pt-1] == ':') pt = pathname.Find('\', pt+1); CString path; while(pt != -1 && pt<=end) { path = pathname.Left(pt+1); if(_access(path, 0) == -1) _mkdir(path); pt = pathname.Find('\', pt+1); } return true;} 3.ShellExecute直接调用.exe文件 CString strCurrentDir; int nRet = ::GetModuleFileName(NULL, strCurrentDir.GetBuffer(255), 255); strCurrentDir.ReleaseBuffer(); if ( nRet == 0) { return; } int nFind = strCurrentDir.ReverseFind('\\'); strCurrentDir = strCurrentDir.Left(nFind); nFind = strCurrentDir.ReverseFind('\\'); strCurrentDir = strCurrentDir.Left(nFind); nFind = strCurrentDir.ReverseFind('\\'); strCurrentDir = strCurrentDir.Left(nFind);
::ShellExecute(NULL, "open", strCurrentDir + "\\ParamEdit.exe", "", strCurrentDir, SW_SHOW);
4.C++随机数
rand()函数中带了一个RAND_MAX的宏定义它的值是0到+32767好现在就很清楚啦随机函数产生的都是这两个之间的整数(注意这里是整数)如果想生成-0.005~+0.005那么你可以这样(float)(rand()-rand())/32767*0.005就搞定了用它之前别忘了要加一个srand( (unsigned)time( NULL ) );在循环体外面加如果在里面加每次生成的数几乎是相同的
5.解决外部符号错误:_main,_WinMain@16,__beginthreadex
在创建MFC项目时, 不使用MFC AppWizard向导, 如果没有设置好项目参数, 就会在编译时产生很多连接错误, 如error LNK2001错误, 典型的错误提示有:libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainLIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex下面介绍解决的方法:
1). Windows子系统设置错误, 提示:libcmtd.lib(crt0.obj) : error LNK2001: unresolved external symbol _mainWindows项目要使用Windows子系统, 而不是Console, 可以这样设置:[Project] --> [Settings] --> 选择"Link"属性页,在Project Options中将/subsystem:console改成/subsystem:windows
2). Console子系统设置错误, 提示:LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16控制台项目要使用Console子系统, 而不是Windows, 设置:[Project] --> [Settings] --> 选择"Link"属性页,在Project Options中将/subsystem:windows改成/subsystem:console
3). 程序入口设置错误, 提示:msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16通常, MFC项目的程序入口函数是WinMain, 如果编译项目的Unicode版本, 程序入口必须改为wWinMainCRTStartup, 所以需要重新设置程序入口:[Project] --> [Settings] --> 选择"C/C++"属性页,在Category中选择Output,再在Entry-point symbol中填入wWinMainCRTStartup, 即可
4). 线程运行时库设置错误, 提示:nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadexnafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex这是因为MFC要使用多线程时库, 需要更改设置:[Project] --> [Settings] --> 选择"C/C++"属性页,在Category中选择Code Generation,再在Use run-time library中选择Debug Multithreaded或者multithreaded其中,Single-Threaded单线程静态链接库(release版本)Multithreaded多线程静态链接库(release版本)multithreaded DLL多线程动态链接库(release版本)Debug Single-Threaded单线程静态链接库(debug版本)Debug Multithreaded多线程静态链接库(debug版本)Debug Multithreaded DLL多线程动态链接库(debug版本)单线程: 不需要多线程调用时, 多用在DOS环境下多线程: 可以并发运行静态库: 直接将库与程序Link, 可以脱离MFC库运行动态库: 需要相应的DLL动态库, 程序才能运行release版本: 正式发布时使用debug版本: 调试阶段使用
6.ReverseFind()#include <STDIO.H>#include <AFX.H>
int main(){ CString s; s.Format("abcdefghijk"); int nPos = s.ReverseFind('a'); printf("nPos is %d\n",nPos); return 0;}其中,'a'对应的nPos是0,'h'对应的nPos是7,以此类推。但是:s.ReverseFind('a')和s.Find('a')的结果是一样的。问题是:ReverseFind() 和 Find() 有什么区别呢:对于ReverseFind(),查找顺序是从后往前,找到后的nPos是按前后顺序排列的。而Find()是从前往后查的,找到后的nPos也是按前后顺序排列的。
|
|
关于vtk安装后遇到的问题 读书笔记
Basara(游客)发表评论于2007/4/5 15:44:54 |
我装完vtk后编译一个mfc和vtk混合编程的程序出现下面的错误:Linking...example_canny.obj : error LNK2001: unresolved external symbol "public: __thiscall CExample_cannyDlg::CExample_cannyDlg(class CWnd *)" (??0CExample_cannyDlg@@QAE@PAVCWnd@@@Z)Debug/example_canny.exe : fatal error LNK1120: 1 unresolved externals执行 link.exe 时出错.-----------------------这个程序是没有问题的,用的是老师给的已通过的。我用cmake编译vtk,重新设置cmake的选项都重做了好几次编译了,还是没有办法解决这个问题。不知道到底是怎么回事。希望大狭能有空看到给予回复,小妹不甚感激! |
|
HELP ME 读书笔记
兰心之舟(游客)发表评论于2006/5/13 10:49:36 |
你好,我现在在做毕业设计,是一个小型的漏洞扫描系统,但在出现了现在的错误
Compiling...scan.cppLinking...scan.obj : error LNK2001: unresolved external symbol "public: __thiscall CScanDlg::CScanDlg(class CWnd *)" (??0CScanDlg@@QAE@PAVCWnd@@@Z)scan.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall CHistoryEdit::~CHistoryEdit(void)" (??1CHistoryEdit@@UAE@XZ)Debug/scan.exe : fatal error LNK1120: 2 unresolved externalsError executing link.exe.
Results
scan.exe - 3 error(s), 0 warning(s)怎么解决啊!谢谢! |
|
回复:笔记 3.8 读书笔记
im(游客)发表评论于2006/4/14 7:56:37 |
|
回复:笔记 3.8 读书笔记
newqiang(游客)发表评论于2006/3/31 23:19:47 |
|
回复:笔记 3.8 读书笔记
闪电(游客)发表评论于2006/3/31 18:44:42 |
非常感谢您的帮助 我以后有不明白的可以随时在这里提问马?? 谢谢您 |
|
回复:笔记 3.8 读书笔记
菜鸟(游客)发表评论于2006/3/16 13:47:17 |
谢谢你的笔记,不但解决了问题,还讲明了道理
佩服!! |
|
» 1 »
|