vc雕虫小技集(二)
1,如果你没有定义_unicode,则lpctstr代表 const char * ,因此直接使用就可以了.
如果定义了_unicode ,lpctstr代表 const wchar_t* ,就不能直接使用了.
2,得到鼠标的位置
dword dw = getmessagepos();
cpoint pt(loword(dw),hiword(dw));//鼠标的屏幕坐标
cwnd::screentoclient();
3,得到文件的长度
方法一:handle hhandle;
dword dwsize;
hhandle = ::createfile((lpctstr)strzipfile,generic_read,
file_share_read,null,open_existing,file_attribute_normal,
null);
if(hhandle == invalid_handle_value)
return false;
dwsize = ::getfilesize(hhandle,null);
closehandle(hhandle);
方法二:cstring szfile="c:\aaa.txt";
int nfilesize=0;
cfilefind finder;
if(finder.findfile(szfile)){
finder.findnextfile();
nfilesize = finder.getlength(); //文件大小在这里