🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
2 messages
2 total messages Started by Bill Bream Wed, 11 Apr 2007 23:17
Sending a FAX via the Windows FAX Console
#2139
Author: Bill Bream
Date: Wed, 11 Apr 2007 23:17
76 lines
2888 bytes
Hello,
I'm trying to send a FAX using Windows FAX Console programmatically with "FaxSendDocument" in "winfax.dll". I'm getting a "parameter incorrect" message. Can you help me out? - What's wrong with my code? - Is there a better way? - Would you suggest using a 3rd party component? Thanks in advance for you answer. Here's the code:

void TfrmMain::FaxDocument()
{
	HANDLE               fxHandle;
	PFAX_JOB_PARAM       pfxParam;
	PFAX_COVERPAGE_INFO  pcpInfo;
	DWORD                dwJobId;
	LPCTSTR              pszServerName = NULL;


        // POINTING to local machine right now:
	// pszServerName = 
	//////////

	// Connect to the fax server
	FaxConnectFaxServerPtr =
	   (FAX_CONNECT_FAX_SERVER_A)GetProcAddress(FDllHandle, "FaxConnectFaxServerA");
	if(FaxConnectFaxServerPtr)
	{
		if(!FaxConnectFaxServerPtr(pszServerName, &fxHandle))
		{
			ReportOSError();
			ShowMessage("ERROR connecting to the FAX Server!");
			return;
		}
	}

	FaxClosePtr = (FAX_CLOSE)GetProcAddress(FDllHandle, "FaxClose");

	// Prepare and allocate job params and cover page data
	FaxCompleteJobParamsPtr =
		(FAX_COMPLETE_JOB_PARAMS_A)GetProcAddress(FDllHandle, "FaxCompleteJobParamsA");
	if(FaxCompleteJobParamsPtr)
	{
		if(!FaxCompleteJobParamsPtr(&pfxParam, &pcpInfo ))
		{
			ReportOSError();
			if(FaxClosePtr)
			   FaxClosePtr(fxHandle);
			return;
		}
	}

		 pcpInfo = NULL;

	const String TempFileName =
		"c:\\Bill\\faxserver.doc";
	// Try to send
	FaxSendDocumentPtr =
		(FAX_SEND_DOCUMENT_A)GetProcAddress(FDllHandle, "FaxSendDocumentA");
	if(FaxSendDocumentPtr)
	{
		if(FaxSendDocumentPtr(fxHandle, TempFileName.c_str(), pfxParam, pcpInfo,
		   &dwJobId))
			   ShowMessage("SendDoc succeeded");
		else
			{
				ReportOSError();
				ShowMessage("ERROR with FaxSendDocument!");
			}
	}

	// Cleanup here:
	FaxFreeBufferPtr = (FAX_FREE_BUFFER)GetProcAddress(FDllHandle, "FaxFreeBuffer");
	if(FaxFreeBufferPtr)
	   FaxFreeBufferPtr(pfxParam);

	if(pcpInfo && FaxFreeBufferPtr)
	   FaxFreeBufferPtr(pcpInfo);

	if(FaxClosePtr)
	   FaxClosePtr(fxHandle);
}
Re: Sending a FAX via the Windows FAX Console
#2141
Author: Bob Gonder
Date: Thu, 12 Apr 2007 05:04
27 lines
1808 bytes
Bill Bream wrote:

>I'm getting a "parameter incorrect" message. Can you help me out?

You didn't say which line gives that error.

>	if(!FaxConnectFaxServerPtr(pszServerName, &fxHandle))
	if( ! FaxConnectFaxServerPtr( NULL, &fxHandle ) )

>	if(!FaxCompleteJobParamsPtr(&pfxParam, &pcpInfo ))
>
>	 pcpInfo = NULL;

You didn't free pcpInfo.
You didn't fill in the recipient info in the pfxParam.

>	const String TempFileName =
>		"c:\\Bill\\faxserver.doc";
>	// Try to send
>	if(FaxSendDocumentPtr(fxHandle, TempFileName.c_str(), pfxParam, pcpInfo,
>		   &dwJobId))
	if( FaxSendDocumentPtr( fxHandle, "c:\\Bill\\faxserver.doc",
				 pfxParam, NULL, &dwJobId ) )

>	   FaxFreeBufferPtr(pfxParam);
>	   FaxFreeBufferPtr(pcpInfo);
>	   FaxClosePtr(fxHandle);
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads