几块VC中的常用代码

   主要是回顾一下VC的常用知识,包括得到系统时间日期(使用GetLocalTime)、分离字串等。

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);

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值