VC雕虫小技集(二)[1]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 he_zhidan 的 blog

 

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();    //文件大小在这里

本文关键:VC 雕虫小技集
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top