摘要: 了解了string 的操作符,查找函数和substr,其实就已经了解了string的80%的操作了。insert函数, replace函数和erase函数在使用起来相对简单。下面以一个例子来说明其应用。 string只是提供了按照位置和区间的replace函数,而不能用一个string字串来替换指定string中的另一个字串。这里写一个函数来实现这个功能: void string_replace(string & strBig, const string & strsrc, const string &strdst) { string::size_type pos=0; 阅读全文
posted @ 2011-09-28 09:23 积木 阅读(3199) 评论(0) 推荐(0) 编辑
摘要: HexToString(const char *szContent, int len, bool bHasSpace){string str = "";for (int i=0; i<len; i++){char strTemp[8] = {0};if (bHasSpace){sprintf(strTemp, "%02X ", (BYTE)szContent[i]);}else{sprintf(strTemp, "%02X", (BYTE)szContent[i]);}str += strTemp;}return str;} 阅读全文
posted @ 2011-09-28 09:12 积木 阅读(1242) 评论(0) 推荐(0) 编辑
摘要: std::vector<StAlarmInfo > g_vec; UINT j =1;std::vector<StAlarmInfo *>::iterator iter = std::find_if (g_vec.begin(), g_vec.end(), Find_AutoID_AlInfo(j));if(iter != g_vec.end() ){找到}class Find_AutoID_AlInfo{public: explicit Find_AutoID_AlInfo (const int autoid):id(autoid) {} bool operator 阅读全文
posted @ 2011-08-19 16:11 积木 阅读(239) 评论(0) 推荐(0) 编辑
摘要: Microsoft Visual C++ 2008Redistributable Package (x86) En SP1---vcredist_x86.exehttp://u.115.com/file/bhzxq7iq#vc2008_Redistributable_Package_(x86)_En_SP1.zip 阅读全文
posted @ 2011-07-28 11:18 积木 阅读(224) 评论(0) 推荐(0) 编辑
摘要: CStdioFile File; // 定义一个CStdioFile类变量FileCString FileData; // 定义一个CString,作为一个缓冲区//定义n个临时字符串变量,大小依据实际情况,这里暂设为10char TempStr1[10],TempStr2[10]......TempStrN[10];File.ReadString(FileData); // 将一行数据读到缓冲区//将该行数据的n个字符读到n个临时字符串变量sscanf(FileData,"%s %s %s %s ......%s",TempStr1,TempStr2......TempS 阅读全文
posted @ 2011-07-18 14:13 积木 阅读(5123) 评论(0) 推荐(0) 编辑
摘要: CStdioFile类的声明保存再afx.h头文件中。CStdioFile类继承自CFile类,CStdioFile对象表示一个用运行时的函数fopen打开的c运行时的流式文件。流式文件是被缓冲的,而且可以以文本方式(默认)或者二进制方式打开。CStdioFile类不支持CFile类中的Duplicate、LockRange、UnlockRange函数,如果你使用了,会得到CNotSupportedException类的错误。CStringFile类默认的是按照Text模式操作文件。CFile 类默认的是按照二进制模式操作文件。这里大致说明一下二进制模式和Text模式的区别。二进制模式:对于一 阅读全文
posted @ 2011-07-17 00:33 积木 阅读(20780) 评论(0) 推荐(2) 编辑
摘要: try { CFile file; if ( !file.Open(_T( "C:/text.TXT "),CFile::modeReadWrite)) { // ==========> 这段代码写在DLL中上面这个OPEN失败,,直接写在EXE程序中为正确的。。 } // ………………………… } catch(CFileException* e) { MessageBox( "File Operation Error! "); } 是啊,你不是有“catch(CFileException* e)”吗?错误信息在“e”里面e-> m_caus 阅读全文
posted @ 2011-07-17 00:04 积木 阅读(5224) 评论(0) 推荐(0) 编辑
摘要: 应用程序进程本身及其调用的每个DLL模块都具有一个全局唯一的HINSTANCE句柄,它们代表了DLL或EXE模块在进程虚拟空间中的起始地址。进程本身的模块句柄一般为0x400000,而DLL模块的缺省句柄为0x10000000。如果程序同时加载了多个DLL,则每个DLL模块都会有不同的 HINSTANCE。应用程序在加载DLL时对其进行了重定位。 共享MFC DLL(或MFC扩展DLL)的规则DLL涉及到HINSTANCE句柄问题,HINSTANCE句柄对于加载资源特别重要。EXE和DLL都有其自己的资源,而且这些资源的ID可能重复,应用程序需要通过资源模块的切换来找到正确的资源。如果应用程序 阅读全文
posted @ 2011-06-02 20:39 积木 阅读(3818) 评论(0) 推荐(1) 编辑
摘要: 导出:extern "C" _declspec(dllexport) : 表示这个函数是DLL导出函数,可以被外部引用。导出类 class _declspec(dllexport) classname{...}AFX_EXT_CLASS导入:在应用工程中引用DLL中全局变量的一个更好方法是:extern int _declspec(dllimport) global; //用_declspec(dllimport)导入Class _declspec(dllimport) classname 来导入类调用约定:1. __stdcall 可让VC 编写的DLL被其他语言编写的程 阅读全文
posted @ 2011-06-02 20:28 积木 阅读(672) 评论(0) 推荐(0) 编辑
摘要: DLL类型判断:1. MFC规则DLL 没有界面要求 theApp 入口2. MFC扩展DLL 有界面导出 DllMain 入口3. Win32DLL APIENTRY DllMain 入口DLL分类:1。Non-MFC DLL(非MFC动态库):不采用MFC类库结构,其导出函数为标准的C接口,能被非MFC或MFC编写的应用程序所调用;2。MFC Regular DLL(MFC规则DLL):非MFC动态库MFC规则DLL 包含一个继承自CWinApp的类,但其无消息循环;3。MFC Extension DLL(MFC扩展DLL):采用MFC的动态链接版本创建,它 只能被用MFC类库所编写的应用 阅读全文
posted @ 2011-06-02 20:03 积木 阅读(743) 评论(0) 推荐(0) 编辑