Code archives/User Libs/ICDBurn (dll source)

This code has been declared by its author to be Public Domain code.

Download source code

ICDBurn (dll source) by B+man
(Posted 21 years ago)
A few functions that allow blitz to record data CD's using the WinAPI ICDBurn interface...

C++ code, DECLS file and Blitz example are all in the document below!

Have fun!!!

:)

(P.S. If you don't write your own libs, or havent got VC++, I'll post the binarys etc etc tomorrow!)
//ICDBurn userlib functions (DLL source)
//Written by Michael Denathorn 2006
//
//Allows Blitz to record data CD's (use's the same process as
//burning CD's through Windows)
//Windows XP compatible only (I think!)
//Built using VC++ 7

/*
Functions

	GetBurnFolder				-	Returns the directory path where you should
									place your files, before burning them to disc

	IsRecordableDrive()			-	Returns true if there is a recordable CD Device 
									on the system
	
	GetRecordableDriveLetter()	-	Returns the drive letter of the recordable device
									e.g. 'E:\'

	BurnDisc(HWND hWnd)			-	Burn the data to disc... Parameter can be null (0)


*/



#include <windows.h>
#include <atlbase.h>
#include <atlstr.h>
#include <ShlObj.h>
#include <string.h>

#define BBDECL extern "C" _declspec(dllexport)
#define BBCALL _stdcall

class ICDBurnWrapper : public CComQIPtr<ICDBurn>
{
public:
	HRESULT result;

	ICDBurnWrapper() {
		result = CoCreateInstance(CLSID_CDBurn,NULL,
			CLSCTX_INPROC_SERVER|CLSCTX_LOCAL_SERVER);
	}

	~ICDBurnWrapper() { }

	BOOL Burn(HWND hwnd) {
		result = (*this)->Burn(hwnd);
		return SUCCEEDED(result);
	}
	BOOL HasRecordableDrive() {
		BOOL bHasIt=FALSE;
		result = (*this)->HasRecordableDrive(&bHasIt);
		return (SUCCEEDED(result) && bHasIt);
	}

	CString GetRecorderDriveLetter() {
		WCHAR d[32]={0};
		result = (*this)->GetRecorderDriveLetter(d, sizeof(d)/sizeof(d[0]));
	
		return d;
	}

	CString GetBurnFolderPath() {
		TCHAR path[MAX_PATH]={0};
		result = SHGetSpecialFolderPath(NULL, path, CSIDL_CDBURN_AREA, FALSE);
		return path;
	}
};

ICDBurnWrapper burner;

BBDECL const char *  BBCALL GetBurnFolder(void)
{
	return(burner.GetBurnFolderPath());
}

BBDECL BOOL BBCALL IsRecordableDrive(void)
{
	BOOL isThereOne;
	isThereOne = burner.HasRecordableDrive();
	return(isThereOne);
}

BBDECL const char *  BBCALL GetRecordableDriveLetter()
{
	return(burner.GetRecorderDriveLetter());
}

BBDECL BOOL  BBCALL BurnDisc(HWND hWnd)
{
	return(burner.Burn(hWnd));
}

/*
----------------- DECLS file --------------
.lib "ICDBurnDLL.dll"
GetBurnFolder$():"_GetBurnFolder@0"
IsRecordableDrive%():"_IsRecordableDrive@0"
GetRecordableDriveLetter$():"_GetRecordableDriveLetter@0"
BurnDisc%(hWnd%):"_BurnDisc@4"
*/


/*
----------------- Blitz Example --------------

;ICDBurn example
;Written by Michael Denathorn 2006
;
;CD copying for Blitz.. wahey!!! :)

Local burnFolder$,result,recordDrive$

;Find out where we must drop our files for windows to
;copy from
burnFolder$ = GetBurnFolder$()+"\"

;Check to see if there's a recordable drive on the system
result = IsRecordableDrive()
If result = True
;If so, grab the drive letter
recordDrive$ = GetRecordableDriveLetter$()
Else
Notify "There is no recordable CD drive on the system"
End
End If

;Output the details
Print "The staging area where we put our files is:-"
Print burnFolder$
Print "The recordable device is ["+recordDrive$+"]"

;Find a file
moveFilepath$ = RequestFile("Select a file:","",False)

;Grab the specific filename from the path
;(Probably a quicker way... but its late!)
For loop = Len(moveFilepath$) To 1 Step -1
	char$ = Mid$(moveFilepath$,loop,1)
	If char$ = "\" Then Exit
	tempfile$ = tempfile$ + char$
Next

For loop = Len(tempfile$) To 1 Step -1
	char$ = Mid$(tempfile$,loop,1)
	If char$ = "\" Then Exit
	file$ = file$ + char$
Next


;Copy the file selected to the staging area, a notification
;tooltip should appear telling you the file(s) are ready
Print "Moving "+file$+" to the staging folder..."
CopyFile(moveFilepath$,burnFolder$+file$)

;Burn the files
result=Confirm("Burn File(s)",True)
If result=1 Then 
result = BurnDisc(0)
Else
Notify "You cancelled the process!"
EndIf

Print "Finished!!!"
WaitKey

*/