04 2012 档案
摘要:这种错误一般都是越界造成的,例如:char buffer[10];buffer[11] = '\0';参考:http://forums.codeguru.com/showthread.php?t=299770
阅读全文
摘要:当子窗口被建立,销毁或用户单击鼠标键时,WM_PARENTNOTIFY被发送使用如下:LRESULT WINAPI xxx_WndProc(HWND hwnd,UINT uMsg,WPARAM wParam,LPARAM lParam){ switch(uMsg) { HANDLE_MSG(hwnd,WM_PARENTNOTIFY, xxxx_OnParentNotify); } return( DefWindowProc(hwnd,uMsg,wParam,lParam));}void xxx_OnParentNotify(HWND hwnd, UINT msg, ...
阅读全文
摘要:void ImageFromIDResource(CImage& image, UINT nID, LPCTSTR lpType) { HINSTANCE hInst = g_hInst; HRSRC hRsrc = ::FindResource (hInst,MAKEINTRESOURCE(nID),lpType); if(hRsrc == NULL) return; DWORD dwLen = SizeofResource(hInst, hRsrc); BYTE* lpRsrc = (BYTE*)LoadResour...
阅读全文
摘要://删除文件或者文件夹bool DeleteFile(string strPath){ int nLen = strPath.length(); char* pPath = new char[nLen+2]; strcpy(pPath,strPath.c_str()); pPath[nLen+1]='\0'; SHFILEOPSTRUCT FileOp={0}; FileOp.fFlags = //FOF_ALLOWUNDO | //允许放回回收站 FOF_NOCONFIRMATION | //不出现确认对话框 FOF_NO...
阅读全文
摘要:7z a -tzip -p111 archive.7z txt.txt 压缩 密码为1117z x -tzip -p111 archive.7z 解压 密码为1117z.exe 是 7-Zip 的命令行版本。7z.exe 使用 7-Zip 的其它模块,7za.exe 是7-Zip 的独立版本,7za.exe 仅支持 7z、zip、gzip、bzip2 和 tar 格式,7za.exe 使用时不会调用其它模块。命令行选项7z [命令行] [[选项]...] [基本档案名称] [[参数变量]...]7z [command] [[switch]...] [base_archive_name...
阅读全文
摘要:cout<<(1>-2)<<endl; // 1 正常,都是有符号数 cout<<((unsigned int)1>-2)<<endl; // 0 -2被转换为无符号数. cout<<((unsigned int)1>-2.)<<endl; // 1 float不存在无符号数,所以,无符号数肯定大于float型的负数!以下实验均在virual c++6中运行通过这个问题测试是否懂得C语言中的整数自动转换原则,有些开发者懂得极少这些东西。当表达式中存在有符号类型和无符号类型时所有的操作数都自动转换为无符号类
阅读全文
摘要:如何在没有窗口的线程环境使用SetTimer()函数关键点:消息循环(GetMessage,DispatchMessage)必须和setTImer函数在同一个线程中。#include <iostream>#include <stdio.h>#include <windows.h>#define IDT_TIMER 100void CALLBACK TimerProc(HWND hwnd,UINT uMsg,UINT_PTR idEvent,DWORD dwTime){ SYSTEMTIME st; GetLocalTime(&st); printf(
阅读全文
摘要:今天写程序的时候用到GDI+,不过编译不通过。出现的错误为:1>------ Build started: Project: Label, Configuration: Debug Win32 ------1>Compiling...1>stdafx.cpp1>c:/program files/microsoft sdks/windows/v6.0a/include/gdiplusimaging.h(74) : error C4430: missing type specifier - int assumed. Note: C++ does not support de
阅读全文
摘要:问题:有时候用ifstream或ofstream打开带有中文路径的文件会失败。例如: ofstream outFile("f:\\新建文件夹\\fuck.xml",ios_base::trunc | ios_base::out | ios_base::binary); outFile<<"<xml></xml>"; outFile.close();解决方法1:使用wofstream wofstream outFile(_T("f:\\新建文件夹\\fuck.xml"),ios_base::trunc
阅读全文
摘要:#include <iostream>#include <cstring>using namespace std;int main(){ if(-1<=strlen("Hello world")) { cout<<"-1<=strlen(\"Hello world\")"<<endl; } int nLen=strlen("Hello world"); if(-1<=nLen) { cout<<"-1<="<
阅读全文
摘要:include <iostream>#include <map>using namespace std;int main(){ map<string,map<string,string> > mapmaps; map<string,string> mapmap; mapmap.insert(pair<string,string>("ysl","ysh")); mapmaps.insert(pair<string,map<string,string> >(&qu
阅读全文
摘要:今天意外见识了这个名词是在CSDN帖子里http://topic.csdn.net/u/20120406/03/f59790a9-67b8-479c-9f43-9bc413fae761.html?95101 其实这个困惑早就出现了,记得最早是看到了这篇文章http://www.cnblogs.com/wenzhang/archive/2011/12/30/2308052.html,当时还请教了作者,但始终没有说服自己的理由,今天 再看到确实有种乞重见老朋友的感觉,所以就上网搜搜这方面的帖子了。 首先来看一个简单的例子吧:#include <iostream>using namesp
阅读全文
摘要:#include <windows.h>int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil){ char system[MAX_PATH]; char pathtofile[MAX_PATH]; HMODULE GetModH = GetModuleHandle(NULL); //得到当前执行文件的全路径 GetModuleFileName(GetModH,pathtofile,sizeof(pathtof...
阅读全文
摘要:先使用InternetOpen初始化WinINet函数,然后在使用InternetOpenUrl打开指定链接,最后就用InternetReadFile就能读取到网页源代码.下面的代码能够打开http://www.baidu.com/并且将网页源代码打印出来.#include <stdio.h>#include <windows.h>#include <wininet.h>#pragma comment(lib,"Wininet.lib")#include <vector>using namespace std; int mai
阅读全文