By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,513 Members | 1,693 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,513 IT Pros & Developers. It's quick & easy.

imapi staging image for record iz on CD WINxp

P: 4
Hi to all, this is my first post here so I'm hoping you can help me. Now I'm writing a app which, among all other things need to record some data to CD. I'm using IMAPI v1 and here is the problem: i cant create an staging image, this is the part of my code:
Expand|Select|Wrap|Line Numbers
  1. ...
  2. IStorage* pStorage = NULL;
  3. IStream* pStream;
  4. int i=0;
  5. StgCreateDocfile( NULL, STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, &pStorage);
  6.  
  7. CFile files[32];
  8.  
  9. //filenames is CStringList which is populated by users choice of files they want to record on CD
  10. POSITION pos = filenames.GetHeadPosition();
  11. while(pos != NULL)
  12. {
  13. CString strFilePath=filenames.GetNext(pos);
  14.  
  15. int nSize = 0;
  16. CFileException e;
  17.  
  18. if (filesIdea.Open(strFilePath,CFile::modeRead|CFile::typeBinary,&e))
  19. {
  20. LPWSTR lpszW = new WCHAR[255];
  21. LPTSTR lpStr = strFilePath.GetBuffer( strFilePath.GetLength() );
  22. int nLen = MultiByteToWideChar(CP_ACP, 0,lpStr, -1, NULL, NULL);
  23. int code = MultiByteToWideChar(CP_ACP, 0, strFilePath, -1, pszW,nLen);
  24. if(!code)
  25. {
  26. CString tmp = _T("'MultiByteToWideChar' returns NULL!");
  27. DWORD err = GetLastError();
  28. DisplayErrorString(tmp,err);
  29. if (lpszW)
  30. delete [] lpszW;
  31. filesIdea.Close();
  32. pDiscMaster->ClearFormatContent();
  33. return FALSE;
  34. }
  35.  
  36. HRESULT res;
  37. if( (res = pStorage->CreateStream( lpszW, STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_FAILIFTHERE, 0, 0, &pStream) ) != S_OK )
  38. {!!!HERE IT'S CRACKS SAYING "Invalid value for pwcsName." (lpszW???)
  39. ShowHRError(res);
  40. if (lpszW)
  41. delete [] lpszW;
  42. filesIdea.Close();
  43. pDiscMaster->ClearFormatContent();
  44. return FALSE;
  45. }
  46. nSize = files[i].GetLength();
  47. BYTE *pBuffer = new BYTE[nSize];
  48. if (files[i].Read(pBuffer,nSize) > 0)
  49. {
  50. pStream->Write(pBuffer,nSize,NULL);
  51. pStream->Release();
  52. }
  53. files[i].Close();
  54. delete[] pBuffer;
  55. }
  56.  
  57. ...
  58.  
As I put it my code breaks in line 37.
I'm trying to find code example which works?? Or someone who can tell me where I did wrong??Why can't I create stream, what is wrong with lpszW?
THX to all!
May 29 '07 #1
Share this Question
Share on Google+
2 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
Per Microsoft docs lpszW:
must not exceed 31 characters in length (not including the string terminator). The 000 through 01f characters, serving as the first character of the stream/storage name, are reserved for use by OLE. This is a compound file restriction, not a structured storage restriction.
Does your lpszW fconform to this?
May 29 '07 #2

P: 4
Per Microsoft docs lpszW:

Does your lpszW fconform to this?
I'm aweare of that!

Can I burn both directories and files?
May 30 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.