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

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

问题描述

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

I have a problem when trying to use CString.

我有一个使用VS2010Express编写的控制台应用程序。我有一个代码我想使用,但它使用CString。当我尝试包括适当的头atlstr.h(据我所知),我得到着名的错误:无法打开源文件。
Goggling过了一会儿似乎一般来说应该是可能的,但atlstr.h不适用于Express用户。
问题:

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)

如果任何人有一个Idea如何继续使用此代码,使用或不使用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:\Program\Delade filer\System\ado\msado15.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 来替换CString

You could replace CString with CStdString

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

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