Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 36041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:19:51+00:00 2026-05-10T14:19:51+00:00

We need to programatically burn files to CD in a C\C++ Windows XP/Vista application

  • 0

We need to programatically burn files to CD in a C\C++ Windows XP/Vista application we are developing using Borlands Turbo C++.

What is the simplest and best way to do this? We would prefer a native windows API (that doesnt rely on MFC) so as not to rely on any third party software/drivers if one is available.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:19:52+00:00Added an answer on May 10, 2026 at 2:19 pm

    We used the following:

    Store files in the directory returned by GetBurnPath, then write using Burn. GetCDRecordableInfo is used to check when the CD is ready.

    #include <stdio.h> #include <imapi.h> #include <windows.h>  struct MEDIAINFO {     BYTE nSessions;     BYTE nLastTrack;     ULONG nStartAddress;     ULONG nNextWritable;     ULONG nFreeBlocks; }; //============================================================================== //  Description:    CD burning on Windows XP //============================================================================== #define CSIDL_CDBURN_AREA               0x003b SHSTDAPI_(BOOL) SHGetSpecialFolderPathA(HWND hwnd, LPSTR pszPath, int csidl, BOOL fCreate); SHSTDAPI_(BOOL) SHGetSpecialFolderPathW(HWND hwnd, LPWSTR pszPath, int csidl, BOOL fCreate); #ifdef UNICODE #define SHGetSpecialFolderPath  SHGetSpecialFolderPathW #else #define SHGetSpecialFolderPath  SHGetSpecialFolderPathA #endif //============================================================================== // Interface IDiscMaster const IID IID_IDiscMaster = {0x520CCA62,0x51A5,0x11D3,{0x91,0x44,0x00,0x10,0x4B,0xA1,0x1C,0x5E}}; const CLSID CLSID_MSDiscMasterObj = {0x520CCA63,0x51A5,0x11D3,{0x91,0x44,0x00,0x10,0x4B,0xA1,0x1C,0x5E}};  typedef interface ICDBurn ICDBurn; // Interface ICDBurn const IID IID_ICDBurn =    {0x3d73a659,0xe5d0,0x4d42,{0xaf,0xc0,0x51,0x21,0xba,0x42,0x5c,0x8d}}; const CLSID CLSID_CDBurn = {0xfbeb8a05,0xbeee,0x4442,{0x80,0x4e,0x40,0x9d,0x6c,0x45,0x15,0xe9}};  MIDL_INTERFACE('3d73a659-e5d0-4d42-afc0-5121ba425c8d') ICDBurn : public IUnknown { public:     virtual HRESULT STDMETHODCALLTYPE GetRecorderDriveLetter(         /* [size_is][out] */ LPWSTR pszDrive,         /* [in] */ UINT cch) = 0;      virtual HRESULT STDMETHODCALLTYPE Burn(         /* [in] */ HWND hwnd) = 0;      virtual HRESULT STDMETHODCALLTYPE HasRecordableDrive(         /* [out] */ BOOL *pfHasRecorder) = 0; }; //============================================================================== //  Description:    Get burn pathname //  Parameters:     pathname - must be at least MAX_PATH in size //  Returns:        Non-zero for an error //  Notes:          CoInitialize(0) must be called once in application //============================================================================== int GetBurnPath(char *path) {     ICDBurn* pICDBurn;     int ret = 0;      if (SUCCEEDED(CoCreateInstance(CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) {         BOOL flag;         if (pICDBurn->HasRecordableDrive(&flag) == S_OK) {             if (SHGetSpecialFolderPath(0, path, CSIDL_CDBURN_AREA, 0)) {                 strcat(path, '\\');             }             else {                 ret = 1;             }         }         else {             ret = 2;         }         pICDBurn->Release();     }     else {         ret = 3;     }     return ret; } //============================================================================== //  Description:    Get CD pathname //  Parameters:     pathname - must be at least 5 bytes in size //  Returns:        Non-zero for an error //  Notes:          CoInitialize(0) must be called once in application //============================================================================== int GetCDPath(char *path) {     ICDBurn* pICDBurn;     int ret = 0;      if (SUCCEEDED(CoCreateInstance(CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) {         BOOL flag;         WCHAR drive[5];         if (pICDBurn->GetRecorderDriveLetter(drive, 4) == S_OK) {             sprintf(path, '%S', drive);         }         else {             ret = 1;         }         pICDBurn->Release();     }     else {         ret = 3;     }     return ret; } //============================================================================== //  Description:    Burn CD //  Parameters:     None //  Returns:        Non-zero for an error //  Notes:          CoInitialize(0) must be called once in application //============================================================================== int Burn(void) {     ICDBurn* pICDBurn;     int ret = 0;      if (SUCCEEDED(CoCreateInstance(CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) {         if (pICDBurn->Burn(NULL) != S_OK) {             ret = 1;         }         pICDBurn->Release();     }     else {         ret = 2;     }     return ret; } //============================================================================== bool GetCDRecordableInfo(long *FreeSpaceSize) {     bool Result = false;     IDiscMaster *idm = NULL;     IDiscRecorder *idr = NULL;     IEnumDiscRecorders *pEnumDiscRecorders = NULL;     ULONG cnt;     long type;     long mtype;     long mflags;     MEDIAINFO mi;      try {         CoCreateInstance(CLSID_MSDiscMasterObj, 0, CLSCTX_ALL, IID_IDiscMaster, (void**)&idm);         idm->Open();         idm->EnumDiscRecorders(&pEnumDiscRecorders);         pEnumDiscRecorders->Next(1, &idr, &cnt);         pEnumDiscRecorders->Release();          idr->OpenExclusive();         idr->GetRecorderType(&type);         idr->QueryMediaType(&mtype, &mflags);         idr->QueryMediaInfo(&mi.nSessions, &mi.nLastTrack, &mi.nStartAddress, &mi.nNextWritable, &mi.nFreeBlocks);         idr->Release();          idm->Close();         idm->Release();         Result = true;     }     catch (...) {         Result = false;     }      if (Result == true) {         Result = false;         if (mtype == 0) {             //  No Media inserted             Result = false;         }         else {             if ((mflags & 0x04) == 0x04) {                 // Writable Media                 Result = true;             }             else {                 Result = false;             }              if (Result == true) {                 *FreeSpaceSize = (mi.nFreeBlocks * 2048);             }             else {                 *FreeSpaceSize = 0;             }         }     }      return Result; } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to programatically Insert a contact to outlook Contact using C# application. I
I need to merge a whole bunch of docx files programatically. Imagine they are
I am creating a C# Windows Mobile application that I need to programmatically invoke
I need to programatically encrypt a directory of files, like in a .zip or
I need to programatically interface with SharePoint folders, files and lists from outside SharePoint.
I need to programatically determine whether .NET 3.5 is installed. I thought it would
My current program need to use programatically create a XPathExpression instance to apply to
I need to programatically append to a multi-page TIFF or PDF a new image.
I need help programatically graphing more points than can fit in a single Excel
I am in a need of programatically convert an Word-XML file into a RTF

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.