谢谢!

解决方案 »

  1.   

    CString strYour;
    strYour.Format("%s",date +%C%y%m%d )
      

  2.   

    CString strYour;
    strYour.Format("%d",date +%C%y%m%d );
      

  3.   

    用CreateProcess(),可以用来得到控制台程序的返回字符串,这里是一个和delphi的例子:function ThreadComp.RunTerminal(const Prog, CommandLine,Dir: String;var ExitCode:DWORD): String;
    var
      HRead,HWrite:THandle;
      StartInfo:TStartupInfo;
      ProceInfo:TProcessInformation;
      b:Boolean;
      sa:TSecurityAttributes;
      inS:THandleStream;
      sRet:TStrings;
    begin
      Result := '';
      FillChar(sa,sizeof(sa),0);
      //ÉèÖÃÔÊÐí¼Ì³Ð£¬·ñÔòÔÚNTºÍ2000ÏÂÎÞ·¨È¡µÃÊä³ö½á¹û
      sa.nLength := sizeof(sa);
      sa.bInheritHandle := True;
      sa.lpSecurityDescriptor := nil;
      b := CreatePipe(HRead,HWrite,@sa,0);
      CheckResult(b);  FillChar(StartInfo,SizeOf(StartInfo),0);
      StartInfo.cb := SizeOf(StartInfo);
      StartInfo.wShowWindow := SW_HIDE;
      //ʹÓÃÖ¸¶¨µÄ¾ä±ú×÷Ϊ±ê×¼ÊäÈëÊä³öµÄÎļþ¾ä±ú,ʹÓÃÖ¸¶¨µÄÏÔʾ·½Ê½
      StartInfo.dwFlags     := STARTF_USESTDHANDLES+STARTF_USESHOWWINDOW;
      StartInfo.hStdError   := HWrite;
      StartInfo.hStdInput   := GetStdHandle(STD_INPUT_HANDLE);//HRead;
      StartInfo.hStdOutput  := HWrite;  b := CreateProcess(PChar(Prog),//lpApplicationName: PChar
             PChar(CommandLine),    //lpCommandLine: PChar
             nil,    //lpProcessAttributes: PSecurityAttributes
             nil,    //lpThreadAttributes: PSecurityAttributes
             True,    //bInheritHandles: BOOL
             CREATE_NEW_CONSOLE,
             nil,         
             PChar(Dir),
             StartInfo,
             ProceInfo    );  CheckResult(b);
      WaitForSingleObject(ProceInfo.hProcess,INFINITE);
      GetExitCodeProcess(ProceInfo.hProcess,ExitCode);  inS := THandleStream.Create(HRead);
      if inS.Size>0 then
      begin
        sRet := TStringList.Create;
        sRet.LoadFromStream(inS);
        Result := sRet.Text;
        sRet.Free;
      end;
      inS.Free;  CloseHandle(HRead);
      CloseHandle(HWrite);
    end;
      

  4.   

    CString str=date.Format("%Y%m%d");