Because the online only Delphi example I used to write when the CB found that there are some examples can not be used, so the whole life of the gas to simply check the data themselves wrote, afraid of netizens in programming with this kind of situation, immediately passed up.
void __fastcall Tform1::bitbtn1click (tobject *sender)
{
Char *adevice, *adriver, *aport;
Thandle Devicemode;
Pdevicemode DevMode;
int length,width;
length=1400;
width=2410;//sets the size unit of the custom paper to 0.1 mm
Adevice =new char[100];
Adriver =new char[100];
Aport =new char[100];
Get printer
Printer ()->getprinter (Adevice, Adriver, Aport,devicemode);
Get pDevMode structure
DevMode = (_devicemodea*) GlobalLock ((void *) devicemode);
Set values that can be modified
Devmode->dmfields = devmode->dmfields| Dm_papersize;
Devmode->dmfields = devmode->dmfields| Dm_paperlength;
Devmode->dmfields = devmode->dmfields| Dm_paperwidth;
Set the value to be modified
devmode->dmpapersize=dmpaper_user;//Set as custom paper
devmode->dmpaperlength=length;
devmode->dmpaperwidth=width;
Test print
Printer ()->begindoc ();
TextOut (Printer ()->handle, 0, 0, "-----------------", 17);
Printer ()->newpage ();
TextOut (Printer ()->handle, 0, 0, "++++++++++++++++++", 18);
Printer ()->newpage ();
Printer ()->enddoc ();
}