使用 VS Express 时在控制台应用程序中使用 CString [英] Use CString in console app when using VS Express

查看:24
本文介绍了使用 VS Express 时在控制台应用程序中使用 CString的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 CString 时遇到问题.

I have a problem when trying to use CString.

我有一个使用 VS2010Express 编写的控制台应用程序.我有一段代码想使用,但它使用 CString.当我尝试包含适当的头文件 atlstr.h(据我所知)时,我收到了著名的错误:无法打开源文件.经过一段时间的 Goggling 之后,似乎通常应该是可能的,但是 Express 用户无法使用 atlstr.h.问题:

I have a console application written using VS2010Express. I have a piece of code I would like to use, but it uses CString. When I try to include the appropriate header atlstr.h (as far as I know) I get the famous error: Cannot open source file. After Goggling around for a while it seems that in general it should be possible, but the atlstr.h is not available to Express users. Questions:

1) 是吗?2) 我能以某种方式避免这个问题吗?

1) Is that right ? 2) Can I avoid this problem somehow?

下面是代码,(来源:http://www.cprogramming.com/tutorial/ado_c++_wrapper_classes.html)

Below is the code, (origin: http://www.cprogramming.com/tutorial/ado_c++_wrapper_classes.html)

如果有人对我如何继续使用此代码有任何想法,无论是否使用 CString,请帮助我....

If anyone has an Idea how I can continue using this code, with or without the use of CString, please give me a hand....

#import "C:ProgramDelade filerSystemadomsado15.dll" rename ("EOF","adoEOF")       no_namespace


#include <atlstr.h>


class CADOConnection
{   private:

    _ConnectionPtr pConnection;
    CString m_szConnectionString;

    BOOL Initialize();


public:

    void SetConnectionString(CString& szConnectionString);
    TCHAR *GetConnectionString(){return m_szConnectionString);

    BOOL IsClosed();
    BOOL IsOpen();
    BOOL Open();
    BOOL Open(CString& szConnectionString, CString szUser=_T(""), CString   szPassword=_T(""));
    BOOL Close();

    CADOConnection(CString& szConnectionString);
    CADOConnection(void);
    ~CADOConnection(void);
};

谢谢,复活节快乐!

推荐答案

你可以用 CStdString

这篇关于使用 VS Express 时在控制台应用程序中使用 CString的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆