CString 如何到头文件中

beautyzeb18 2005-05-16 03:21:58
#include <string>不行
换成#include <afx.h>报#include <windows.h>已经包含有了
到底是怎么回事?在线等待,希望路过的给看看.谢谢
...全文
202 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
beautyzeb18 2005-05-17
  • 打赏
  • 举报
回复
ATL工程中使用CString ,CFile类时,要导入afx.h,而且afx.h必须在导入atlbase.h前面被导入,此外工程还必须支持mfc类库,具体为什么这么做,我也不太清楚
beautyzeb18 2005-05-17
  • 打赏
  • 举报
回复
自己解决了!谢谢各位给的意见
xiao_xiao_zi 2005-05-16
  • 打赏
  • 举报
回复
把头文件里#include <windows.h>去掉
加上#include <afx.h>
beautyzeb18 2005-05-16
  • 打赏
  • 举报
回复

///////////////////////////////////////////////////////////////////////////////
//
// [ VerUpCommon.cpp ]
// Copyright (C) 2000 - 2000, Works Applications Corp.
// All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

//#include "StdAfx_Verup.h"
#include "VerUpCommon.h"
#include <shlwapi.h>
#include <odbcinst.h>
#include <sstream>
#include <list>
typedef std::list<tstring> tstrlist;
#include "WALib01CPP.h"
#include "AutoOleInit.h"
//#include <sqlenv.h>

///////////////////////////////////////////////////////////////////////////////

#define TCharSize(t) (sizeof(t) / sizeof(TCHAR))

///////////////////////////////////////////////////////////////////////////////

BOOL g_fRunningUnderNT;

beautyzeb18 2005-05-16
  • 打赏
  • 举报
回复
///////////////////////////////////////////////////////////////////////////////
//
// [ VerUpCommon.h ]
// Copyright (C) 2000 - 2000, Works Applications Corp.
// All Rights Reserved.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef _VERUPCOMMON_H_IS_INCLUDED
#define _VERUPCOMMON_H_IS_INCLUDED

///////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <vdmdbg.h>
#include <string>
#include <vector>
typedef std::basic_string<TCHAR> tstring;
typedef std::vector<tstring> tstrvect;

#import "../CompanyEx/CompanyEx.tlb" named_guids
using namespace COMPANYEXLib;
using namespace std;
extern HANDLE g_hEventEndSession;

///////////////////////////////////////////////////////////////////////////////

BOOL InitializeVerUpCommonModule(BOOL fRunningUnderNT);
BOOL UninitializeVerUpCommonModule();
BOOL IsVDMApp(LPCTSTR lpszExeFile);
BOOL OutputDebugLog(
LPCTSTR lpszMessage, BOOL fErrorLog = FALSE, DWORD dwError = 0
);
void ReleaseMonitor();
void SetLoggingMode(BOOL fEnableLogging);
void GetExtErrorMessage(DWORD dwExtError, LPTSTR lpszMessage);
//CString GetErrorMessageEx(DWORD dwError);

///////////////////////////////////////////////////////////////////////////////

typedef struct tagVDMPROCESSINFO {
tstring strExeFile;
DWORD dwProcessId;
BOOL fFound;
BOOL fCompareDirOnly;
DWORD dwProcessIdExclude;
} VDMPROCESSINFO;

BOOL GetVDMProcessId(LPCTSTR lpszVDMExeFile, DWORD& dwProcessId);
BOOL WINAPI EnumProcessProc(
DWORD dwProcessId, DWORD dwAttributes, LPARAM lpVDMProcessInfo
);
BOOL WINAPI EnumTaskProcEx(
DWORD dwThreadId,
WORD hMod16,
WORD hTask16,
PSZ pszModName,
PSZ pszFileName,
LPARAM lpVDMProcessInfo
);

BOOL GetPEProcessId(
LPCTSTR lpszPEExeFile, DWORD& dwProcessId, BOOL fSameDirOnly
);

typedef INT (WINAPI *VDMENUMPROCESSWOW)(PROCESSENUMPROC fp, LPARAM lparam);
typedef INT (WINAPI *VDMENUMTASKWOWEX)(
DWORD dwProcessId, TASKENUMPROCEX fp, LPARAM lparam
);

typedef HANDLE (WINAPI *CREATETOOLHELP32SNAPSHOT)(
DWORD dwFlags, DWORD th32ProcessID
);
BOOL IsSameDir(LPCTSTR lpszExe1, LPCTSTR lpszExe2);
BOOL ExistProcessInSameDir(
LPCTSTR lpszExeFile, DWORD dwProcessIdExclude = 0
);
BOOL ExistVDMProcessInSameDir(
LPCTSTR lpszExeFile, DWORD dwProcessIdExclude = 0
);
BOOL ExistPEProcessInSameDir(
LPCTSTR lpszExeFile, DWORD dwProcessIdExclude = 0
);
BOOL WaitForNoProcessInSameDir(
LPCTSTR lpszExeFile, DWORD dwProcessIdExclude = 0
);
BOOL ExistProcessInSameDirEx(
LPCTSTR lpszExeFile, DWORD dwProcessIdExclude = 0
);

int GetCurrentPtfNumber();
int GetCurrentPtfNumber(LPCTSTR lpszFileName);
BOOL PutCurrentPtfNumber(int iPtfNo);
BOOL PutCurrentPtfNumber(LPCTSTR lpszFileName, int iPtfNo);
BOOL CopyPtfNumberToLocalFile(LPCTSTR lpszFileName);
BOOL IsRunningUnderNT();
HRESULT GetBrowserVersion(LPDWORD pdwMajor, LPDWORD pdwMinor);
HRESULT CreateShortCut(
LPCTSTR pszShortcutFile, LPTSTR pszLink, LPTSTR pszDesc
);
BOOL GetDesktopFolder(LPTSTR lpszFolderPath, int nMax);
BOOL CheckWinInet();
BOOL RemoveDirectoryAndFiles(LPCTSTR lpszDirectory);
BOOL GetRegistryPrivilege(HWND hwnd, BOOL fShowError);

BOOL SetupOracleEnv(
LPCTSTR lpszDsn,
LPCTSTR lpszServer, LPCTSTR lpszSid, LPCTSTR lpszPort,
LPCTSTR lpszCMServer, LPCTSTR lpszCMPort
);
BOOL SetupDb2Env(
LPCTSTR lpszDsn,
LPCTSTR lpszServer, LPCTSTR lpszSid, LPCTSTR lpszPort
);
BOOL SetupBdeEnv(
LPCTSTR lpszDsn, LPCTSTR lpszSid, LPCTSTR lpszUid, LPCTSTR lpszPwd,
LPCTSTR lpszPdoxDir, LPCTSTR lpszBdeDll32Name = NULL
);
BOOL SetupBdeEnv_DB2(
LPCTSTR lpszDsn, LPCTSTR lpszSid, LPCTSTR lpszUid, LPCTSTR lpszPwd,
LPCTSTR lpszPdoxDir = NULL
);
BOOL SetupOdbcEnv(
LPCTSTR lpszDsn, LPCTSTR lpszSid, LPCTSTR lpszUid, LPCTSTR lpszPwd
);
CString GetOracleDllName(BOOL fFileNameOnly);
void FindFileFromDir(
LPCTSTR lpszFileName, LPCTSTR lpszDir, tstrvect& results
);

///////////////////////////////////////////////////////////////////////////////

#if !defined(_DEBUG)
#define DebugMessage(x) \
OutputDebugString(TEXT("Debug : ")); \
OutputDebugString(x); \
OutputDebugString(TEXT("\r\n"))
#else
#define DebugMessage DebugMessageProc
#endif

void DebugMessageProc(LPCTSTR lpszMessage);

///////////////////////////////////////////////////////////////////////////////

BOOL CompactMdb(
LPCTSTR lpszMdbPath, LPCTSTR lpszPassword = NULL,
tstring* pMessage = NULL
);
DWORD RegisterRunOnce(LPCTSTR lpszName, LPCTSTR lpszValue);
DWORD ReplaceRegistryValue(
HKEY hParentKey, LPCTSTR lpszSubKey, LPCTSTR lpszPrev, LPCTSTR lpszAfter
);
CString GetCompanyDirFromRegistry();
CString GetTempCompanyDirFromRegistry();
DWORD SetTempCompanyDirToRegistry(LPCTSTR lpszTempCompanyDir);

///////////////////////////////////////////////////////////////////////////////

#endif // !defined(_VERUPCOMMON_H_IS_INCLUDED)

// [ END OF FILE ] ////////////////////////////////////////////////////////////
beautyzeb18 2005-05-16
  • 打赏
  • 举报
回复
给大侠们看一下,我也不是很明白
就贴出.h和.cpp程序吧!
firmbird 2005-05-16
  • 打赏
  • 举报
回复
晕,你是什么类型的程序啊,是不是没选MFC支持
  • 打赏
  • 举报
回复
.h头文件(c风格)和c++风格的头文件,不能混用.
#include<string>
using namespace std;//ok

#include<string.h>//ok,euqal to the above

#include<string>
#include<iostream.h>
using namespace std;//不管使用不使用using 都出错

.h头文件可以看做暗含了using 指令
区别在:
.h的实现文件(.cpp)文件是没有模块化的
而c++风格的是已经模块化的,所以不要混用
beautyzeb18 2005-05-16
  • 打赏
  • 举报
回复
不行
OpenHero 2005-05-16
  • 打赏
  • 举报
回复
using namespace std;
行不?
看看
OpenHero 2005-05-16
  • 打赏
  • 举报
回复
命名空间

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧