Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionannouncement
6 Posts 6 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    learningvisualc
    wrote on last edited by
    #1

    Hi all, I am using IPersistFile::Save Method. My problem is i am passing a CString variable in this function and compiler is giving error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

    hres = ppf->Save(szLinkName,TRUE);
    ppf>Release();

    szLinkName is a CString variable which is being passed in this function.. How can i convert it??? Thanks in advance

    J I CPalliniC T 4 Replies Last reply
    0
    • L learningvisualc

      Hi all, I am using IPersistFile::Save Method. My problem is i am passing a CString variable in this function and compiler is giving error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

      hres = ppf->Save(szLinkName,TRUE);
      ppf>Release();

      szLinkName is a CString variable which is being passed in this function.. How can i convert it??? Thanks in advance

      J Offline
      J Offline
      Jonathan Davies
      wrote on last edited by
      #2

      Try: Please tell my how to change from cstring to LPOLESTR and make my code right: [^]

      1 Reply Last reply
      0
      • L learningvisualc

        Hi all, I am using IPersistFile::Save Method. My problem is i am passing a CString variable in this function and compiler is giving error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

        hres = ppf->Save(szLinkName,TRUE);
        ppf>Release();

        szLinkName is a CString variable which is being passed in this function.. How can i convert it??? Thanks in advance

        I Offline
        I Offline
        Intersect
        wrote on last edited by
        #3

        Before you pass your CString convert it into BSTR or LPCOLESTR const LPCOLESTR* pCole; int iLen = strlen(szLinkName); memcpy(pCole,szLinkName,iLen); hres = ppf->Save(pCole,TRUE); ppf->Release();

        S 1 Reply Last reply
        0
        • L learningvisualc

          Hi all, I am using IPersistFile::Save Method. My problem is i am passing a CString variable in this function and compiler is giving error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

          hres = ppf->Save(szLinkName,TRUE);
          ppf>Release();

          szLinkName is a CString variable which is being passed in this function.. How can i convert it??? Thanks in advance

          CPalliniC Offline
          CPalliniC Offline
          CPallini
          wrote on last edited by
          #4

          try

          CStringW wszLinkName(szLinkName);
          hres = ppf->Save(wszLinkName,TRUE);
          ppf>Release();

          :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          In testa che avete, signor di Ceprano?

          1 Reply Last reply
          0
          • I Intersect

            Before you pass your CString convert it into BSTR or LPCOLESTR const LPCOLESTR* pCole; int iLen = strlen(szLinkName); memcpy(pCole,szLinkName,iLen); hres = ppf->Save(pCole,TRUE); ppf->Release();

            S Offline
            S Offline
            Stephen Hewitt
            wrote on last edited by
            #5

            @Intersect☺™ wrote:

            const LPCOLESTR* pCole; int iLen = strlen(szLinkName); memcpy(pCole,szLinkName,iLen); hres = ppf->Save(pCole,TRUE); ppf->Release();

            Note the parts I've underlined. This code will cause nothing but trouble.

            Steve

            1 Reply Last reply
            0
            • L learningvisualc

              Hi all, I am using IPersistFile::Save Method. My problem is i am passing a CString variable in this function and compiler is giving error C2664: 'IPersistFile::Save' : cannot convert parameter 1 from 'CString' to 'LPCOLESTR'.

              hres = ppf->Save(szLinkName,TRUE);
              ppf>Release();

              szLinkName is a CString variable which is being passed in this function.. How can i convert it??? Thanks in advance

              T Offline
              T Offline
              ThatsAlok
              wrote on last edited by
              #6

              what about using #define UNICODE 1

              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
              Never mind - my own stupidity is the source of every "problem" - Mixture

              cheers, Alok Gupta VC Forum Q&A :- I/IV Support CRY- Child Relief and You

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups