随笔分类 -  【原创】C/C++相关

MFC API ATL C语言
摘要:建立一个不能打开的文件。当你看懂这段代码,就是一次质的改变。源自 windows 核心编程 扩展...#include <windows.h>void RaiseToDebugP(){/* GetCurrentProcessID 得到当前进程的ID OpenProcessToken 得到进程的令牌句柄 LookupPrivilegeValue 查询进程的权限 AdjustTokenPrivileges 调整令牌权限*/ HANDLE hToken; HANDLE hProcess = GetCurrentProcess(); if ( OpenPro... 阅读全文
posted @ 2012-08-06 17:33 upendi 阅读(362) 评论(0) 推荐(0)
摘要:【源码 测试】#include <sys/time.h>#include <stdio.h>#include <mysql.h>int main(void){ MYSQL_RES *result; MYSQL_ROW row; MYSQL *connection, mysql; int state; mysql_init(&mysql); connection = mysql_real_connect(&mysql,"localhost","root","951241"," 阅读全文
posted @ 2012-08-01 15:40 upendi 阅读(613) 评论(0) 推荐(0)
摘要:【代码加载lib及库中函数声明】#pragma comment(lib,"dll_phishing.lib")extern "C" _declspec(dllexport) int is_phishing(char* url);//char*extern "C" _declspec(dllimport) int read_config(vector<string> white_vector);//char*【vs 2010解决方案和项目】建立一个解决方案,输入两个不同的名字,解决方案最好具有普遍性。再建方案要用到的小项目, 阅读全文
posted @ 2012-07-25 16:36 upendi 阅读(459) 评论(0) 推荐(0)
摘要:传递vector<string>类型参数~【dll 文件】#include <iostream>#include <vector>#include <string>using namespace std;extern "C" __declspec(dllexport)int show_vector(vector<string> aaa);int show_vector(vector<string> aaa) // 传过来的aaa最好不要修改、增加、删除里的值{vector<string>:: 阅读全文
posted @ 2012-07-25 11:08 upendi 阅读(258) 评论(0) 推荐(0)
摘要:在VC6.0 下编译通过。。。其它VC平台类似!一、建立 Win32 Dynamic-LinkLibrary 项目【dll.cpp】#include <iostream>#include <string>#include "dll.h"using namespace std;void add(char* aa){string bb = aa;cout << "you are right!" << "------" << bb <<endl;}【dll.h】#inc 阅读全文
posted @ 2012-07-23 14:43 upendi 阅读(891) 评论(0) 推荐(0)
摘要:这周主要做了stl环境下url字符串操作, 用到string 类的很多函数。完成了对url的识别和对银行网址的认定,以防止钓鱼网站的url被误认。。。stl下主要是对容器的使用,vector list ;当然做为C++ 的标准,流和输入与输出是少不了的,也包括文件;最基本的是字符串的操作了,string提供了很多的函数,可以调用。vector:【例】vector<string> abcd;abcd.push_back("dfkddghdrherherf");//插入abcd.push_back("ldfsdlfjsl");abcd.push_ 阅读全文
posted @ 2012-07-20 18:21 upendi 阅读(734) 评论(0) 推荐(0)
摘要:io_service一般作为处理工作的work pool。网络中,作为服务器接收用,可以加速处理收到的信息。主要有post, dispatch, stop, run. 几可常用方法。通常还会用到boost bind一起使用io_service是并发的,在队列中,有几个run, 就有几个并发进行;而对于strand 是严格顺序进行的调用。看下面的例子:#include <iostream>#include <boost/shared_ptr.hpp>#include <boost/asio.hpp>#include <iostream>#inclu 阅读全文
posted @ 2012-07-13 15:22 upendi 阅读(7093) 评论(0) 推荐(0)
摘要:简单明了,这个是cpluscpus 对find_if的定义:123456template<class InputIterator, class Predicate> InputIterator find_if ( InputIterator first, InputIterator last, Predicate pred ) { for ( ; first!=last ; first++ ) if ( pred(*first) ) break; return first; } 【例1】对第三参数的处理例子,第三参数就是一函数名。。。class CPerson{publ... 阅读全文
posted @ 2012-07-12 16:32 upendi 阅读(2271) 评论(0) 推荐(0)
摘要:http://blog.sina.com.cn/s/blog_780ff8860100zwz7.html 阅读全文
posted @ 2012-07-04 13:38 upendi 阅读(439) 评论(0) 推荐(0)
摘要:依据网上所查,C中主要是说:NULL是指针为空而“”是指针不是空,而是指向空内容。而JAVA中是null没有对象,而“”为有对象,但为空对象。所以在判断的时候要先判断是否没空,再判断是否没空对象(内容为空)。如:if(object == NULL || object == "") 而不要写成if(object == "" || object == NULL) 阅读全文
posted @ 2012-04-21 09:08 upendi 阅读(296) 评论(0) 推荐(0)
摘要:首先声明,是读大量代码适用。刚开始读几万行代码,没头绪,没文档,没说明,没注释;只有一个简单的功能框架,读得让人头痛。但是工作需要必须读。C代码:(如果要掌握代码,达到能改动能力,一定不要先看主函数)主要是依据源码的标题,先大致看一下会实现些什么功能。再依据功能最好能自己连读边写个文档记录。做了这个心里对代码有了大致的了解,再细读各个函数,把几个接口函数和全局变记录下来。最后整体联系一下,看主函数的调用,贯通整个程序,可以调试看看具体过程。C++代码:主要是看类结构图和功能函数,由于C++本身功能分得比较清楚,所以比较容易看懂。但是,最让人纠结的是,总有人把C和C++代码一起使用,这个时候就要 阅读全文
posted @ 2012-04-20 16:23 upendi 阅读(1201) 评论(0) 推荐(0)