贝贝源代码分析之一
来源:互联网 发布:python http下载文件 编辑:程序博客网 时间:2024/04/28 02:34
程序入口点代码分析
- int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow) {
- #ifndef _DEBUG
- SingleInstance dcapp(_T("{STRONGDC-AEE8350A-B49A-4753-AB4B-E55479A48351}"));
- #else
- SingleInstance dcapp(_T("{STRONGDC-AEE8350A-B49A-4753-AB4B-E55479A48350}"));
- #endif
- //以上代码得到了单例的对象
- if(dcapp.IsAnotherInstanceRunning()) {
- // Allow for more than one instance...
- bool multiple = false;
- if(_tcslen(lpstrCmdLine) == 0) {
- if (::MessageBox(NULL, _T("There is already an instance of StrongDC++ running./nDo you want to launch another instance anyway?"),
- _T(APPNAME) _T(" ") _T(VERSIONSTRING), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2 | MB_TOPMOST) == IDYES) {
- //设置可以启动多个实例
- multiple = true;
- }
- }
- if(multiple == false) {
- HWND hOther = NULL;
- EnumWindows(searchOtherInstance, (LPARAM)&hOther);
- if( hOther != NULL ) {
- // pop up
- ::SetForegroundWindow(hOther);
- if( IsIconic(hOther)) {
- // restore
- ::ShowWindow(hOther, SW_RESTORE);
- }
- sendCmdLine(hOther, lpstrCmdLine);
- }
- return FALSE;
- }
- }
- // For SHBrowseForFolder, UPnP
- HRESULT hRes = ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
- #ifdef _DEBUG
- EXTENDEDTRACEINITIALIZE( Util::getDataPath().c_str() );
- //File::deleteFile(Util::getDataPath() + "exceptioninfo.txt");
- #endif
- LPTOP_LEVEL_EXCEPTION_FILTER pOldSEHFilter = NULL;
- pOldSEHFilter = SetUnhandledExceptionFilter(&DCUnhandledExceptionFilter);
- AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES | ICC_LISTVIEW_CLASSES | ICC_TREEVIEW_CLASSES | ICC_PROGRESS_CLASS | ICC_STANDARD_CLASSES |
- ICC_TAB_CLASSES | ICC_UPDOWN_CLASS | ICC_USEREX_CLASSES); // add flags to support other controls
- hRes = _Module.Init(NULL, hInstance);
- ATLASSERT(SUCCEEDED(hRes));
- try {
- File f(WinUtil::getAppName(), File::READ, File::OPEN);
- TigerTree tth(TigerTree::calcBlockSize(f.getSize(), 1));
- size_t n = 0;
- size_t n2 = DEBUG_BUFSIZE;
- while( (n = f.read(buf, n2)) > 0) {
- tth.update(buf, n);
- n2 = DEBUG_BUFSIZE;
- }
- tth.finalize();
- strcpy(::tth, tth.getRoot().toBase32().c_str());
- WinUtil::tth = Text::toT(::tth);
- } catch(const FileException&) {
- dcdebug("Failed reading exe/n");
- }
- HINSTANCE hInstRich = ::LoadLibrary(_T("RICHED20.DLL"));
- int nRet = Run(lpstrCmdLine, nCmdShow);
- if ( hInstRich ) {
- ::FreeLibrary(hInstRich);
- }
- // Return back old VS SEH handler
- if (pOldSEHFilter != NULL)
- SetUnhandledExceptionFilter(pOldSEHFilter);
- _Module.Term();
- ::CoUninitialize();
- #ifdef _DEBUG
- EXTENDEDTRACEUNINITIALIZE();
- #endif
- return nRet;
- }
- 贝贝源代码分析之一
- 贝贝
- Lucene4源代码分析之一:源代码导入Eclipse
- Wordpress源代码分析之settings.php之一
- [原创]经过整理的源代码 google map 代码分析之一
- Redis源代码分析之一:内存管理——Zmalloc
- 开源代码分析技巧之一——打印调用逻辑
- Github android客户端源代码分析之一:环境搭建
- Github android客户端源代码分析之一:环境搭建
- Unity5标准着色器源代码剖析之一:架构分析篇
- Bind-9.6.0-P1源代码分析之一:整体架构(初稿)
- 纪念贝贝
- nginx源代码解读之一
- 邵贝贝译<嵌入式实时操作系统uCOS-ii>:第13章 uCOS操作系统移植分析
- OpenStack Swift源码分析(4)----swift-ring-builder源代码解析之一
- 协议栈之一:《linux内核网络栈源代码情景分析》.(曹桂平)
- inetutils中tftp源代码分析之一:tftp中命令的使用
- 源代码分析
- [ZT]AIX系统中动态链接库的创建与使用
- 想成为嵌入式程序员应知道的0x10个基本问题
- Google chrome 中文版下载
- 基于配置的ORMapping框架浅析之1(以自己开发的框架为例子)
- SPKtool 使用手册
- 贝贝源代码分析之一
- 不要怕,不要悔
- 用XsltArgumentList实现xsl的参数调用
- Web应用开发技术细节大突破
- emc 2006和2007笔试题
- commit-email.pl多国语言的问题之一 字符集转换问题
- 【.net】webserver的
- 关于外观的禁忌
- 基于配置的ORMapping框架浅析之2(以自己开发的框架为例子)