|
-
February 6th, 2005, 05:06 PM
#1
C++ Newbie - What have I done wrong?
I am wanting to use the exported function "SendFax".
When I call this function it returns 15, and nothing else happens.
I have to admit defeat here.
Please help.
Code follows...
Wee!
Code:
// The following ifdef block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the ENZ_FAXING_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// ENZ_FAXING_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
#ifdef ENZ_FAXING_EXPORTS
#define ENZ_FAXING_API __declspec(dllexport)
#else
#define ENZ_FAXING_API __declspec(dllimport)
#endif
// This class is exported from the ENZ_Faxing.dll
class ENZ_FAXING_API CENZ_Faxing {
public:
CENZ_Faxing();
//properties
char* FaxNumber;
// TODO: add your methods here
char* SetFaxNumber(char* thisFaxNumber);
char* GetFaxNumber();
};
extern ENZ_FAXING_API int nENZ_Faxing;
ENZ_FAXING_API int fnENZ_Faxing(void);
// ENZ_Faxing.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
#include "ENZ_Faxing.h"
#include "winfax.h"
#include "fstream.h"
#include "stdio.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
// This is the constructor of a class that has been exported.
// see ENZ_Faxing.h for the class definition
CENZ_Faxing::CENZ_Faxing()
{
return;
}
char* CENZ_Faxing::SetFaxNumber(char* thisFaxNumber)
{
return thisFaxNumber;
};
char* CENZ_Faxing::GetFaxNumber()
{
return FaxNumber;
};
ENZ_FAXING_API int SendFax(char* thisFaxNumber, int DEBUG)
{
int retVal;
CENZ_Faxing FaxApp;
FILE *thisFile;
char* output = "";
if (DEBUG == 1)
{
// Open a file for outputting debug information.
if ((thisFile = fopen("c:\\temp\\debug.log","r+")) == NULL)
{
return 20;
}
else
{
// Write to the file
fprintf(thisFile, "FaxApp Object has been declared ok.\n" );
}
};
if (FaxApp.FaxNumber == NULL)
{
FaxApp.FaxNumber = FaxApp.SetFaxNumber(thisFaxNumber);
};
if( DEBUG==1 )
{ // Write to the file
fprintf(thisFile, "Fax number has been set ok\n");
};
FAX_PRINT_INFO fpi;
fpi.RecipientNumber = FaxApp.GetFaxNumber();
fpi.SizeOfStruct=sizeof(FAX_PRINT_INFO);
if(DEBUG==1)
{
// Write to the file
fprintf(thisFile, "Process has initialised ok\n");
};
DWORD nJobID;
FAX_CONTEXT_INFO fci;
fci.SizeOfStruct=sizeof(FAX_CONTEXT_INFO);
retVal = FaxStartPrintJob(NULL,&fpi,&nJobID,&fci);
if (DEBUG==1)
{
fprintf(thisFile, "FaxStartPrintJob returned &d\n", retVal);
};
retVal = EndDoc(NULL);
if (DEBUG==1)
{
fprintf(thisFile, "EndDoc returned %d\n",retVal);
//Close the file
fclose(thisFile);
}
return 1;
}
Last edited by Andreas Masur; February 6th, 2005 at 05:52 PM.
Reason: Added code tags...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|