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. Windows API
  4. to read from instream need ofsrream after ready to read in Vista

to read from instream need ofsrream after ready to read in Vista

Scheduled Pinned Locked Moved Windows API
c++csharpiosvisual-studioperformance
1 Posts 1 Posters 0 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.
  • K Offline
    K Offline
    kreena
    wrote on last edited by
    #1

    I am getting problem in ofstream and ifstream but only in vista envirnment with my visual studio 6.0 Visual C++ application. I am trying to support drag and drop feature for my application vista. Where in one .cpp file producer application is creating one .txt file that has information of objects that is going to be dragged to the consumer application. That text file is created in the virtual memory so I changed the location to physical memory. as seen below. That is all I have changed in producer side CString fileNameWithoutPath = dbObjTransferID + ".txt"; /*char tmpPath[_MAX_PATH];*/ CString cTempPath= "C:\\Program Files\\Common Files\\"; //VERIFY(GetTempPath(_MAX_PATH, ctmpPath)); CString fullyQualifiedTmpFile; fullyQualifiedTmpFile.Format("%s%s", cTempPath, fileNameWithoutPath); ofstream outStream(fullyQualifiedTmpFile, ios::out | ios::trunc); if (outStream.good()) { Am_Default_Load_Save_Context.Reset(); Am_Default_Load_Save_Context.Save(outStream, Am_Value(listOfItemsToSave)); outStream.close(); *phGlobal = GlobalAlloc(GMEM_FIXED | GMEM_SHARE | GMEM_ZEROINIT, fullyQualifiedTmpFile.GetLength() + 1); const char * pStr = fullyQualifiedTmpFile; memcpy(*phGlobal, pStr, fullyQualifiedTmpFile.GetLength()); bSuccess = TRUE; } else bSuccess = FALSE; IN THE CONSUMER SIDE: I am opening the filed that I have created wich has object information and trying to read that file but if I do not put some ambiguious code in it, it want work without it. Once I try to create ifstream object to read that file, I HAVE TO CREATE ONE MORE OFSTREAM TO LET DATA READ CORRECTLY USING THE IFSTREAM FILE. // copy the pFileName so that we can free the global memory. CString fileName = pFileName; GlobalUnlock(stgMedium.hGlobal); GlobalFree(stgMedium.hGlobal); ifstream inFile; inFile.clear(); inFile.open(fileName, ios::in); // This is the code I have to add in order to make drag and drop work. // I DO NOT WHY ???? CString copyfileName = "C:\\dndNonUsedfile.txt"; ofstream nFile(copyfileName, ios::out); if(inFile.good()) { Am_Value amVal; if(ReadTransferredDataFromFile(inFile, amVal)) if(amVal.Valid()) { versionObj = amVal; } inFile.close(); CFile::Remove(fileName); } nFile.close(); //Code to support vista

    Kreena Amin Software Enginee

    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