none
How to determine sector size?

    Question

  • I try to detect the sector size on the disk (in general), so I execute following code:

    	IWriteEngine2 *pWriteEngine = NULL;
    	HRESULT hResult = CoCreateInstance(__uuidof(MsftWriteEngine2), NULL, CLSCTX_INPROC_SERVER,
    		__uuidof(IWriteEngine2), (void**)&pWriteEngine);
    	if (FAILED(hResult) || pWriteEngine == NULL)
    	{
    		return hResult;
    	}
    	
    	IDiscRecorder2Ex *pExInterface = NULL;
    	hResult = m_discRecorder->QueryInterface(__uuidof(IDiscRecorder2Ex),(void**)&pExInterface);
    	if (FAILED(hResult) || pExInterface == NULL)
    	{
    		pWriteEngine->Release();
    		return hResult;
    	}
    
    	hResult = pWriteEngine->put_Recorder(pExInterface);
    	if (FAILED(hResult))
    	{
    		pExInterface->Release();
    		pWriteEngine->Release();
    		return hResult;
    	}
    
    	LONG lSectorSizeInBytes = 0;
    	hResult = pWriteEngine->get_BytesPerSector(&lSectorSizeInBytes);
    	pWriteEngine->Release();
    	pExInterface->Release();
    	if (FAILED(hResult))
    	{
    		return hResult;
    	}
    
    

    The code *seems* to work but returned size is always -1.

    Which is not what I need :)

     

    Also the entire approach seems to be a bit wrong to me (so I guess I clearly misunderstand it) . I mean I know that for CD, for example, user can burn it two different sector sizes , so how accessing recorder can give you the current sector size?

    I would expect something like that returned from the image or format interfaces, not from recorder.

    So what I missing here?

    Sunday, July 11, 2010 9:57 AM

Answers

  • Hi Roman,

    This method is not designed to retreive the bytes per sector of the media.  This can only be used in conjunction with put_BytesPerSector to retreive what was originally set.

    Note, all optical data discs use 2048 bytes per sector.

     

    Best Regards,

    Windows Optical Team

    Tuesday, July 27, 2010 9:40 PM

All replies

  • Hi Roman,

    This method is not designed to retreive the bytes per sector of the media.  This can only be used in conjunction with put_BytesPerSector to retreive what was originally set.

    Note, all optical data discs use 2048 bytes per sector.

     

    Best Regards,

    Windows Optical Team

    Tuesday, July 27, 2010 9:40 PM
  • You should make documentation more clear then.

    Thank you.

     

    Wednesday, July 28, 2010 5:56 AM