//......
procedure WinPrintFile(const sPrinter, sFileName: string; DoeExport: boolean);
type
_FAX_PRINT_INFOA = record
SizeOfStruct: DWORD; // Size of this structure
DocName: LPCSTR; // Document name that appears in the spooler
RecipientName: LPCSTR; // Recipient name
RecipientNumber: LPCSTR; // Recipient fax number (non-canonical number)
SenderName: LPCSTR; // Sender name
SenderCompany: LPCSTR; // Sender company (optional)
SenderDept: LPCSTR; // Sender department
SenderBillingCode: LPCSTR; // Billing code
Reserved: LPCSTR; // Reserved; must be NULL
DrEmailAddress: LPCSTR; // E.Mail address for delivery report
OutputFileName: LPCSTR; // for print to file, resulting file name
end;
_FAX_CONTEXT_INFOA = record
SizeOfStruct: DWORD; // Size of this structure
hDC: HDC; // Device Context
ServerName: array[0..MAX_COMPUTERNAME_LENGTH] of CHAR; // Server name
end;
PFAX_CONTEXT_INFOA = ^_FAX_CONTEXT_INFOA;
var
pDc: hDc;
DocInfo: TDocInfo;
printInfo: _FAX_PRINT_INFOA;
contextInfo: _FAX_CONTEXT_INFOA;
JobId: DWORD;
winfax, Z: Variant;
msfax: THandle;
qS, Exportfile: string;
i: integer;
FaxStartPrintJob: function(PrinterName: LPCSTR; const PrintInfo: _FAX_PRINT_INFOA; var FaxJobId: DWORD; FaxContextInfo: PFAX_CONTEXT_INFOA): BOOL; stdcall;
begin
DevSize := 0;
msfax := Unassigned;
winfax := Unassigned;
if (uppercase(sPrinter) = 'FAX') then
begin
// open MSFAX with a canvas to print on
RecipMail := '';
for i := 1 to Length(RecipName) do
if RecipName[i] in ['0'..'9'] then RecipMail := RecipMail + RecipName[i];
fillchar(printinfo, sizeof(printinfo), #0);
fillchar(contextInfo, sizeof(contextInfo), #0);
contextInfo.SizeOfStruct := (sizeof(_FAX_CONTEXT_INFOA));
printInfo.SizeOfStruct := (sizeof(_FAX_PRINT_INFOA));
printInfo.DocName := pchar(Subject);
printInfo.RecipientName := pchar(Company);
printInfo.RecipientNumber := pchar(RecipMail);
msfax := LoadLibrary('winfax.dll');
if msfax = 0 then
begin
error('winfax.dll niet geladen', '');
exit;
end;
@FaxStartPrintJob := GetProcAddress(msfax, 'FaxStartPrintJobA');
if not FaxStartPrintJob(pChar(sPrinter), printInfo, JobId, @contextInfo) then
begin
exit;
end;
pDc := contextInfo.hDC;
end
else if (uppercase(sPrinter) = 'WINFAX') then
begin
// open WINFAX with a canvas to print on
......