Servus Leuz,
Versuche ein C++ Programm zu erstellen, mit dem ich z.B. mittels TAPI die Anrufende Nummer anzeigen kann und diese weiterverarbeiten. Da ich noch etwas neu in C++ bin tu ich mich etwas schwer mit dem Code und versuche es anhand dem Bsp. von MSDN.
Was muss ich noch wo hineinschreiben, um die Funktion Create() aufzurufen?
Versuche ein C++ Programm zu erstellen, mit dem ich z.B. mittels TAPI die Anrufende Nummer anzeigen kann und diese weiterverarbeiten. Da ich noch etwas neu in C++ bin tu ich mich etwas schwer mit dem Code und versuche es anhand dem Bsp. von MSDN.
Code:
#include <windows.h>
#include "tapi.h"
#pragma hdrstop
//---------------------------------------------------------------------------
#pragma argsused
class CTapiConnection
{
protected:
// This area contains the protected members of the CTapiConnection class.
DWORD m_dwNumDevs; // the number of line devices available
DWORD m_dwDeviceID; // the line device ID
DWORD m_dwRequestedID;
LONG m_lAsyncReply;
// BOOLEANS to handle reentrancy.
BOOL m_bShuttingDown;
BOOL m_bStoppingCall;
BOOL m_bInitializing;
BOOL m_bReplyReceived;
BOOL m_bTapiInUse; // whether TAPI is in use or not
BOOL m_bInitialized; // whether TAPI has been initialized
public:
// This area contains the public members of the CTapiConnection class.
HLINEAPP m_hLineApp; // the usage handle of this application for TAPI
HCALL m_hCall; // handle to the call
HLINE m_hLine; // handle to the open line
DWORD m_dwAPIVersion; // the API version
char m_szPhoneNumber[64]; // the phone number to call
protected:
// Here is where I put the protected (internal) functions.
BOOL ShutdownTAPI();
BOOL HandleLineErr(long lLineErr);
LPLINEDEVCAPS GetDeviceLine(DWORD *dwAPIVersion,
LPLINEDEVCAPS lpLineDevCaps);
LPLINEDEVCAPS MylineGetDevCaps(LPLINEDEVCAPS lpLineDevCaps,
DWORD dwDeviceID, DWORD dwAPIVersion);
LPVOID CheckAndReAllocBuffer(LPVOID lpBuffer, size_t sizeBufferMinimum);
LPLINEADDRESSCAPS MylineGetAddressCaps (LPLINEADDRESSCAPS lpLineAddressCaps,
DWORD dwDeviceID, DWORD dwAddressID, DWORD dwAPIVersion,
DWORD dwExtVersion);
BOOL MakeTheCall(LPLINEDEVCAPS lpLineDevCaps,LPCSTR lpszAddress);
LPLINECALLPARAMS CreateCallParams (LPLINECALLPARAMS lpCallParams,
LPCSTR lpszDisplayableAddress);
long WaitForReply (long lRequestID);
void HandleLineCallState(DWORD dwDevice, DWORD dwMessage,
DWORD dwCallbackInstance,
DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
private:
// This section is for private functions.
public:
// Public functions.
CTapiConnection();
~CTapiConnection();
BOOL Create(char *szPhoneNumber = NULL);
BOOL DialCall(char *szPhoneNumber = NULL);
BOOL HangupCall();
static void CALLBACK lineCallbackFunc(
DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);
};
WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
Create();
return 0;
}
//---------------------------------------------------------------------------
BOOL CTapiConnection::Create(char *szPhoneNumber)
{
long lReturn;
const SUCCESS= 0;
MessageBox(NULL,"There are no telephony devices installed.", "TEST", 1);
// If we're already initialized, then initialization succeeds.
if (m_hLineApp)
return TRUE;
// If we're in the middle of initializing, then fail, we're not done.
if (m_bInitializing)
return FALSE;
m_bInitializing = TRUE;
// Initialize TAPI.
do
{
lReturn = ::lineInitialize(&m_hLineApp,
NULL,
lineCallbackFunc,
"DialIt",
&m_dwNumDevs);
if (m_dwNumDevs != 0)
{
MessageBox(NULL,"There are no telephony devices installed.", "TEST", 1);
m_bInitializing = FALSE;
return FALSE;
}
if (HandleLineErr(lReturn))
continue;
else
{
OutputDebugString("lineInitialize unhandled error\n");
m_bInitializing = FALSE;
return FALSE;
}
}
while(lReturn != SUCCESS);
// If the user furnished a phone number, copy it over.
if (szPhoneNumber)
strcpy(m_szPhoneNumber, szPhoneNumber);
m_bInitializing = FALSE;
return TRUE;
}
Was muss ich noch wo hineinschreiben, um die Funktion Create() aufzurufen?