unit audiocdburnxp;
interface
uses windows,shlobj,dialogs,shellapi; //,ole2  - seems to be borked in 2006 -
// Can get round it by copying the ole2.pas file to project dir, but is a borland file

function GetStagingPath : string;
function GoBurn : integer;

{type
IUnknown = interface
    ['{00000000-0000-0000-C000-000000000046}//']
    {function QueryInterface(const IID: TGUID; out Obj): HResult; stdcall;
    function _AddRef: Integer; stdcall;
    function _Release: Integer; stdcall;
end;
    }

type
ICDBURN = interface (system.IUnknown)
    ['{3d73a659-e5d0-4d42-afc0-5121ba425c8d}']
function GetRecordDriveLetter(const pszDrive : LPWSTR;out cch : integer) : hresult;stdcall;
function Burn(out hand : hwnd) : hresult;stdcall;
function HasRecordableDrive(const pfHasrecorder : boolean) : hresult;stdcall;
end;




const
CLASS_E_NOAGREEGATION = 040110;
E_NOINTERFACE = 004002;
REGDB_ECLASSNOTREG = 040154;
S_OK = 0;
CLSID_BURN : TGUID = '{fbeb8a05-beee-4442-804e-409d6c4515e9}';
IID_BURN : TGUID =  '{3d73a659-e5d0-4d42-afc0-5121ba425c8d}';
CSIDL_CDBURN_AREA  = {viewgit}{/viewgit}3b;

implementation

function GetStagingPath : string;
var
stagingpath : string;
pstagingpath : pchar;
begin
result:='';
getmem(pstagingpath,MAX_PATH+1);
fillchar(stagingpath,sizeof(stagingpath),0);
SHGetSpecialFolderPath(0,PStagingPath,CSIDL_CDBURN_AREA,false);
stagingpath:=string(pstagingpath);
freemem(pstagingpath);
result:=stagingpath;
end;

function GoBurn : integer;
//var
//OBurn : ICDBurn;
//hr : HResult;
//th : HWND;
begin
//hr:=CoCreateInstance(CLSID_Burn, nil,CLSCTX_INPROC_SERVER,IID_Burn,oburn);
//if hr<>0 then begin
//messagedlg('Windows XP CD Writing extensions are not availiable on this system.',mtWarning,[mbOk],0);
//result:=-1;
//end
//else begin
//result:=0;
//th:=0;
//oburn.burn(th);
//end;
result:=0;
end;

end.