正文

C++常用知识2005-09-09 21:03:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/xboy/4558.html

分享到:

C++常用知识 1: 得到系统时间日期(使用GetLocalTime) CString sTime,sYear,sMonth,sDay; SYSTEMTIME CurTime; GetLocalTime(&CurTime); sYear.Format("%d年",CurTime.wYear); sMonth.Format("%d月",CurTime.wMonth); sDay.Format("%d日",CurTime.wDay); sTime =  sYear+ sMonth + sDay;   // CurTime.wHour   // CurTime.wMinute   // CurTime.wSecond IBM的 AfxMessageBox(sTime); 2: 分离字串 CString str = "4d3f0a2278"; unsigned char a[12]; long x; for(int i = 0;i< (str.GetLength()/2);i++) {   sscanf(str.Mid(2*i,2),"%x",&x);   a[i] = x; } 3: 得到当前目录 (GetCurrentDirectory) char  CurPath[MAX_PATH]; DWORD size=MAX_PATH; GetCurrentDirectory(size,CurPath); AfxMessageBox(CurPath); // CString number; int len = LineLength(LineIndex(0)); LPTSTR p=number.GetBuffer(len); this->GetLine(0,p,len); AfxMessageBox(number);    得到系统目录 (GetSystemDirectory) 4: 从字符串中提取数字 CString strNum; CString str("测试125各国87kk"); strNum = GetStr(str); AfxMessageBox(strNum);    5: 创建无模对话框 CDlg_Test *aa = new CDlg_Test; aa->Create(IDD_DIALOG1,NULL); aa->ShowWindow(SW_SHOW); 6: 得到窗口绝对坐标 CString strNum,strNum1; CRect rect; GetClientRect(&rect); ClientToScreen(&rect); strNum.Format("X: %d",rect.top); strNum1.Format("   Y: %d",rect.left); strNum = strNum + strNum1; AfxMessageBox(strNum); 7: 复制文件夹 SHFILEOPSTRUCT  Op; char FromBuf[]="E:\\temp\0"; char ToBuf[]="\\\\SINTEKSERVER\\个人文档\\陈 伟\0";; Op.hwnd = NULL; Op.wFunc = FO_COPY; Op.pFrom = FromBuf; Op.pTo = ToB

阅读(3068) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册