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.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#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?