josip cagalj

I created application to burn data to CD. But I had a problem to burn a folder (couldn't get the app to burn root folder, only subfolders and files). After I solved that I had another problem, stuff I need to record has >31 characters in a filename. So I used:
IShellFolder* pFolder, and
pFolder->BindToStorage(...),
instead IStorage, but (again) I couldn't burn the root folder, only it's content!
I'm going to try with imapi v2 on XP. My configuration is VC6++ on Win XP. I've downloaded and installed Feb2003 SDK then (for v1), but now I need to download the whole SDK for Vista and drag out all headers / IDL / TLB for IMAPIv2 and placed them where On the same place I installed my previous SDK (Feb2003) Could I used them (headers / IDL / TLB) in a VC6++
One more thing please, if there is a code sample in VC++
I'm sorry if I'm boring you too much! BIG THANKS in advance for your trouble!

P.S.
Was it enough to run "WindowsXP-KB932716-x86-ENU.exe."


Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

Garrett - MSFT

Hello Josip,

I would recommend you use IMAPIv2 for your burning needs. It will provide much simpler interface and we can provide much better support for it here!

There are a few code samples in VC++ that ship as part of the SDK, look for imapi2sample as the biggest one.

And yes, it was enough to run that update package to install the IMAPIv2 binaries. IMAPIv1 will continue to work on the system and continue to use the old burning code though...

Please let me know if you have any further questions!

thanks,

Garrett Jacobson

SDE, Optical Platform Group






Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

josip cagalj

Well, you ask for it !
I'm using code from Imapi2Sample to my app(VC6++), and I get "Unhandled exception in my_app.exe: 0xC0000005: Access Violation" msg on:

hr = root->AddTree(dir, true);.

code sample;
//CString strFilePath - full path to directory(e.g. c:/something/sonething/dir_name)
USES_CONVERSION;
BSTR name = T2W(strFilePath.operator LPCTSTR());
dir = :Tongue TiedysAllocString( name ); // (emotion clip is hiding: 'SysAllocString' line)
hr = root->AddTree(dir, true);

I set second parameter to true because I want the root directory to be present on media!
Please help, thanks!




Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

Garrett - MSFT

Hello Josip,

To better assist you, I'd need to find out where root came from.

My guess is that an AV (access violation) on this line is due to the fact that the root variable is NULL or improperly set up. Did you use CoCreateInstance to make an IFileSystemImage object and then get the Root node from that interface

Thanks,

Garrett Jacobson

SDE, Optical Platform Group






Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

josip cagalj

Hi, thank you again it works now!
I have another question: how to find out if the media inserted is previously been closed
When I try to record more data to an a closed media I get "IMAPI_E_NO_COMPATIBLE_MULTISESSION_TYPE" !
is that what I need to expect, so that I can put out a message box to a user and warn him Or is there another way to find out
Big thanks!
P.S. (edited)
I think I find out:
IDiscFormat2Data::get_CurrentMediaStatus, and get:
IMAPI_FORMAT2_DATA_MEDIA_STATE_FINALIZED !






Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

Garrett - MSFT

Hello Josip,

Yup, you've got it! Checking the media state using get_CurrentMediaStatus is a good way to determine if a disc is appendable or finalized...

Please let me know if you have any further questions!

thanks,

Garrett Jacobson

SDE, Optical Platform Group






Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

josip cagalj

Hi.
I've did some testing and all works fine but when I insert CD I've previously closed ( put_ForceMediaToBeClosed(TRUE) ), I get '40960' for IMAPI_FORMAT2_DATA_MEDIA_STATE value. This is not any of defined values!

Another thing, I'm having trouble with adding files (IFsiDirectoryItem::AddFile), here is my code:

IStorage* pStorage = NULL;
IStream* pStream;
CFile f;
CFileException e;
BSTR file,dir;

BSTR name = T2W(strFilePath.operator LPCTSTR());

HRESULT hr_doc = StgCreateDocfile( NULL, STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, NULL, &pStorage);
if (f.Open(strFilePath,CFile::modeRead,&e))
{
USES_CONVERSION;
CString ime = f.GetFileName();
HRESULT res;
res = pStorage->CreateStream( T2W(ime.operator LPCTSTR()), STGM_DIRECT|STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE|STGM_FAILIFTHERE, 0, 0, &pStream) ;
ULONG nSize = f.GetLength();
BYTE *pBuffer = new BYTE[nSize];
if (f.Read(pBuffer,nSize) > 0)
{
hr_doc = pStream->Write(pBuffer,nSize,NULL);
}
f.Close();
delete[] pBuffer;
}
file = :Tongue TiedysAllocString( name );
hr = root->AddFile(file, pStream); //FAILES HERE (returns 'c0aab11a')
hr_doc = pStream->Release();

where 'strFilePath' is a full pathname of a file!

Is this not a good way to add a file to be recorded on media
Once again THANK YOU wery much!




Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

josip cagalj

Error state -> IMAPI_E_DIR_NOT_FOUND (not found in FileSystemImage hierarchy)
What I need to do




Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

Garrett - MSFT

Hello Josip,

IMAPI_E_DIR_NOT_FOUND indicates that the path you passed into AddFile probably contains more than a filename (possibly a directory too ) and that this directory path is not already created in the filesystem. So if you passed "imapi2\test.txt" into the AddFile call to the root directory, you would have already had to create a directory in root called "imapi2". Please ensure that the path you passed in is correct relative to the root and all directories in the path have already been created...

Also, the media state value is a bit field, meaning that each MEDIA_STATE value represents one bit, 40960 = 0xA000 = (0x8000 | 0x2000). If you look up those two values, you'll see that this indicates IMAPI_FORMAT2_DATA_MEDIA_STATE_WRITE_PROTECTED and IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MEDIA. It's probably unsupported right now BECAUSE it's write protected.

The best way to check for values is to AND the MEDIA_STATE enumeration value with the value returned from the get_ function to see if a particular flag is set. For example:

if (mediaState & IMAPI_FORMAT2_DATA_MEDIA_STATE_UNSUPPORTED_MEDIA)

{

// this is unsupported media!

}

Please let me know if you have any further questions!

thanks,

Garrett Jacobson

SDE, Optical Platform Group






Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

josip cagalj

You've right, my file has several directory's in it's path which I passed into AddFile() as a first parametar!
For e.g. in my code sample:
my strFilePath : C:/folder1/folder2/my.txt
How can I create a directory in root for folder1 and folder2
, and just than I can call AddFile() as I did in my code sample
Thanks
P.S.
Is my second parametar to AddFile() the IStream OK




Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

josip cagalj

If full pathname of my file is like:
c:\folder1\folder2\my_filename.abc,
how to get it to record to media. How to create folder1 and folder2 to root
Still don't get it. Help please!




Re: Optical Platform Discussion Dev system install of Vista SDK on Windows XP for IMAPIv2

Henry Gabryjelski - MSFT

I already answered this question on your other thread:

http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1891698&SiteID=1

hth,

.