' ########################################################################################
' Microsoft Windows
' File: WinFax.inc
' Contents: This module contains the WIN32 FAX APIs.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_WinFax_PBI)
#DEFINE PBX_WinFax_PBI
%EQUATE `WINFAS_INC = 1
#INCLUDE ONCE "Legacy/Devices/Tapi.inc"
'//
'// FAX ERROR CODES
'//
%EQUATE `FAX_ERR_START = 7001& ' // First fax specific error code
%EQUATE `FAX_ERR_SRV_OUTOFMEMORY = 7001&
%EQUATE `FAX_ERR_GROUP_NOT_FOUND = 7002&
%EQUATE `FAX_ERR_BAD_GROUP_CONFIGURATION = 7003&
%EQUATE `FAX_ERR_GROUP_IN_USE = 7004&
%EQUATE `FAX_ERR_RULE_NOT_FOUND = 7005&
%EQUATE `FAX_ERR_NOT_NTFS = 7006&
%EQUATE `FAX_ERR_DIRECTORY_IN_USE = 7007&
%EQUATE `FAX_ERR_FILE_ACCESS_DENIED = 7008&
%EQUATE `FAX_ERR_MESSAGE_NOT_FOUND = 7009&
%EQUATE `FAX_ERR_DEVICE_NUM_LIMIT_EXCEEDED = 7010&
%EQUATE `FAX_ERR_NOT_SUPPORTED_ON_THIS_SKU = 7011&
%EQUATE `FAX_ERR_VERSION_MISMATCH = 7012& ' // Fax client/server versions mismtach
%EQUATE `FAX_ERR_RECIPIENTS_LIMIT = 7013& ' // Recipients limit in a single broadcast
%EQUATE `FAX_ERR_END = 7013& ' // Last fax specific error code
'//
'// MessageId: FAX_E_SRV_OUTOFMEMORY
'//
'// MessageText:
'//
'// The fax server failed to allocate memory.
'//
'#define FAX_E_SRV_OUTOFMEMORY MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_SRV_OUTOFMEMORY)
%EQUATE `FAX_E_SRV_OUTOFMEMORY = &H80041B59&
'//
'// MessageId: FAX_E_GROUP_NOT_FOUND
'//
'// MessageText:
'//
'// The fax server failed to locate an outbound routing group by name.
'//
'#define FAX_E_GROUP_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_GROUP_NOT_FOUND)
%EQUATE `FAX_E_GROUP_NOT_FOUND = &H80041B5A&
'//
'// MessageId: FAX_E_BAD_GROUP_CONFIGURATION
'//
'// MessageText:
'//
'// The fax server encountered an outbound routing group with bad configuration.
'//
'#define FAX_E_BAD_GROUP_CONFIGURATION MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_BAD_GROUP_CONFIGURATION)
%EQUATE `FAX_E_BAD_GROUP_CONFIGURATION = &H080041B5B&
'//
'// MessageId: FAX_E_GROUP_IN_USE
'//
'// MessageText:
'//
'// The fax server cannot remove an outbound routing group because it is in use by one or more outbound routing rules.
'//
'#define FAX_E_GROUP_IN_USE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_GROUP_IN_USE)
%EQUATE `FAX_E_GROUP_IN_USE = &H80041B5C&
'//
'// MessageId: FAX_E_RULE_NOT_FOUND
'//
'// MessageText:
'//
'// The fax server failed to locate an outbound routing rule by country code and area code.
'//
'#define FAX_E_RULE_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_RULE_NOT_FOUND)
%EQUATE `FAX_E_RULE_NOT_FOUND = &H80041B5D&
'//
'// MessageId: FAX_E_NOT_NTFS
'//
'// MessageText:
'//
'// The fax server cannot set an archive folder to a non-NTFS partition.
'//
'#define FAX_E_NOT_NTFS MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_NOT_NTFS)
%EQUATE `FAX_E_NOT_NTFS = &H80041B5E&
'//
'// MessageId: FAX_E_DIRECTORY_IN_USE
'//
'// MessageText:
'//
'// The fax server cannot use the same folder for both the inbox and the sent-items archives.
'//
'#define FAX_E_DIRECTORY_IN_USE MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_DIRECTORY_IN_USE)
%EQUATE `FAX_E_DIRECTORY_IN_USE = &H80041B5F&
'//
'// MessageId: FAX_E_FILE_ACCESS_DENIED
'//
'// MessageText:
'//
'// The fax server cannot access the specified file or folder.
'//
'#define FAX_E_FILE_ACCESS_DENIED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_FILE_ACCESS_DENIED)
%EQUATE `FAX_E_FILE_ACCESS_DENIED = &H80041B60&
'//
'// MessageId: FAX_E_MESSAGE_NOT_FOUND
'//
'// MessageText:
'//
'// The fax server cannot find the job or message by its ID.
'//
'#define FAX_E_MESSAGE_NOT_FOUND MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_MESSAGE_NOT_FOUND)
%EQUATE `FAX_E_MESSAGE_NOT_FOUND = &H80041B61&
'//
'// MessageId: FAX_E_DEVICE_NUM_LIMIT_EXCEEDED
'//
'// MessageText:
'//
'// The fax server cannot complete the operation because the number of active fax devices allowed for this version of Windows was exceeded.
'//
'#define FAX_E_DEVICE_NUM_LIMIT_EXCEEDED MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_DEVICE_NUM_LIMIT_EXCEEDED)
%EQUATE `FAX_E_DEVICE_NUM_LIMIT_EXCEEDED = &H80041B62&
'//
'// MessageId: FAX_E_NOT_SUPPORTED_ON_THIS_SKU
'//
'// MessageText:
'//
'// The fax server cannot complete the operation because it is not supported for this version of Windows.
'//
'#define FAX_E_NOT_SUPPORTED_ON_THIS_SKU MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_NOT_SUPPORTED_ON_THIS_SKU)
%EQUATE `FAX_E_NOT_SUPPORTED_ON_THIS_SKU = &H80041B63&
'//
'// MessageId: FAX_E_VERSION_MISMATCH
'//
'// MessageText:
'//
'// The fax server API version does not support the requested operation.
'//
'#define FAX_E_VERSION_MISMATCH MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_VERSION_MISMATCH)
%EQUATE `FAX_E_VERSION_MISMATCH = &H80041B64&
'//
'// MessageId: FAX_E_RECIPIENT_LIMIT
'//
'// MessageText:
'//
'// The limit on the number of recipients for a single fax broadcast was reached.
'//
'#define FAX_E_RECIPIENTS_LIMIT MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, FAX_ERR_RECIPIENTS_LIMIT)
%EQUATE `FAX_E_RECIPIENTS_LIMIT = &H80041B65&
' enum FAX_ENUM_LOG_LEVELS
%EQUATE `FAXLOG_LEVEL_NONE = 0
%EQUATE `FAXLOG_LEVEL_MIN = 1
%EQUATE `FAXLOG_LEVEL_MED = 2
%EQUATE `FAXLOG_LEVEL_MAX = 3
' enum FAX_ENUM_LOG_CATEGORIES
%EQUATE `FAXLOG_CATEGORY_INIT = 1 ' // Initialization / shutdown
%EQUATE `FAXLOG_CATEGORY_OUTBOUND = 2 ' // Outbound messages
%EQUATE `FAXLOG_CATEGORY_INBOUND = 3 ' // Inbound messages
%EQUATE `FAXLOG_CATEGORY_UNKNOWN = 4 ' // Unknown category (all others)
' // Size = 12 bytes
TYPE FAX_LOG_CATEGORYA DWORD
 Name AS ASCIIZ PTR ' LPCSTR // logging category name
 Category AS DWORD ' DWORD // logging category number
 Level AS DWORD ' DWORD // logging level for the category
END TYPE
' // Size = 12 bytes
TYPE FAX_LOG_CATEGORYW DWORD
 Name AS WSTRINGZ PTR ' LPCWSTR // logging category name
 Category AS DWORD ' DWORD // logging category number
 Level AS DWORD ' DWORD // logging level for the category
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_LOG_CATEGORY = FAX_LOG_CATEGORYW
#ELSE
 MACRO FAX_LOG_CATEGORY = FAX_LOG_CATEGORYA
#ENDIF
' // Size = 4 bytes
TYPE FAX_TIME WORD
 Hour AS WORD ' WORD
 Minute AS WORD ' WORD
END TYPE
' // Size = 52 bytes
TYPE FAX_CONFIGURATIONA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 Retries AS DWORD ' DWORD // number of retries for fax send
 RetryDelay AS DWORD ' DWORD // number of minutes between retries
 DirtyDays AS DWORD ' DWORD // number of days to keep an unsent job in the queue
 Branding AS LONG ' BOOL // fsp should brand outgoing faxes
 UseDeviceTsid AS LONG ' BOOL // server uses device tsid only
 ServerCp AS LONG ' BOOL // clients must use cover pages on the server
 PauseServerQueue AS LONG ' BOOL // is the server queue paused?
 StartCheapTime AS FAX_TIME ' FAX_TIME // start of discount rate period
 StopCheapTime AS FAX_TIME ' FAX_TIME // end of discount rate period
 ArchiveOutgoingFaxes AS LONG ' BOOL // whether outgoing faxes should be archived
 ArchiveDirectory AS ASCIIZ PTR ' LPCSTR // archive directory for outgoing faxes
 Reserved AS ASCIIZ PTR ' LPCSTR // Reserved; must be NULL
END TYPE
' // Size = 52 bytes
TYPE FAX_CONFIGURATIONW DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 Retries AS DWORD ' DWORD // number of retries for fax send
 RetryDelay AS DWORD ' DWORD // number of minutes between retries
 DirtyDays AS DWORD ' DWORD // number of days to keep an unsent job in the queue
 Branding AS LONG ' BOOL // fsp should brand outgoing faxes
 UseDeviceTsid AS LONG ' BOOL // server uses device tsid only
 ServerCp AS LONG ' BOOL // clients must use cover pages on the server
 PauseServerQueue AS LONG ' BOOL // is the server queue paused?
 StartCheapTime AS FAX_TIME ' FAX_TIME // start of discount rate period
 StopCheapTime AS FAX_TIME ' FAX_TIME // end of discount rate period
 ArchiveOutgoingFaxes AS LONG ' BOOL // whether outgoing faxes should be archived
 ArchiveDirectory AS WSTRINGZ PTR ' LPCWSTR // archive directory for outgoing faxes
 Reserved AS WSTRINGZ PTR ' LPCWSTR // Reserved; must be NULL
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_CONFIGURATION = FAX_CONFIGURATIONW
#ELSE
 MACRO FAX_CONFIGURATION = FAX_CONFIGURATIONA
#ENDIF
'//
'// FaxSetJob() command codes
'//
' enum FAX_ENUM_JOB_COMMANDS
%EQUATE `JC_UNKNOWN = 0
%EQUATE `JC_DELETE = 1
%EQUATE `JC_PAUSE = 2
%EQUATE `JC_RESUME = 3
%EQUATE `JC_RESTART = %JC_RESUME
'//
'// job type defines
'//
%EQUATE `JT_UNKNOWN = 0
%EQUATE `JT_SEND = 1
%EQUATE `JT_RECEIVE = 2
%EQUATE `JT_ROUTING = 3
%EQUATE `JT_FAIL_RECEIVE = 4
'//
'// job status defines
'//
%EQUATE `JS_PENDING = &H00000000
%EQUATE `JS_INPROGRESS = &H00000001
%EQUATE `JS_DELETING = &H00000002
%EQUATE `JS_FAILED = &H00000004
%EQUATE `JS_PAUSED = &H00000008
%EQUATE `JS_NOLINE = &H00000010
%EQUATE `JS_RETRYING = &H00000020
%EQUATE `JS_RETRIES_EXCEEDED = &H00000040
' // Size = 88 bytes
TYPE FAX_DEVICE_STATUSA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 CallerId AS ASCIIZ PTR ' LPCSTR // caller id string
 Csid AS ASCIIZ PTR ' LPCSTR // station identifier
 CurrentPage AS DWORD ' DWORD // current page
 DeviceId AS DWORD ' DWORD // permanent line id
 DeviceName AS ASCIIZ PTR ' LPCSTR // device name
 DocumentName AS ASCIIZ PTR ' LPCSTR // document name
 JobType AS DWORD ' DWORD // send or receive?
 PhoneNumber AS ASCIIZ PTR ' LPCSTR // sending phone number
 RoutingString AS ASCIIZ PTR ' LPCSTR // routing information
 SenderName AS ASCIIZ PTR ' LPCSTR // sender name
 RecipientName AS ASCIIZ PTR ' LPCSTR // recipient name
 Size AS DWORD ' DWORD // size in bytes of the document
 StartTime AS FILETIME ' FILETIME // starting time of the fax send/receive
 Status AS DWORD ' DWORD // current status of the device, see FPS_??? masks
 StatusString AS ASCIIZ PTR ' LPCSTR // status string if the Status field is zero. this may be NULL.
 SubmittedTime AS FILETIME ' FILETIME // time the document was submitted
 TotalPages AS DWORD ' DWORD // total number of pages in this job
 Tsid AS ASCIIZ PTR ' LPCSTR // transmitting station identifier
 UserName AS ASCIIZ PTR ' LPCSTR // user that submitted the active job
END TYPE
' // Size = 88 bytes
TYPE FAX_DEVICE_STATUSW DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 CallerId AS WSTRINGZ PTR ' LPCWSTR // caller id string
 Csid AS WSTRINGZ PTR ' LPCWSTR // station identifier
 CurrentPage AS DWORD ' DWORD // current page
 DeviceId AS DWORD ' DWORD // permanent line id
 DeviceName AS WSTRINGZ PTR ' LPCWSTR // device name
 DocumentName AS WSTRINGZ PTR ' LPCWSTR // document name
 JobType AS DWORD ' DWORD // send or receive?
 PhoneNumber AS WSTRINGZ PTR ' LPCWSTR // sending phone number
 RoutingString AS WSTRINGZ PTR ' LPCWSTR // routing information
 SenderName AS WSTRINGZ PTR ' LPCWSTR // sender name
 RecipientName AS WSTRINGZ PTR ' LPCWSTR // recipient name
 Size AS DWORD ' DWORD // size in bytes of the document
 StartTime AS FILETIME ' FILETIME // starting time of the fax send/receive
 Status AS DWORD ' DWORD // current status of the device, see FPS_??? masks
 StatusString AS WSTRINGZ PTR ' LPCWSTR // status string if the Status field is zero. this may be NULL.
 SubmittedTime AS FILETIME ' FILETIME // time the document was submitted
 TotalPages AS DWORD ' DWORD // total number of pages in this job
 Tsid AS WSTRINGZ PTR ' LPCWSTR // transmitting station identifier
 UserName AS WSTRINGZ PTR ' LPCWSTR // user that submitted the active job
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_DEVICE_STATUS = FAX_DEVICE_STATUSW
#ELSE
 MACRO FAX_DEVICE_STATUS = FAX_DEVICE_STATUSA
#ENDIF
' // Size = 92 bytes
TYPE FAX_JOB_ENTRYA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 JobId AS DWORD ' DWORD // fax job id
 UserName AS ASCIIZ PTR ' LPCSTR // user who submitted the job
 JobType AS DWORD ' DWORD // job type, see JT defines
 QueueStatus AS DWORD ' DWORD // job queue status, see JS defines
 Status AS DWORD ' DWORD // current status of the device, see FPS_??? masks
 Size AS DWORD ' DWORD // size in bytes of the document
 PageCount AS DWORD ' DWORD // total page count
 RecipientNumber AS ASCIIZ PTR ' LPCSTR // recipient fax number
 RecipientName AS ASCIIZ PTR ' LPCSTR // recipient name
 Tsid AS ASCIIZ PTR ' LPCSTR // transmitter's id
 SenderName AS ASCIIZ PTR ' LPCSTR // sender name
 SenderCompany AS ASCIIZ PTR ' LPCSTR // sender company
 SenderDept AS ASCIIZ PTR ' LPCSTR // sender department
 BillingCode AS ASCIIZ PTR ' LPCSTR // billing code
 ScheduleAction AS DWORD ' DWORD // when to schedule the fax, see JSA defines
 ScheduleTime AS SYSTEMTIME ' SYSTEMTIME // time to send the fax when JSA_SPECIFIC_TIME is used (must be local time)
 DeliveryReportType AS DWORD ' DWORD // delivery report type, see DRT defines
 DeliveryReportAddress AS ASCIIZ PTR ' LPCSTR // email address for delivery report (ndr or dr) thru MAPI / SMTP
 DocumentName AS ASCIIZ PTR ' LPCSTR // document name
END TYPE
' // Size = 92 bytes
TYPE FAX_JOB_ENTRYW DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 JobId AS DWORD ' DWORD // fax job id
 UserName AS WSTRINGZ PTR ' LPCWSTR // user who submitted the job
 JobType AS DWORD ' DWORD // job type, see JT defines
 QueueStatus AS DWORD ' DWORD // job queue status, see JS defines
 Status AS DWORD ' DWORD // current status of the device, see FPS_??? masks
 Size AS DWORD ' DWORD // size in bytes of the document
 PageCount AS DWORD ' DWORD // total page count
 RecipientNumber AS WSTRINGZ PTR ' LPCWSTR // recipient fax number
 RecipientName AS WSTRINGZ PTR ' LPCWSTR // recipient name
 Tsid AS WSTRINGZ PTR ' LPCWSTR // transmitter's id
 SenderName AS WSTRINGZ PTR ' LPCWSTR // sender name
 SenderCompany AS WSTRINGZ PTR ' LPCWSTR // sender company
 SenderDept AS WSTRINGZ PTR ' LPCWSTR // sender department
 BillingCode AS WSTRINGZ PTR ' LPCWSTR // billing code
 ScheduleAction AS DWORD ' DWORD // when to schedule the fax, see JSA defines
 ScheduleTime AS SYSTEMTIME ' SYSTEMTIME // time to send the fax when JSA_SPECIFIC_TIME is used (must be local time)
 DeliveryReportType AS DWORD ' DWORD // delivery report type, see DRT defines
 DeliveryReportAddress AS WSTRINGZ PTR ' LPCWSTR // email address for delivery report (ndr or dr) thru MAPI / SMTP
 DocumentName AS WSTRINGZ PTR ' LPCWSTR // document name
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_JOB_ENTRY = FAX_JOB_ENTRYW
#ELSE
 MACRO FAX_JOB_ENTRY = FAX_JOB_ENTRYA
#ENDIF
'//
'// fax port state masks
'//
'// if you change these defines the be sure to
'// change the resources in the fax service.
'//
%EQUATE `FPS_DIALING = &H20000001
%EQUATE `FPS_SENDING = &H20000002
%EQUATE `FPS_RECEIVING = &H20000004
%EQUATE `FPS_COMPLETED = &H20000008
%EQUATE `FPS_HANDLED = &H20000010
%EQUATE `FPS_UNAVAILABLE = &H20000020
%EQUATE `FPS_BUSY = &H20000040
%EQUATE `FPS_NO_ANSWER = &H20000080
%EQUATE `FPS_BAD_ADDRESS = &H20000100
%EQUATE `FPS_NO_DIAL_TONE = &H20000200
%EQUATE `FPS_DISCONNECTED = &H20000400
%EQUATE `FPS_FATAL_ERROR = &H20000800
%EQUATE `FPS_NOT_FAX_CALL = &H20001000
%EQUATE `FPS_CALL_DELAYED = &H20002000
%EQUATE `FPS_CALL_BLACKLISTED = &H20004000
%EQUATE `FPS_INITIALIZING = &H20008000
%EQUATE `FPS_OFFLINE = &H20010000
%EQUATE `FPS_RINGING = &H20020000
%EQUATE `FPS_AVAILABLE = &H20100000
%EQUATE `FPS_ABORTING = &H20200000
%EQUATE `FPS_ROUTING = &H20400000
%EQUATE `FPS_ANSWERED = &H20800000
'//
'// fax port capability mask
'//
%EQUATE `FPF_RECEIVE = &H00000001 ' // Automatically receive faxes
%EQUATE `FPF_SEND = &H00000002
%EQUATE `FPF_VIRTUAL = &H00000004
' // Size = 36 bytes
TYPE FAX_PORT_INFOA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 DeviceId AS DWORD ' DWORD // Device ID
 State AS DWORD ' DWORD // State of the device
 Flags AS DWORD ' DWORD // Device specific flags
 Rings AS DWORD ' DWORD // Number of rings before answer
 Priority AS DWORD ' DWORD // Device priority
 DeviceName AS ASCIIZ PTR ' LPCSTR // Device name
 Tsid AS ASCIIZ PTR ' LPCSTR // Device Tsid
 Csid AS ASCIIZ PTR ' LPCSTR // Device Csid
END TYPE
' // Size = 36 bytes
TYPE FAX_PORT_INFOW
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 DeviceId AS DWORD ' DWORD // Device ID
 State AS DWORD ' DWORD // State of the device
 Flags AS DWORD ' DWORD // Device specific flags
 Rings AS DWORD ' DWORD // Number of rings before answer
 Priority AS DWORD ' DWORD // Device priority
 DeviceName AS WSTRINGZ PTR ' LPCWSTR // Device name
 Tsid AS WSTRINGZ PTR ' LPCWSTR // Device Tsid
 Csid AS WSTRINGZ PTR ' LPCWSTR // Device Csid
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_PORT_INFO = FAX_PORT_INFOW
#ELSE
 MACRO FAX_PORT_INFO = FAX_PORT_INFOA
#ENDIF
' // Size = 36 bytes
TYPE FAX_ROUTING_METHODA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 DeviceId AS DWORD ' DWORD // device identifier
 Enabled AS LONG ' BOOL // is this method enabled for this device?
 DeviceName AS ASCIIZ PTR ' LPCSTR // device name
 Guid AS ASCIIZ PTR ' LPCSTR // guid that identifies this routing method
 FriendlyName AS ASCIIZ PTR ' LPCSTR // friendly name for this method
 FunctionName AS ASCIIZ PTR ' LPCSTR // exported function name that identifies this method
 ExtensionImageName AS ASCIIZ PTR ' LPCSTR // module (dll) name that implements this method
 ExtensionFriendlyName AS ASCIIZ PTR ' LPCSTR // displayable string that identifies the extension
END TYPE
' // Size = 36 bytes
TYPE FAX_ROUTING_METHODW
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 DeviceId AS DWORD ' DWORD // device identifier
 Enabled AS LONG ' BOOL // is this method enabled for this device?
 DeviceName AS WSTRINGZ PTR ' LPCWSTR // device name
 Guid AS WSTRINGZ PTR ' LPCWSTR // guid that identifies this routing method
 FriendlyName AS WSTRINGZ PTR ' LPCWSTR // friendly name for this method
 FunctionName AS WSTRINGZ PTR ' LPCWSTR // exported function name that identifies this method
 ExtensionImageName AS WSTRINGZ PTR ' LPCWSTR // module (dll) name that implements this method
 ExtensionFriendlyName AS WSTRINGZ PTR ' LPCWSTR // displayable string that identifies the extension
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_ROUTING_METHOD = FAX_ROUTING_METHODW
#ELSE
 MACRO FAX_ROUTING_METHOD = FAX_ROUTING_METHODA
#ENDIF
' // Size = 28 bytes
TYPE FAX_GLOBAL_ROUTING_INFOA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 Priority AS DWORD ' DWORD // priority of this device
 Guid AS ASCIIZ PTR ' LPCSTR // guid that identifies this routing method
 FriendlyName AS ASCIIZ PTR ' LPCSTR // friendly name for this method
 FunctionName AS ASCIIZ PTR ' LPCSTR // exported function name that identifies this method
 ExtensionImageName AS ASCIIZ PTR ' LPCSTR // module (dll) name that implements this method
 ExtensionFriendlyName AS ASCIIZ PTR ' LPCSTR // displayable string that identifies the extension
END TYPE
' // Size = 28 bytes
TYPE FAX_GLOBAL_ROUTING_INFOW DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 Priority AS DWORD ' DWORD // priority of this device
 Guid AS WSTRINGZ PTR ' LPCWSTR // guid that identifies this routing method
 FriendlyName AS WSTRINGZ PTR ' LPCWSTR // friendly name for this method
 FunctionName AS WSTRINGZ PTR ' LPCWSTR // exported function name that identifies this method
 ExtensionImageName AS WSTRINGZ PTR ' LPCWSTR // module (dll) name that implements this method
 ExtensionFriendlyName AS WSTRINGZ PTR ' LPCWSTR // displayable string that identifies the extension
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_GLOBAL_ROUTING_INFO = FAX_GLOBAL_ROUTING_INFOW
#ELSE
 MACRO FAX_GLOBAL_ROUTING_INFO = FAX_GLOBAL_ROUTING_INFOA
#ENDIF
' // Size = 128 bytes
TYPE FAX_COVERPAGE_INFOA DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 CoverPageName AS ASCIIZ PTR ' LPCSTR // coverpage document name
 UseServerCoverPage AS LONG ' BOOL // coverpage exists on the fax server
 RecName AS ASCIIZ PTR
 RecFaxNumber AS ASCIIZ PTR
 RecCompany AS ASCIIZ PTR
 RecStreetAddress AS ASCIIZ PTR
 RecCity AS ASCIIZ PTR
 RecState AS ASCIIZ PTR
 RecZip AS ASCIIZ PTR
 RecCountry AS ASCIIZ PTR
 RecTitle AS ASCIIZ PTR
 RecDepartment AS ASCIIZ PTR
 RecOfficeLocation AS ASCIIZ PTR
 RecHomePhone AS ASCIIZ PTR
 RecOfficePhone AS ASCIIZ PTR
 SdrName AS ASCIIZ PTR
 SdrFaxNumber AS ASCIIZ PTR
 SdrCompany AS ASCIIZ PTR
 SdrAddress AS ASCIIZ PTR
 SdrTitle AS ASCIIZ PTR
 SdrDepartment AS ASCIIZ PTR
 SdrOfficeLocation AS ASCIIZ PTR
 SdrHomePhone AS ASCIIZ PTR
 SdrOfficePhone AS ASCIIZ PTR
 Note AS ASCIIZ PTR
 Subject AS ASCIIZ PTR
 TimeSent AS SYSTEMTIME ' SYSTEMTIME // Time the fax was sent
 PageCount AS DWORD ' DWORD // Number of pages
END TYPE
' // Size = 128 bytes
TYPE FAX_COVERPAGE_INFOW DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 CoverPageName AS WSTRINGZ PTR ' LPCWSTR // coverpage document name
 UseServerCoverPage AS LONG ' BOOL // coverpage exists on the fax server
 RecName AS WSTRINGZ PTR
 RecFaxNumber AS WSTRINGZ PTR
 RecCompany AS WSTRINGZ PTR
 RecStreetAddress AS WSTRINGZ PTR
 RecCity AS WSTRINGZ PTR
 RecState AS WSTRINGZ PTR
 RecZip AS WSTRINGZ PTR
 RecCountry AS WSTRINGZ PTR
 RecTitle AS WSTRINGZ PTR
 RecDepartment AS WSTRINGZ PTR
 RecOfficeLocation AS WSTRINGZ PTR
 RecHomePhone AS WSTRINGZ PTR
 RecOfficePhone AS WSTRINGZ PTR
 SdrName AS WSTRINGZ PTR
 SdrFaxNumber AS WSTRINGZ PTR
 SdrCompany AS WSTRINGZ PTR
 SdrAddress AS WSTRINGZ PTR
 SdrTitle AS WSTRINGZ PTR
 SdrDepartment AS WSTRINGZ PTR
 SdrOfficeLocation AS WSTRINGZ PTR
 SdrHomePhone AS WSTRINGZ PTR
 SdrOfficePhone AS WSTRINGZ PTR
 Note AS WSTRINGZ PTR
 Subject AS WSTRINGZ PTR
 TimeSent AS SYSTEMTIME ' SYSTEMTIME // Time the fax was sent
 PageCount AS DWORD ' DWORD // Number of pages
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_COVERPAGE_INFO = FAX_COVERPAGE_INFOW
#ELSE
 MACRO FAX_COVERPAGE_INFO = FAX_COVERPAGE_INFOA
#ENDIF
' enum FAX_ENUM_JOB_SEND_ATTRIBUTES
%EQUATE `JSA_NOW = 0 ' // Send now
%EQUATE `JSA_SPECIFIC_TIME = 1 ' // Send at specific time
%EQUATE `JSA_DISCOUNT_PERIOD = 2 ' // Send at server configured discount period
'#ifndef _FAXAPIP_
' enum FAX_ENUM_DELIVERY_REPORT_TYPES
%EQUATE `DRT_NONE = &H0000 ' // Do not send receipt
%EQUATE `DRT_EMAIL = &H0001 ' // Send receipt by email
%EQUATE `DRT_INBOX = &H0002 ' // send receipt to local inbox
'#endif // _FAXAPIP_
' // Size = 80 bytes
TYPE FAX_JOB_PARAMA DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 RecipientNumber AS ASCIIZ PTR ' LPCSTR // recipient fax number
 RecipientName AS ASCIIZ PTR ' LPCSTR // recipient name
 Tsid AS ASCIIZ PTR ' LPCSTR // transmitter's id
 SenderName AS ASCIIZ PTR ' LPCSTR // sender name
 SenderCompany AS ASCIIZ PTR ' LPCSTR // sender company
 SenderDept AS ASCIIZ PTR ' LPCSTR // sender department
 BillingCode AS ASCIIZ PTR ' LPCSTR // billing code
 ScheduleAction AS DWORD ' DWORD // when to schedule the fax, see JSA defines
 ScheduleTime AS SYSTEMTIME ' SYSTEMTIME // time to send the fax when JSA_SPECIFIC_TIME is used (must be local time)
 DeliveryReportType AS DWORD ' DWORD // delivery report type, see DRT defines
 DeliveryReportAddress AS ASCIIZ PTR ' LPCSTR // email address for delivery report (ndr or dr) thru MAPI / SMTP
 DocumentName AS ASCIIZ PTR ' LPCSTR // document name (optional)
 CallHandle AS DWORD ' HCALL // optional call handle
 Reserved(2) AS DWORD PTR ' DWORD_PTR // reserved for ms use only
END TYPE
' // Size = 80 bytes
TYPE FAX_JOB_PARAMW DWORD
 SizeOfStruct AS DWORD ' DWORD // size of this structure
 RecipientNumber AS WSTRINGZ PTR ' LPCWSTR // recipient fax number
 RecipientName AS WSTRINGZ PTR ' LPCWSTR // recipient name
 Tsid AS WSTRINGZ PTR ' LPCWSTR // transmitter's id
 SenderName AS WSTRINGZ PTR ' LPCWSTR // sender name
 SenderCompany AS WSTRINGZ PTR ' LPCWSTR // sender company
 SenderDept AS WSTRINGZ PTR ' LPCWSTR // sender department
 BillingCode AS WSTRINGZ PTR ' LPCWSTR // billing code
 ScheduleAction AS DWORD ' DWORD // when to schedule the fax, see JSA defines
 ScheduleTime AS SYSTEMTIME ' SYSTEMTIME // time to send the fax when JSA_SPECIFIC_TIME is used (must be local time)
 DeliveryReportType AS DWORD ' DWORD // delivery report type, see DRT defines
 DeliveryReportAddress AS WSTRINGZ PTR ' LPCWSTR // email address for delivery report (ndr or dr) thru MAPI / SMTP
 DocumentName AS WSTRINGZ PTR ' LPCWSTR // document name (optional)
 CallHandle AS DWORD ' HCALL // optional call handle
 Reserved(2) AS DWORD PTR ' DWORD_PTR // reserved for ms use only
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_JOB_PARAM = FAX_JOB_PARAMW
#ELSE
 MACRO FAX_JOB_PARAM = FAX_JOB_PARAMA
#ENDIF
'//
'// Event Ids
'//
'// FEI_NEVENTS is the number of events
'//
%EQUATE `FEI_DIALING = &H00000001
%EQUATE `FEI_SENDING = &H00000002
%EQUATE `FEI_RECEIVING = &H00000003
%EQUATE `FEI_COMPLETED = &H00000004
%EQUATE `FEI_BUSY = &H00000005
%EQUATE `FEI_NO_ANSWER = &H00000006
%EQUATE `FEI_BAD_ADDRESS = &H00000007
%EQUATE `FEI_NO_DIAL_TONE = &H00000008
%EQUATE `FEI_DISCONNECTED = &H00000009
%EQUATE `FEI_FATAL_ERROR = &H0000000a
%EQUATE `FEI_NOT_FAX_CALL = &H0000000b
%EQUATE `FEI_CALL_DELAYED = &H0000000c
%EQUATE `FEI_CALL_BLACKLISTED = &H0000000d
%EQUATE `FEI_RINGING = &H0000000e
%EQUATE `FEI_ABORTING = &H0000000f
%EQUATE `FEI_ROUTING = &H00000010
%EQUATE `FEI_MODEM_POWERED_ON = &H00000011
%EQUATE `FEI_MODEM_POWERED_OFF = &H00000012
%EQUATE `FEI_IDLE = &H00000013
%EQUATE `FEI_FAXSVC_ENDED = &H00000014
%EQUATE `FEI_ANSWERED = &H00000015
%EQUATE `FEI_JOB_QUEUED = &H00000016
%EQUATE `FEI_DELETED = &H00000017
%EQUATE `FEI_INITIALIZING = &H00000018
%EQUATE `FEI_LINE_UNAVAILABLE = &H00000019
%EQUATE `FEI_HANDLED = &H0000001a
%EQUATE `FEI_FAXSVC_STARTED = &H0000001b
%EQUATE `FEI_NEVENTS = %FEI_FAXSVC_STARTED
' // Size = 24 bytes
TYPE FAX_EVENTA DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 TimeStamp AS FILETIME ' FILETIME // Timestamp for when the event was generated
 DeviceId AS DWORD ' DWORD // Permanent line id
 EventId AS DWORD ' DWORD // Current event id
 JobId AS DWORD ' DWORD // Fax Job Id, 0xffffffff indicates inactive job
END TYPE
' // Size = 24 bytes
TYPE FAX_EVENTW DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 TimeStamp AS FILETIME ' FILETIME // Timestamp for when the event was generated
 DeviceId AS DWORD ' DWORD // Permanent line id
 EventId AS DWORD ' DWORD // Current event id
 JobId AS DWORD ' DWORD // Fax Job Id, 0xffffffff indicates inactive job
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_EVENT = FAX_EVENTW
#ELSE
 MACRO FAX_EVENT = FAX_EVENTA
#ENDIF
' // Size = 44 bytes
TYPE FAX_PRINT_INFOA DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 DocName AS ASCIIZ PTR ' LPCSTR // Document name that appears in the spooler
 RecipientName AS ASCIIZ PTR ' LPCSTR // Recipient name
 RecipientNumber AS ASCIIZ PTR ' LPCSTR // Recipient fax number (non-canonical number)
 SenderName AS ASCIIZ PTR ' LPCSTR // Sender name
 SenderCompany AS ASCIIZ PTR ' LPCSTR // Sender company (optional)
 SenderDept AS ASCIIZ PTR ' LPCSTR // Sender department
 SenderBillingCode AS ASCIIZ PTR ' LPCSTR // Billing code
 Reserved AS ASCIIZ PTR ' LPCSTR // Reserved; must be NULL
 DrEmailAddress AS ASCIIZ PTR ' LPCSTR // E.Mail address for delivery report
 OutputFileName AS ASCIIZ PTR ' LPCSTR // for print to file, resulting file name
END TYPE
' // Size = 44 bytes
TYPE FAX_PRINT_INFOW DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 DocName AS WSTRINGZ PTR ' LPWCSTR // Document name that appears in the spooler
 RecipientName AS WSTRINGZ PTR ' LPWCSTR // Recipient name
 RecipientNumber AS WSTRINGZ PTR ' LPWCSTR // Recipient fax number (non-canonical number)
 SenderName AS WSTRINGZ PTR ' LPWCSTR // Sender name
 SenderCompany AS WSTRINGZ PTR ' LPWCSTR // Sender company (optional)
 SenderDept AS WSTRINGZ PTR ' LPWCSTR // Sender department
 SenderBillingCode AS WSTRINGZ PTR ' LPWCSTR // Billing code
 Reserved AS WSTRINGZ PTR ' LPWCSTR // Reserved; must be NULL
 DrEmailAddress AS WSTRINGZ PTR ' LPWCSTR // E.Mail address for delivery report
 OutputFileName AS WSTRINGZ PTR ' LPWCSTR // for print to file, resulting file name
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_PRINT_INFO = FAX_PRINT_INFOW
#ELSE
 MACRO FAX_PRINT_INFO = FAX_PRINT_INFOA
#ENDIF
' // Size = 24 bytes
TYPE FAX_CONTEXT_INFOA DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 hDC AS DWORD ' HDC // Device Context
 ServerName AS ASCIIZ * %MAX_COMPUTERNAME_LENGTH + 1 ' CHAR // Server name
END TYPE
' // Size = 40 bytes
TYPE FAX_CONTEXT_INFOW DWORD
 SizeOfStruct AS DWORD ' DWORD // Size of this structure
 hDC AS DWORD ' HDC // Device Context
 ServerName AS WSTRINGZ * %MAX_COMPUTERNAME_LENGTH + 1 ' WCHAR // Server name
END TYPE
#IF %DEF(%UNICODE)
 MACRO FAX_CONTEXT_INFO = FAX_CONTEXT_INFOW
#ELSE
 MACRO FAX_CONTEXT_INFO = FAX_CONTEXT_INFOA
#ENDIF
'//
'// prototypes
'//
DECLARE FUNCTION FaxConnectFaxServerA LIB "winfax.dll" ALIAS "FaxConnectFaxServerA" ( BYREF MachineName AS ASCIIZ , BYREF FaxHandle AS QUAD ) AS LONG
DECLARE FUNCTION FaxConnectFaxServerW LIB "winfax.dll" ALIAS "FaxConnectFaxServerW" ( BYREF MachineName AS WSTRINGZ
 , BYREF FaxHandle AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxConnectFaxServer = FaxConnectFaxServerW
#ELSE
 MACRO FaxConnectFaxServer = FaxConnectFaxServerA
#ENDIF
DECLARE FUNCTION FaxClose LIB "winfax.dll" ALIAS "FaxClose" ( BYVAL FaxHandle AS QUAD ) AS LONG
' enum FAX_ENUM_PORT_OPEN_TYPE
%EQUATE `PORT_OPEN_QUERY = 1
%EQUATE `PORT_OPEN_MODIFY = 2
DECLARE FUNCTION FaxOpenPort LIB "winfax.dll" ALIAS "FaxOpenPort" ( BYVAL FaxHandle AS QUAD , BYVAL DeviceId AS QUAD , BYVAL Flags AS QUAD , BYREF FaxPortHandle AS QUAD ) AS LONG
DECLARE FUNCTION FaxCompleteJobParamsA LIB "winfax.dll" ALIAS "FaxCompleteJobParamsA" ( BYREF JobParams AS FAX_JOB_PARAMA
 , BYREF CoverpageInfo AS FAX_COVERPAGE_INFOA
 ) AS LONG
DECLARE FUNCTION FaxCompleteJobParamsW LIB "winfax.dll" ALIAS "FaxCompleteJobParamsW" ( BYREF JobParams AS FAX_JOB_PARAMW
 , BYREF CoverpageInfo AS FAX_COVERPAGE_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxCompleteJobParams = FaxCompleteJobParamsW
#ELSE
 MACRO FaxCompleteJobParams = FaxCompleteJobParamsA
#ENDIF
DECLARE FUNCTION FaxSendDocumentA LIB "winfax.dll" ALIAS "FaxSendDocumentA" ( BYVAL FaxHandle AS QUAD , BYREF FileName AS ASCIIZ , BYREF JobParams AS FAX_JOB_PARAMA , BYREF CoverpageInfo AS FAX_COVERPAGE_INFOA , BYREF FaxJobId AS QUAD ) AS LONG
DECLARE FUNCTION FaxSendDocumentW LIB "winfax.dll" ALIAS "FaxSendDocumentW" ( BYVAL FaxHandle AS QUAD
 , BYREF FileName AS WSTRINGZ
 , BYREF JobParams AS FAX_JOB_PARAMW
 , BYREF CoverpageInfo AS FAX_COVERPAGE_INFOW
 , BYREF FaxJobId AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSendDocument = FaxSendDocumentW
#ELSE
 MACRO FaxSendDocument = FaxSendDocumentA
#ENDIF
'typedef BOOL
'(CALLBACK *PFAX_RECIPIENT_CALLBACKA)(
' );
'FUNCTION FAX_RECIPIENT_CALLBACKA ( ' BYVAL FaxHandle AS DWORD
' , BYVAL RecipientNumber AS DWORD
' , BYVAL Context AS DWORD
' , BYREF JobParams AS FAX_JOB_PARAMA
' , BYREF CoverpageInfo AS FAX_COVERPAGE_INFOA
' ) AS LONG
'typedef BOOL
'(CALLBACK *PFAX_RECIPIENT_CALLBACKW)(
' );
'FUNCTION FAX_RECIPIENT_CALLBACKW ( ' BYVAL FaxHandle AS DWORD
' , BYVAL RecipientNumber AS DWORD
' , BYVAL Context AS DWORD
' , BYREF JobParams AS FAX_JOB_PARAMW
' , BYREF CoverpageInfo AS FAX_COVERPAGE_INFOW
' ) AS LONG
DECLARE FUNCTION FaxSendDocumentForBroadcastA LIB "winfax.dll" ALIAS "FaxSendDocumentForBroadcastA" ( BYVAL FaxHandle AS DWORD
 , BYREF FileName AS ASCIIZ
 , BYREF FaxJobId AS DWORD
 , BYVAL FaxRecipientCallback AS DWORD
 , BYVAL Context AS DWORD
 ) AS LONG
DECLARE FUNCTION FaxSendDocumentForBroadcastW LIB "winfax.dll" ALIAS "FaxSendDocumentForBroadcastW" ( BYVAL FaxHandle AS DWORD
 , BYREF FileName AS WSTRINGZ
 , BYREF FaxJobId AS DWORD
 , BYVAL FaxRecipientCallback AS DWORD
 , BYVAL Context AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSendDocumentForBroadcast = FaxSendDocumentForBroadcastW
#ELSE
 MACRO FaxSendDocumentForBroadcast = FaxSendDocumentForBroadcastA
#ENDIF
DECLARE FUNCTION FaxEnumJobsA LIB "winfax.dll" ALIAS "FaxEnumJobsA" ( BYVAL FaxHandle AS QUAD , BYREF JobEntry AS FAX_JOB_ENTRYA , BYREF JobsReturned AS QUAD ) AS LONG
DECLARE FUNCTION FaxEnumJobsW LIB "winfax.dll" ALIAS "FaxEnumJobsW" ( BYVAL FaxHandle AS QUAD
 , BYREF JobEntry AS FAX_JOB_ENTRYW
 , BYREF JobsReturned AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxEnumJobs = FaxEnumJobsW
#ELSE
 MACRO FaxEnumJobs = FaxEnumJobsA
#ENDIF
DECLARE FUNCTION FaxGetJobA LIB "winfax.dll" ALIAS "FaxGetJobA" ( BYVAL FaxHandle AS QUAD , BYVAL JobId AS QUAD , BYREF JobEntry AS FAX_JOB_ENTRYA ) AS LONG
DECLARE FUNCTION FaxGetJobW LIB "winfax.dll" ALIAS "FaxGetJobW" ( BYVAL FaxHandle AS QUAD
 , BYVAL JobId AS DWORD
 , BYREF JobEntry AS FAX_JOB_ENTRYW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxGetJob = FaxGetJobW
#ELSE
 MACRO FaxGetJob = FaxGetJobA
#ENDIF
DECLARE FUNCTION FaxSetJobA LIB "winfax.dll" ALIAS "FaxSetJobA" ( BYVAL FaxHandle AS QUAD , BYVAL JobId AS QUAD , BYVAL Command AS QUAD , BYREF JobEntry AS FAX_JOB_ENTRYA ) AS LONG
DECLARE FUNCTION FaxSetJobW LIB "winfax.dll" ALIAS "FaxSetJobW" ( BYVAL FaxHandle AS QUAD
 , BYVAL JobId AS DWORD
 , BYVAL Command AS DWORD
 , BYREF JobEntry AS FAX_JOB_ENTRYW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSetJob = FaxSetJobW
#ELSE
 MACRO FaxSetJob = FaxSetJobA
#ENDIF
DECLARE FUNCTION FaxGetPageData LIB "winfax.dll" ALIAS "FaxGetPageData" ( BYVAL FaxHandle AS QUAD , BYVAL JobId AS QUAD , BYREF Buffer AS QUAD , BYREF BufferSize AS QUAD , BYREF ImageWidth AS QUAD , BYREF ImageHeight AS QUAD ) AS LONG
DECLARE FUNCTION FaxGetDeviceStatusA LIB "winfax.dll" ALIAS "FaxGetDeviceStatusA" ( BYVAL FaxHandle AS QUAD
 , BYREF DeviceStatus AS FAX_DEVICE_STATUSA
 ) AS LONG
DECLARE FUNCTION FaxGetDeviceStatusW LIB "winfax.dll" ALIAS "FaxGetDeviceStatusW" ( BYVAL FaxHandle AS DWORD
 , BYREF DeviceStatus AS FAX_DEVICE_STATUSW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxGetDeviceStatus = FaxGetDeviceStatusW
#ELSE
 MACRO FaxGetDeviceStatus = FaxGetDeviceStatusA
#ENDIF
DECLARE FUNCTION FaxAbort LIB "winfax.dll" ALIAS "FaxAbort" ( BYVAL FaxHandle AS QUAD , BYVAL JobId AS QUAD ) AS LONG
DECLARE FUNCTION FaxGetConfigurationA LIB "winfax.dll" ALIAS "FaxGetConfigurationA" ( BYVAL FaxHandle AS QUAD
 , BYREF FaxConfig AS FAX_CONFIGURATIONA
 ) AS LONG
DECLARE FUNCTION FaxGetConfigurationW LIB "winfax.dll" ALIAS "FaxGetConfigurationW" ( BYVAL FaxHandle AS DWORD
 , BYREF FaxConfig AS FAX_CONFIGURATIONW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxGetConfiguration = FaxGetConfigurationW
#ELSE
 MACRO FaxGetConfiguration = FaxGetConfigurationA
#ENDIF
DECLARE FUNCTION FaxSetConfigurationA LIB "winfax.dll" ALIAS "FaxSetConfigurationA" ( BYVAL FaxHandle AS QUAD , BYREF FaxConfig AS FAX_CONFIGURATIONA ) AS LONG
DECLARE FUNCTION FaxSetConfigurationW LIB "winfax.dll" ALIAS "FaxSetConfigurationW" ( BYVAL FaxHandle AS QUAD
 , BYREF FaxConfig AS FAX_CONFIGURATIONW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSetConfiguration = FaxSetConfigurationW
#ELSE
 MACRO FaxSetConfiguration = FaxSetConfigurationA
#ENDIF
DECLARE FUNCTION FaxGetLoggingCategoriesA LIB "winfax.dll" ALIAS "FaxGetLoggingCategoriesA" ( BYVAL FaxHandle AS QUAD , BYREF Categories AS FAX_LOG_CATEGORYA , BYREF NumberCategories AS QUAD ) AS LONG
DECLARE FUNCTION FaxGetLoggingCategoriesW LIB "winfax.dll" ALIAS "FaxGetLoggingCategoriesW" ( BYVAL FaxHandle AS QUAD
 , BYREF Categories AS FAX_LOG_CATEGORYW
 , BYREF NumberCategories AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxGetLoggingCategories = FaxGetLoggingCategoriesW
#ELSE
 MACRO FaxGetLoggingCategories = FaxGetLoggingCategoriesA
#ENDIF
DECLARE FUNCTION FaxSetLoggingCategoriesA LIB "winfax.dll" ALIAS "FaxSetLoggingCategoriesA" ( BYVAL FaxHandle AS QUAD , BYREF Categories AS FAX_LOG_CATEGORYA , BYREF NumberCategories AS QUAD ) AS LONG
DECLARE FUNCTION FaxSetLoggingCategoriesW LIB "winfax.dll" ALIAS "FaxSetLoggingCategoriesW" ( BYVAL FaxHandle AS QUAD
 , BYREF Categories AS FAX_LOG_CATEGORYW
 , BYREF NumberCategories AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSetLoggingCategories = FaxSetLoggingCategoriesW
#ELSE
 MACRO FaxSetLoggingCategories = FaxSetLoggingCategoriesA
#ENDIF
DECLARE FUNCTION FaxEnumPortsA LIB "winfax.dll" ALIAS "FaxEnumPortsA" ( BYVAL FaxHandle AS QUAD , BYREF PortInfo AS FAX_PORT_INFOA , BYREF PortsReturned AS QUAD ) AS LONG
DECLARE FUNCTION FaxEnumPortsW LIB "winfax.dll" ALIAS "FaxEnumPortsW" ( BYVAL FaxHandle AS QUAD
 , BYREF PortInfo AS FAX_PORT_INFOW
 , BYREF PortsReturned AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxEnumPorts = FaxEnumPortsW
#ELSE
 MACRO FaxEnumPorts = FaxEnumPortsA
#ENDIF
DECLARE FUNCTION FaxGetPortA LIB "winfax.dll" ALIAS "FaxGetPortA" ( BYVAL FaxHandle AS QUAD , BYREF PortInfo AS FAX_PORT_INFOA ) AS LONG
DECLARE FUNCTION FaxGetPortW LIB "winfax.dll" ALIAS "FaxGetPortW" ( BYVAL FaxHandle AS QUAD
 , BYREF PortInfo AS FAX_PORT_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxGetPort = FaxGetPortW
#ELSE
 MACRO FaxGetPort = FaxGetPortA
#ENDIF
DECLARE FUNCTION FaxSetPortA LIB "winfax.dll" ALIAS "FaxSetPortA" ( BYVAL FaxHandle AS QUAD , BYREF PortInfo AS FAX_PORT_INFOA ) AS LONG
DECLARE FUNCTION FaxSetPortW LIB "winfax.dll" ALIAS "FaxSetPortW" ( BYVAL FaxHandle AS QUAD
 , BYREF PortInfo AS FAX_PORT_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSetPort = FaxSetPortW
#ELSE
 MACRO FaxSetPort = FaxSetPortA
#ENDIF
DECLARE FUNCTION FaxEnumRoutingMethodsA LIB "winfax.dll" ALIAS "FaxEnumRoutingMethodsA" ( BYVAL FaxHandle AS QUAD , BYREF RoutingMethod AS FAX_ROUTING_METHODA , BYREF MethodsReturned AS QUAD ) AS LONG
DECLARE FUNCTION FaxEnumRoutingMethodsW LIB "winfax.dll" ALIAS "FaxEnumRoutingMethodsW" ( BYVAL FaxHandle AS QUAD
 , BYREF RoutingMethod AS FAX_ROUTING_METHODW
 , BYREF MethodsReturned AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxEnumRoutingMethods = FaxEnumRoutingMethodsW
#ELSE
 MACRO FaxEnumRoutingMethods = FaxEnumRoutingMethodsA
#ENDIF
DECLARE FUNCTION FaxEnableRoutingMethodA LIB "winfax.dll" ALIAS "FaxEnableRoutingMethodA" ( BYVAL FaxHandle AS QUAD , BYREF RoutingGuid AS ASCIIZ , BYVAL Enabled AS LONG ) AS LONG
DECLARE FUNCTION FaxEnableRoutingMethodW LIB "winfax.dll" ALIAS "FaxEnableRoutingMethodW" ( BYVAL FaxHandle AS QUAD
 , BYREF RoutingGuid AS WSTRINGZ
 , BYVAL Enabled AS LONG
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxEnableRoutingMethod = FaxEnableRoutingMethodW
#ELSE
 MACRO FaxEnableRoutingMethod = FaxEnableRoutingMethodA
#ENDIF
DECLARE FUNCTION FaxEnumGlobalRoutingInfoA LIB "winfax.dll" ALIAS "FaxEnumGlobalRoutingInfoA" ( BYVAL FaxHandle AS QUAD , BYREF RoutingInfo AS FAX_GLOBAL_ROUTING_INFOA , BYREF MethodsReturned AS QUAD ) AS LONG
DECLARE FUNCTION FaxEnumGlobalRoutingInfoW LIB "winfax.dll" ALIAS "FaxEnumGlobalRoutingInfoW" ( BYVAL FaxHandle AS QUAD
 , BYREF RoutingInfo AS FAX_GLOBAL_ROUTING_INFOW
 , BYREF MethodsReturned AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxEnumGlobalRoutingInfo = FaxEnumGlobalRoutingInfoW
#ELSE
 MACRO FaxEnumGlobalRoutingInfo = FaxEnumGlobalRoutingInfoA
#ENDIF
DECLARE FUNCTION FaxSetGlobalRoutingInfoA LIB "winfax.dll" ALIAS "FaxSetGlobalRoutingInfoA" ( BYVAL FaxHandle AS QUAD , BYREF RoutingInfo AS FAX_GLOBAL_ROUTING_INFOA ) AS LONG
DECLARE FUNCTION FaxSetGlobalRoutingInfoW LIB "winfax.dll" ALIAS "FaxSetGlobalRoutingInfoW" ( BYVAL FaxHandle AS QUAD
 , BYREF RoutingInfo AS FAX_GLOBAL_ROUTING_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSetGlobalRoutingInfo = FaxSetGlobalRoutingInfoW
#ELSE
 MACRO FaxSetGlobalRoutingInfo = FaxSetGlobalRoutingInfoA
#ENDIF
DECLARE FUNCTION FaxGetRoutingInfoA LIB "winfax.dll" ALIAS "FaxGetRoutingInfoA" ( BYVAL FaxHandle AS QUAD , BYREF RoutingGuid AS ASCIIZ , BYREF RoutingInfoBuffer AS QUAD , BYREF RoutingInfoBufferSize AS QUAD ) AS LONG
DECLARE FUNCTION FaxGetRoutingInfoW LIB "winfax.dll" ALIAS "FaxGetRoutingInfoW" ( BYVAL FaxHandle AS QUAD
 , BYREF RoutingGuid AS WSTRINGZ
 , BYREF RoutingInfoBuffer AS DWORD
 , BYREF RoutingInfoBufferSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxGetRoutingInfo = FaxGetRoutingInfoW
#ELSE
 MACRO FaxGetRoutingInfo = FaxGetRoutingInfoA
#ENDIF
DECLARE FUNCTION FaxSetRoutingInfoA LIB "winfax.dll" ALIAS "FaxSetRoutingInfoA" ( BYVAL FaxHandle AS QUAD , BYREF RoutingGuid AS ASCIIZ , BYVAL RoutingInfoBuffer AS BYTE PTR , BYVAL RoutingInfoBufferSize AS QUAD ) AS LONG
DECLARE FUNCTION FaxSetRoutingInfoW LIB "winfax.dll" ALIAS "FaxSetRoutingInfoW" ( BYVAL FaxHandle AS QUAD
 , BYREF RoutingGuid AS WSTRINGZ
 , BYVAL RoutingInfoBuffer AS BYTE PTR
 , BYVAL RoutingInfoBufferSize AS DWORD
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxSetRoutingInfo = FaxSetRoutingInfoW
#ELSE
 MACRO FaxSetRoutingInfo = FaxSetRoutingInfoA
#ENDIF
DECLARE FUNCTION FaxInitializeEventQueue LIB "winfax.dll" ALIAS "FaxInitializeEventQueue" ( BYVAL FaxHandle AS QUAD , BYVAL CompletionPort AS QUAD , BYVAL CompletionKey AS QUAD , BYVAL hWnd AS QUAD , BYVAL MessageStart AS QUAD ) AS LONG
DECLARE SUB FaxFreeBuffer LIB "winfax.dll" ALIAS "FaxFreeBuffer" ( BYVAL Buffer AS QUAD
 ) ' void
DECLARE FUNCTION FaxStartPrintJobA LIB "winfax.dll" ALIAS "FaxStartPrintJobA" ( BYREF PrinterName AS ASCIIZ , BYREF PrintInfo AS FAX_PRINT_INFOA , BYREF FaxJobId AS QUAD , BYREF FaxContextInfo AS FAX_CONTEXT_INFOA ) AS LONG
DECLARE FUNCTION FaxStartPrintJobW LIB "winfax.dll" ALIAS "FaxStartPrintJobW" ( BYREF PrinterName AS ASCIIZ
 , BYREF PrintInfo AS FAX_PRINT_INFOW
 , BYREF FaxJobId AS DWORD
 , BYREF FaxContextInfo AS FAX_CONTEXT_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxStartPrintJob = FaxStartPrintJobW
#ELSE
 MACRO FaxStartPrintJob = FaxStartPrintJobA
#ENDIF
DECLARE FUNCTION FaxPrintCoverPageA LIB "winfax.dll" ALIAS "FaxPrintCoverPageA" ( BYREF FaxContextInfo AS FAX_CONTEXT_INFOA , BYREF CoverPageInfo AS FAX_COVERPAGE_INFOA ) AS LONG
DECLARE FUNCTION FaxPrintCoverPageW LIB "winfax.dll" ALIAS "FaxPrintCoverPageW" ( BYREF FaxContextInfo AS FAX_CONTEXT_INFOW
 , BYREF CoverPageInfo AS FAX_COVERPAGE_INFOW
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxPrintCoverPage = FaxPrintCoverPageW
#ELSE
 MACRO FaxPrintCoverPage = FaxPrintCoverPageA
#ENDIF
DECLARE FUNCTION FaxRegisterServiceProviderW LIB "winfax.dll" ALIAS "FaxRegisterServiceProviderW" ( BYREF DeviceProvider AS WSTRINGZ , BYREF FriendlyName AS WSTRINGZ , BYREF ImageName AS WSTRINGZ , BYREF TspName AS WSTRINGZ ) AS LONG
'#define FaxRegisterServiceProvider FaxRegisterServiceProviderW
MACRO FaxRegisterServiceProvider = FaxRegisterServiceProviderW
DECLARE FUNCTION FaxUnregisterServiceProviderW LIB "winfax.dll" ALIAS "FaxUnregisterServiceProviderW" ( BYREF DeviceProvider AS WSTRINGZ ) AS LONG
'#define FaxUnregisterServiceProvider FaxUnregisterServiceProviderW
MACRO FaxUnregisterServiceProvider = FaxUnregisterServiceProviderW
'typedef BOOL
'(CALLBACK *PFAX_ROUTING_INSTALLATION_CALLBACKW)(
' );
'#define PFAX_ROUTING_INSTALLATION_CALLBACK PFAX_ROUTING_INSTALLATION_CALLBACKW
'FUNCTION FAX_ROUTING_INSTALLATION_CALLBACKW ( ' BYVAL FaxHandle AS DWORD
' , BYVAL Context AS DWORD
' , BYREF MethodName AS WSTRINGZ
' , BYREF FriendlyName AS WSTRINGZ
' , BYREF FunctionName AS WSTRINGZ
' , BYREF Guid AS WSTRINGZ
' ) AS LONG
DECLARE FUNCTION FaxRegisterRoutingExtensionW LIB "winfax.dll" ALIAS "FaxRegisterRoutingExtensionW" ( BYVAL FaxHandle AS DWORD
 , BYREF ExtensionName AS WSTRINGZ
 , BYREF FriendlyName AS WSTRINGZ
 , BYREF ImageName AS WSTRINGZ
 , BYVAL CallBack AS DWORD
 , BYVAL Context AS DWORD
 ) AS LONG
'#define FaxRegisterRoutingExtension FaxRegisterRoutingExtensionW
MACRO FaxRegisterRoutingExtension = FaxRegisterRoutingExtensionW
DECLARE FUNCTION FaxUnregisterRoutingExtensionA LIB "winfax.dll" ALIAS "FaxUnregisterRoutingExtensionA" ( BYVAL FaxHandle AS QUAD , BYREF lpctstrExtensionName AS ASCIIZ ) AS LONG
DECLARE FUNCTION FaxUnregisterRoutingExtensionW LIB "winfax.dll" ALIAS "FaxUnregisterRoutingExtensionW" ( BYVAL FaxHandle AS QUAD
 , BYREF lpctstrExtensionName AS WSTRINGZ
 ) AS LONG
#IF %DEF(%UNICODE)
 MACRO FaxUnregisterRoutingExtension = FaxUnregisterRoutingExtensionW
#ELSE
 MACRO FaxUnregisterRoutingExtension = FaxUnregisterRoutingExtensionA
#ENDIF
DECLARE FUNCTION FaxAccessCheck LIB "winfax.dll" ALIAS "FaxAccessCheck" ( BYVAL FaxHandle AS QUAD , BYVAL AccessMask AS QUAD ) AS LONG
'//
'// Fax Specific Access Rights
'//
%EQUATE `FAX_JOB_SUBMIT = &H0001
%EQUATE `FAX_JOB_QUERY = &H0002
%EQUATE `FAX_CONFIG_QUERY = &H0004
%EQUATE `FAX_CONFIG_SET = &H0008
%EQUATE `FAX_PORT_QUERY = &H0010
%EQUATE `FAX_PORT_SET = &H0020
%EQUATE `FAX_JOB_MANAGE = &H0040
%EQUATE `FAX_READ = %STANDARD_RIGHTS_READ OR %FAX_JOB_QUERY OR %FAX_CONFIG_QUERY OR %FAX_PORT_QUERY
%EQUATE `FAX_WRITE = %STANDARD_RIGHTS_WRITE OR %FAX_JOB_SUBMIT
%EQUATE `FAX_ALL_ACCESS = %STANDARD_RIGHTS_ALL OR %FAX_JOB_SUBMIT OR %FAX_JOB_QUERY OR %FAX_CONFIG_QUERY OR %FAX_CONFIG_SET OR %FAX_PORT_QUERY OR %FAX_PORT_SET OR %FAX_JOB_MANAGE
#ENDIF
