







|
Backup-Burner SDK (page 2)
|
|
|
NOTE: THIS SOFTWARE IS ONLY FOR USE BY SOFTWARE AUTHORS.
IF YOU DON'T WRITE SOFTWARE, DON'T TRY TO USE THIS.
|
To use Backup-Burner, your preferred i386 language would copy the desired files
and folders to the designated folder, load the .dll and call a function.
That's all there is to it.
The following is example source code you would use in your programs to perform a
CD or DVD recording using Backup-Burner. Scroll down to see
Visual C++, BCB,
Delphi, Visual Basic, and
C#. These are just excerpts, see the .cpp and
.pas files in the SDK for more details. (
Return to page 1
)
Microsoft Visual C++ and Borland C++ Builder
// ----------------------------------------------------------------------------
//
// Project File: CallingBB.CPP
// A program that uses LoadLibrary to access MakeBackupCD from BackupBurner.dll.
//
// Compiles in Visual C++ 6 SP5 and BCB5 without warnings or errors.
//
// ----------------------------------------------------------------------------
#include <windows.h>
VOID main(VOID)
{
// Uses a StdCall calling convention.
// CALLBACK is not required in BCB.
typedef int (CALLBACK *MakeBackupCDPtr)( const char *szBBRegName,
const char *szBBRegCode,
const char *szBBVolume,
const char *szBBTitle,
const char *szBBColorForm,
const char *szBBColorText,
const char *szPathtoBinFolder,
char *szBBFutureUse);
MakeBackupCDPtr lpfnMakeBackupCD;
HINSTANCE hDLL; //Choose one
//HMODULE hDLL;
int iResultCode;
char szBBRegName[32];
char szBBRegCode[512];
char szBBVolume[32];
char szBBTitle[128];
char szBBColorForm[32];
char szBBColorText[32];
char szPathtoBinFolder[512];
char szBBFutureUse[512];
strcpy(szBBRegName , "DEMOUSER");
strcpy(szBBRegCode , "ABCD1234");
strcpy(szBBVolume , "MyBackupDisc"); //What ever you want here, but no spaces allowed
strcpy(szBBTitle , "My Project's Name is __");//This shows up on the form.
strcpy(szBBColorForm , "clSilver");//default is clSilver, don't use hex color
strcpy(szBBColorText , "clBlack");//default is clBlack, don't use hex color
strcpy(szPathtoBinFolder, "c:\\myprogpath\\FilesToBackup\\");
strcpy(szBBFutureUse , "");
hDLL = LoadLibrary("\\Bin\\BackupBurner.dll");
if(hDLL == NULL)
{
// handle error
exit(1);
}
lpfnMakeBackupCD = (MakeBackupCDPtr) GetProcAddress(hDLL, "MakeBackupCD");
if(lpfnMakeBackupCD == NULL)
{
// handle error
exit(1);
}
iResultCode = (*lpfnMakeBackupCD)( szBBRegName,
szBBRegCode,
szBBVolume,
szBBTitle,
szBBColorForm,
szBBColorText,
szPathtoBinFolder,
szBBFutureUse);
switch (iResultCode)
{
case -2:// ResultCode = -2 Installation Error- version mismatch';
break;
case -1:// ResultCode = -1 User canceled' ;
break;
case 0: // ResultCode = 0 it was a successful burn!
break;
case 1: // ResultCode = 1 User canceled
break;
case 2: // ResultCode = 2 Installation Error- files missing';
break;
case 3: // ResultCode = 3 Insufficent disk space';
break;
case 5: // ResultCode = 5 there was not a blank disc';
break;
case 7: // ResultCode = 7 bad burn during writing ';
break;
case 8: // ResultCode = 8 no CD/DVD recorder detected. (or no admin rights )
break;
case 9: // ResultCode = 9 Demo expired.'
break;
default:
break;
}
FreeLibrary(hDLL);
exit(0);
}
|
Microsoft Visual C#
// ----------------------------------------------------------------------------
//
// Project File: CallingBB.cs
// A partial program that uses DllImport to access MakeBackupCD from BackupBurner.dll.
// As compared to C++, this particular solution doesn't allow for Dynamic binding of the DLL,
// although it works if you're sure the dll is going to be in the same place.
//
// C# port courtesy Michael Malinak.
// Should compile in Visual C# without errors.
//
// ----------------------------------------------------------------------------
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace CSBackupBurner
{
public class BackupBurner
{
// Get function reference into DLL
[DllImport(@"C:\myprogpath\Bin\BackupBurner.dll")]
public extern static int MakeBackupCD(
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBRegName,
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBRegCode,
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBVolume,
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBTitle,
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBColorForm,
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBColorText,
[MarshalAs(UnmanagedType.LPArray)] byte[] szPathtoBinFolder,
[MarshalAs(UnmanagedType.LPArray)] byte[] szBBFutureUse);
BackupBurner()
{}
public int BurnCD()
{
byte[] szBBRegName = new byte[32];
byte[] szBBRegCode = new byte[512];
byte[] szBBVolume = new byte[32];
byte[] szBBTitle = new byte[128];
byte[] szBBColorForm = new byte[32];
byte[] szBBColorText = new byte[32];
byte[] szPathtoBinFolder = new byte[512];
byte[] szBBFutureUse = new byte[512];
Encoding.ASCII.GetBytes("DEMOUSER").CopyTo(szBBRegName,0);
Encoding.ASCII.GetBytes("ABCD1234").CopyTo(szBBRegCode,0);
Encoding.ASCII.GetBytes("MyBackupDisc").CopyTo(szBBVolume,0);
Encoding.ASCII.GetBytes("My Project's Name is __").CopyTo(szBBTitle,0);
Encoding.ASCII.GetBytes("clSilver").CopyTo(szBBColorForm,0);
Encoding.ASCII.GetBytes("clBlack").CopyTo(szBBColorText,0);
Encoding.ASCII.GetBytes(@"C:\myprogpath\FilesToBackup\").CopyTo(szPathtoBinFolder,0);
Encoding.ASCII.GetBytes("").CopyTo(szBBFutureUse,0);
int result = MakeBackupCD(
szBBRegName,
szBBRegCode,
szBBVolume,
szBBTitle,
szBBColorForm,
szBBColorText,
szPathtoBinFolder,
szBBFutureUse);
return result;
}
}
} |
Delphi 5,6 This example is snipped, see extensive example in SDK
// ----------------------------------------------------------------------------
//
// Project:
// Example of using Delphi with Backup-Burner SDK
// Compiles in Delphi 5, Delphi 6 without hints, warnings, or errors.
//
// ----------------------------------------------------------------------------
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, FileCtrl,
Registry, StdCtrls, Menus, Buttons;
type
TForm1 = class(TForm)
ResultsLabel: TLabel;
Memo1: TMemo;
Button2: TButton;
Button3: TButton;
MainMenu1: TMainMenu;
File1: TMenuItem;
Exit1: TMenuItem;
N1: TMenuItem;
BackuptoCD1: TMenuItem;
Label5: TLabel;
OpenDialog1: TOpenDialog;
procedure TwoButtonClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ResultCode: Integer;
BBRegName,
BBRegCode,
BBVolume,
BBTitle,
BBColorForm,
BBColorText,
BBFolderPath,
BBFutureUse: String;
implementation
{$R *.DFM}
procedure TForm1.ThreeButtonClick(Sender: TObject);
var
H: THandle;
MakeBackupCD: function(BBRegName, BBRegCode, BBVolume, BBTitle, BBColorForm,
BBColorText, BBFolderPath, BBFutureUse: PChar): integer; stdcall;
begin
// Temporarily Disable Burn CD/DVD button to avoid double clicks
Button3.Enabled := False;
// Copy desired files to \Bin\FilesToBackup\ folder (or use the files selected by the #2 button)
CopyFile(Pchar('Bin\AutoRun.exe'), Pchar('Bin\FilesToBackup\AutoRun.exe'),FALSE );
CopyFile(Pchar('Bin\AutoRun.inf'), Pchar('Bin\FilesToBackup\AutoRun.inf'),FALSE );
// Fill in registration numbers, and
// OPTIONAL- Fill in desired Volume name (to be burned as CD/DVD title) or use null '';
BBRegName := 'DEMOUSER';
BBRegCode := 'ABCD1234';
BBVolume := 'MyBackupDisc'; //' What ever you want here, but no spaces allowed
BBTitle := Memo1.Lines[0] + Memo1.Lines[1] ;
BBColorForm := 'clSilver';//default is clSilver, don't use hex color
BBColorText := 'clBlack';//default is clBlack, don't use hex color
BBFutureUse := '';
if BBFolderPath='' then ExtractFilePath(ParamStr(0)); // Make this any folder you desire.
// Hide or minimize your program
Application.Minimize;
// Launch MakeBackupCD function in BackupBurner.dll
// When function returns, the CD/DVD process is complete.
If FileExists(BBFolderPath+ 'BackupBurner.dll') then
begin
ResultCode := 100;
H := LoadLibrary( Pchar(BBFolderPath + 'BackupBurner.dll') );
if H <> NULL then
begin
try
@MakeBackupCD := GetProcAddress(H, 'MakeBackupCD');
if Assigned(MakeBackupCD) then
ResultCode := MakeBackupCD(PChar(BBRegName), PChar(BBRegCode), PChar(BBVolume),
PChar(BBTitle), PChar(BBColorForm), PChar(BBColorText),
PChar(BBFolderPath), PChar(BBFutureUse) );
finally
FreeLibrary(H);
end;
end;
end
else
begin
ResultsLabel.Caption := 'Result: BackupBurner.exe file not found in correct folder ';
Application.Restore;
Sleep(5000);
close;
end;
// the CD/DVD process is complete.
// Unhide or restore your program
Application.Restore;
Button3.Enabled := True;
// OPTIONAL- Inspect the result code
Case ResultCode of
-2: ResultsLabel.Caption := 'Result: ResultCode = -2 Installation Error- version mismatch';
-1: ResultsLabel.Caption := 'Result: ResultCode = -1 User canceled' ;
0: ResultsLabel.Caption := 'Result: ResultCode = 0 it was a successful burn!';
1: ResultsLabel.Caption := 'Result: ResultCode = 1 User canceled';
2: ResultsLabel.Caption := 'Result: ResultCode = 2 Installation Error- files missing';
3: ResultsLabel.Caption := 'Result: ResultCode = 3 Insufficent disk space';
5: ResultsLabel.Caption := 'Result: ResultCode = 5 there was not a blank disc';
7: ResultsLabel.Caption := 'Result: ResultCode = 7 bad burn during writing ';
8: ResultsLabel.Caption := 'Result: ResultCode = 8 no CD/DVD recorder detected. ';
9: ResultsLabel.Caption := 'Result: ResultCode = 9 Demo expired. ';
else
ResultsLabel.Caption := 'Result: There was an unknown result.';
end;
// OPTIONAL- delete unneeded files from \FilesToBackup\
DeleteFile(Pchar('FilesToBackup\SampleData.txt'));
// You are done.
end;
end.
|
Visual Basic
'// ----------------------------------------------------------------------------
'//
'// Project File: CallingBB.vbp
'// A sample program that uses Declare Function to
'// access MakeBackupCD from BackupBurner.dll.
'//
'// Compiles in Visual Basic 6 SP5 without warnings or errors.
'//
'// ----------------------------------------------------------------------------
'Declare the dll's Function here...
Private Declare Function MakeBackupCD Lib "Bin\BackupBurner.dll" _
(ByVal BBRegName As String, _
ByVal BBRegCode As String, _
ByVal BBVolume As String, _
ByVal BBTitle As String, _
ByVal BBColorForm As String, _
ByVal BBColorText As String, _
ByVal PathtoBackupFolder As String, _
ByVal BBFutureUse As String _
) As Integer
'Notice that the path of the dll above is a relative path.
'Other path choices are full: "c:\myprogpath\Bin\BackupBurner.dll"
'or within same folder: "BackupBurner.dll"
Private Sub Form_Load()
'Use Visual Basic's built in error checking
On Error GoTo Err_Load
'Load the strings as shown
BBRegName = "DEMOUSER" 'For Demo use
BBRegCode = "ABCD1234" 'For Demo use
BBVolume = "MyBackupDisc" 'You can name the CD (no spaces allowed)
BBTitle = "My program is ___" 'You can display your program name or comments here
BBColorForm = "clSilver" 'default is clSilver, dont use hex color
BBColorText = "clBlack" 'default is clBlack, dont use hex color
PathtoBackupFolder = "c:\myprogpath\FilesToBackup\"
BBFutureUse = ""
MsgBox "Next will call the MakeBackupCD function in MakeBackupCD.dll...", vbInformation
'Now call the function and wait for a ResultCode to return...
ResultCode = MakeBackupCD(BBRegName, BBRegCode, BBVolume, BBTitle, BBColorForm, _
BBColorText, PathtoBackupFolder, BBFutureUse)
'Display the ResultCode...
Form1.Label1.Caption = "ResultCode= " & ResultCode
Exit Sub
Err_Load:
MsgBox "Error loading dll, check for correct path in the Function Declaration.", vbCritical
End Sub
|
Here is a link to the readme.txt file, so you can view it in your browser
now.
A concise summary is available in our
html PAD file.
Pricing
and license terms
Customization
requests considered. Contact us at
support@net-burner.com .
Return to page 1 of the
Backup-Burner SDK product page.
© 2000-2007 FrontBack LLC. All rights reserved.
|
|