2

I have a problem when trying to use CString.

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) Is that right ? 2) Can I avoid this problem somehow?

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

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

Thank you, and happy Easter !

Lumpi
  • 2,697
  • 5
  • 38
  • 47

2 Answers2

1

Yes it is right (CString is actually part of now-wedded MFC and ATL).

In almost all circumstances I found it trivial to translate the use of CString in som other string class (std::string comes to mind)

I'm not so sure whether the importing of typelibraries (#import) is fully supported in VSExpress, though. It could be - since COM is a binary standard and MIDL can generate pure C header files... but still :)

sehe
  • 374,641
  • 47
  • 450
  • 633
0

You could replace CString with CStdString

LaLeX
  • 188
  • 3
  • 13
  • Hi ! Thank you for that one! It looks like that the CString issue is solved by using your suggestion! – Lumpi Apr 23 '11 at 09:12