
VC++
杜xx
这个作者很懒,什么都没留下…
展开
-
邮槽--进程间通信
发送端// mail2.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "windows.h"#include "stdio.h"int _tmain(int argc, _TCHAR* argv[]){char szMailAddr[]="\\\\.\\mailslot\\myma转载 2015-07-07 22:22:13 · 318 阅读 · 0 评论 -
vc 串口通信代码
#include "StdAfx.h"#include "comm.h"#include "publib.h"#include CommModule::CommModule(){ m_hCOM = NULL; m_bLog = FALSE; m_hThread = NULL; m_hStopEvt = NULL; m_data_cb = NULL;}转载 2015-09-14 16:07:38 · 539 阅读 · 0 评论 -
VC中CSTRING 转char*,,,转string
void CMianDlg::CStringToChar(CString strSource, char *chDes){ int nLength = strSource.GetLength(); int nBytes = WideCharToMultiByte(CP_ACP,0,strSource,nLength,NULL,0,NULL,NULL); WideCharToMult原创 2015-11-03 13:50:33 · 1048 阅读 · 0 评论 -
VC中new和delete的注意
在new 分配内存之后,内存地址和长度是不允许操作的,否则delete时会中断原创 2015-11-03 13:52:22 · 1018 阅读 · 0 评论 -
关于std::list的sort函数在VC6下的修正
徐岩柏 你可能也在使用c++的标准程序库,是不是感觉很好?本人在做项目的过程中发现这样的一个问题,我的list中保存的是一个个对象,我在使用该列表的过程中要依据对象的一个关键字进行排序。你可能会说:这还不容易吗!list 中有个sort函数就可以完成。不错,标准c++当然支持自定义算子排序函数,如果你用vc7 或g++ 就没有问题了,如果你是使用vc6.0如下的程序代码就不能编译:转载 2015-10-21 14:05:42 · 579 阅读 · 0 评论 -
setlocale函数
针对无法读取中文路径下的文件的问题,只要在解析模型配置文件时,加入一句: setlocale(LC_ALL,"chs");即可。setlocale函数原形为: char *setlocale( int category, const char *locale );头文件:所支持的操作系统为:ANSI, Win 95, Win NT对于简体中文可以使用如下设置转载 2015-10-22 10:04:52 · 614 阅读 · 0 评论 -
CopyMemory、FillMemory、MoveMemory、ZeroMemory
CopyMemory复制内存,第一个参数为目的地址,第二个参数为源地址,第三个参数为复制数据的大小,单位字节,源内存区域不能重叠,如果重叠,可以使用MoveMemory()函数。函数原型如下:void CopyMemory( PVOID Destination, const VOID * Source, SIZE_T Length);转载 2015-10-21 17:58:10 · 1245 阅读 · 0 评论 -
MFC 108问题
(1)如何通过代码获得应用程序主窗口的 指针?主窗口的 指针保存在CWinThread::m_pMainWnd中,调用AfxGetMainWnd实现。AfxGetMainWnd() ->ShowWindow(SW_SHOWMAXMIZED)//使程序最大化.(2) 确定应用程序的路径Use GetModuleFileName 获得应用程序的路径,然后去掉可执行文件名。转载 2015-10-09 15:25:25 · 1081 阅读 · 0 评论 -
MYSQL C++操作
一、环境配置1,装好mysql,新建一个C++控制台工程(从最简单的弄起,这个会了,可以往任何c++工程移植),在vs2010中设置,工程--属性--VC++目录--包含目录,将mysql server\include的绝对路径添加进去,例如C:\Program Files\MySQL\MySQL Server 5.6\include。将mysql server\lib文件夹下的libmysq转载 2015-11-02 15:50:21 · 413 阅读 · 0 评论 -
opencv显示视频流
CvSize cs; cs.width = nWidth; cs.height = nHeight; if (img == NULL) { img = cvCreateImage(cs,IPL_DEPTH_8U,3); } CvSize dst_cvsize; //目标图像尺寸 memcpy(img->imageData,原创 2015-11-20 17:49:58 · 973 阅读 · 0 评论 -
GDI创建BMP图
BITMAPINFO m_bmphdr={0}; DWORD dwBmpHdr = sizeof(BITMAPINFO); m_bmphdr.bmiHeader.biBitCount = 24; m_bmphdr.bmiHeader.biClrImportant = 0; m_bmphdr.bmiHeader.biSize = dwBmpHdr;原创 2015-11-20 17:43:56 · 805 阅读 · 0 评论 -
windows下程序崩溃,生成dump文件分析
#include #include #include #pragma comment(lib, "dbghelp.lib")// #ifndef _M_IX86// #error "The following code only works for x86!"// #endifinline BOOL IsDataSectionNeeded(const WCHAR* pModu转载 2016-11-08 11:24:08 · 3468 阅读 · 0 评论 -
vc 中写log文件
#include "StdAfx.h"#include "Log.h"#include #include #include #include #pragma comment(lib, "DbgHelp.lib")//默认构造函数CLog::CLog(){ //初始化 memset(m_strLogPath, 0, MAX_STR_LEN); memset(m_strCur转载 2016-11-16 14:59:18 · 3910 阅读 · 0 评论 -
windows删除非空目录
SHFILEOPSTRUCT FileOp;FileOp.fFlags = FOF_NOCONFIRMATION;FileOp.hNameMappings = NULL;FileOp.hwnd = NULL;FileOp.lpszProgressTitle = NULL;FileOp.pFrom = ".\\blacklistpic";FileOp.pTo = NULL;转载 2016-11-17 17:25:58 · 627 阅读 · 0 评论 -
键盘钩子函数注入dll
// dllmain.cpp : 定义 DLL 应用程序的入口点。#include "stdafx.h"#include "stdio.h"#include "windows.h"HINSTANCE g_hInstance=NULL;HHOOK g_hHook = NULL;HWND g_hwnd = NULL;#define DEF_PROCESS_NAME "www.exe转载 2016-11-30 16:06:53 · 1608 阅读 · 0 评论 -
MFC 检测内存泄漏的方法
C/C++的一个重要特色是可以动态的分配和释放内存,我们的口号是new和delete成对出现。可是,总会由于各种各样的原因,有内存泄露的情况发生,借助visual C++ 集成开发环境,可以方便的检查内存泄露信息,具体方法如下:1、在stdafx.h头文件中添加两行代码//内存泄露检测#define _CRTDBG_MAP_ALLO#include 2、在程序退转载 2016-11-15 11:44:37 · 2918 阅读 · 0 评论 -
windows 注入dll
// dllmain.cpp : 定义 DLL 应用程序的入口点。#include "stdafx.h"#include "windows.h"#include "tchar.h"#include "Urlmon.h"#pragma comment(lib, "urlmon.lib")#define DEF_URL "http://biancheng.dnbcw.info/c/15转载 2016-12-01 11:19:33 · 488 阅读 · 0 评论 -
VC++ 操作ftp http接口
https://technet.microsoft.com/zh-cn/aa384180(v=vs.89)转载 2016-12-01 16:13:58 · 918 阅读 · 0 评论 -
WIFI 用的网站
http://www.codeproject.com/Articles/72105/Manage-WiFi-with-Native-API-WIFI-on-Windows-XP-SP2https://msdn.microsoft.com/en-us/library/aa370032(v=vs.85).aspx原创 2015-08-21 16:51:45 · 346 阅读 · 0 评论 -
VC WIFI常用API地址
https://msdn.microsoft.com/en-us/library/ms706716(v=vs.85).aspx转载 2015-08-20 09:47:48 · 686 阅读 · 0 评论 -
VC DLL的编写调用
#ifndef _LIB_H_#define _LIB_H_extern "C" int __declspec(dllexport) add(int a, int b);#endif #include "stdafx.h"#include "Lib.h"int add(int a, int b){ return a+b;} 静态调用// main原创 2015-08-05 15:41:22 · 424 阅读 · 0 评论 -
标准C++读写文件
{char *my1= (char *)malloc(10);ifstream mys;ofstream my;my.open("1.txt");my.write("10101",5);my.close();mys.open("1.txt",ios::in);mys.getline(my1,6);printf(my1);mys.close();// sy转载 2015-07-07 22:23:22 · 519 阅读 · 0 评论 -
封装按钮
// SkinButton.cpp : 实现文件//#include "stdafx.h"#include "project.h"#include "SkinButton.h"// SkinButtonIMPLEMENT_DYNAMIC(SkinButton, CButton)SkinButton::SkinButton(){ m_bMouseLeave转载 2015-07-07 22:19:25 · 612 阅读 · 0 评论 -
VC 判断系统是否进入睡眠模式
WM_POWERBROADCAST消息可以很据wParam参数来判定判断睡眠唤醒只需PBT_APMRESUMESUSPEND和PBT_APMSUSPEND事件 LRESULT CALLBACK WindowProc( HWND hwnd, // handle to window UINT uMsg, // WM_POWER WPARAM转载 2015-07-07 22:20:22 · 4924 阅读 · 0 评论 -
C_C++命名规则
1、 变量名只能是字母(A-Z,a-z)和数字(0-9)或者下划线(_)组成。2、 第一个字母必须是字母或者下划线开头。3、 不能使用C++关键字来命名变量,以免冲突。4、 变量名区分大小写。 变量命名规则:一、 用最短字符表示最准确的意义。二、 使用变量前缀。1、 整型前缀int n转载 2015-07-07 22:17:23 · 499 阅读 · 0 评论 -
MFC重绘函数
void CDialogDiagnose::OnPaint(){ CPaintDC dc(this); // device context for painting // TODO: 在此处添加消息处理程序代码 CDC MemDC; MemDC.CreateCompatibleDC (&dc); CBitmap *pOldBmp; pOldBmp = MemDC.Se转载 2015-07-07 22:18:26 · 800 阅读 · 0 评论 -
使用API创建窗口
// 新建一个窗口,其消息循环负责处理BYHX消息,有状态改变时直接Post到界面 HWND parent_hWnd =(HWND)pPrinter->m_byhxHandle;//GetForegroundWindow(); HINSTANCE parent_hInst =GetModuleHandle(NULL); WNDCLASSEX wcex0 ={ sizeof(WNDCL转载 2015-07-07 22:21:37 · 618 阅读 · 0 评论 -
VC 弹出CDRom
BOOL TDevSwitch::SendSwitchCmd(BOOL bOpenDrive){ DWORD MaxDriveSet = GetLogicalDrives(); BYTE drive = 0; int nFindVolume = 0; // [7/9/2015 dubing] for ( drive = 0; drive { if ( Ma转载 2015-07-09 19:18:44 · 495 阅读 · 0 评论 -
多线程CreateThread函数的用法及注意事项
当使用CreateProcess调用时,系统将创建一个进程和一个主线程。CreateThread将在主线程的基础上创建一个新线程,大致做如下步骤: 1在内核对象中分配一个线程标识/句柄,可供管理,由CreateThread返回 2把线程退出码置为STILL_ACTIVE,把线程挂起计数置1 3分配context结构 4分配两页的物理存储以准备栈,保护页设置为PAGE_REA转载 2015-07-07 22:16:23 · 549 阅读 · 0 评论 -
VC透掉背景色
//透掉背景色 //CBitmap m_bit; //m_bit.LoadBitmap(strBmpPath); //HBITMAP bBit = (HBITMAP)m_bit.m_hObject; //if (GetObjectType(bBit) == OBJ_BITMAP) //{ // CSize csBitmap = GetBitmapSize(bBit);转载 2015-07-07 22:17:57 · 443 阅读 · 0 评论 -
VC DEVICE插拔消息
WM_DEVICECHANGE消息 电脑或者DEVICE配置发生改变,反馈给应用程序wParamEvent that has occurred. This parameter can be one of the following values from the Dbt.h header file.Value MeaningDBT_CONFIGCHANGECAN转载 2015-07-07 22:19:56 · 445 阅读 · 0 评论 -
STL之LIST使用
// List.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "stdlib.h"#define NULL 0#define TYPE struct stu#define LEN sizeof(struct stu)struct stu{int num;int age;struct stu转载 2015-07-07 22:22:51 · 253 阅读 · 0 评论 -
各种数据转换::::转载
本人并未对以下所有方法进行测试,仅仅是为了给大家一个参考。 Unicode(统一码、万国码、单一码)是一种在计算机上使用的字符编码。它为每种语言中的每个字符设定了统一并且唯一的二进制编码,以满足跨语言、跨平台进行文本转换、处理的要求。1990年开始研发,1994年正式公布。随着计算机工作能力的增强,Unicode也在面世以来的十多年里得到普及。在非 Unicode 环境下,由于不同国家转载 2015-07-07 22:15:42 · 370 阅读 · 0 评论 -
ADO操作数据库
#include "StdAfx.h"#include "Ado.h"#include #include using namespace std;CAdo::CAdo(void){ if (!SUCCEEDED(::CoInitialize(NULL))) { MessageBox(NULL, _T("初始化COM失败!!!"), _T("text"), MB转载 2015-07-07 22:16:54 · 377 阅读 · 0 评论 -
va_list va_start cfindfile遍历文件
__inline void WorkTrace(LPCTSTR lpszFormat,...){ va_list args; va_start(args, lpszFormat); _WorkTrace(_T("WorkHistory"),lpszFormat,args); va_end(args);} ===============================转载 2015-07-07 22:23:57 · 424 阅读 · 0 评论 -
VC 操作串口
h = ::CreateFile(DeviceArray[i].strDevPath, GENERIC_READ|GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL/*|FILE_FLAG_OVERLAPPED*/, 0); res = (h != INVALID_HANDLE_VALUE) ? BM_DEV转载 2015-08-14 14:24:05 · 360 阅读 · 0 评论 -
VC解析XML
#pragma once#include "./XmlNode.h"#include "./Xsl.h"#include //-------------------------------------------------------------------------// Classes Name :CXml CXmlNode CXmlNodes// Aut转载 2015-08-05 17:40:33 · 1350 阅读 · 0 评论 -
格式转换
#include #include #include #include using namespace std;#define XMLSTR "\n"#define DICTSTR "\n"#define DICTEND "\n"#define WORDSTR "#define ENGLISH转载 2015-09-03 14:36:42 · 351 阅读 · 0 评论 -
VS 出现筛选器“xxx”下已存在项目“xxx.cpp”
1.先把xxx.cpp名字改变,然后在打开项目;2.把名字再改回去,重新编译即可原创 2016-12-09 13:20:25 · 3400 阅读 · 0 评论