以下示例代码演示了如何在WIN CE6.0下实现拨号:
#include
#include
using namespace Microsoft.WindowsMobile.Telephony;
#pragma comment (lib, "Tapi32.lib")
#define DEVCAPSSIZE 1024
long lRet;
HLINEAPP hLineApp;
HINSTANCE hInst;
DWORD dwNumDevs;
DWORD dwDeviceID;
DWORD dwAPIVersion;
LINEEXTENSIONID ExtensionID;
LPLINEDEVCAPS lpDevCaps;
HLINE hLine;
HCALL hCall;
LPTSTR lpszDialableAddr;
TCHAR szPhoneNumber[120] = {TEXT("10086")};
LINECALLPARAMS CallParams;
DWORD dwCountryCode = 86;
void CallParamInit(LINECALLPARAMS &cp);
void CALLBACK
lineCallbackFunc(DWORD dwDevice, DWORD dwMsg, DWORD dwCallbackInstance,
DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
return;
}
int WINAPI WinMain (HINSTANCE hInstance,
HINSTANCE hPreviousInstance,
LPWSTR pszCommandLine,
int nCommandShow)
{
lRet = lineInitialize(
&hLineApp,
hInst,
lineCallbackFunc,
NULL,
&dwNumDevs
);
lRet = lineNegotiateAPIVersion(
hLineApp,
dwDeviceID,
0x00010000,
0x00030000,
&dwAPIVersion,
&ExtensionID
);
lpDevCaps = (LPLINEDEVCAPS)(LocalAlloc(LPTR, DEVCAPSSIZE));
lpDevCaps->dwTotalSize = DEVCAPSSIZE;
lRet = lineGetDevCaps(
hLineApp,
dwDeviceID,
dwAPIVersion,
0,
lpDevCaps
);
lRet = lineOpen(
hLineApp,
dwDeviceID,
&hLine,
dwAPIVersion,
0,
0,
LINECALLPRIVILEGE_NONE,
LINEMEDIAMODE_INTERACTIVEVOICE,
NULL
);
lpszDialableAddr = szPhoneNumber;
CallParamInit(CallParams);
lRet = lineMakeCall(
hLine,
&hCall,
lpszDialableAddr,
0,
&CallParams
);
Sleep(10000);
return TRUE;
}
void CallParamInit(LINECALLPARAMS &cp)
{
cp.dwTotalSize = sizeof(LINECALLPARAMS);
cp.dwBearerMode = LINEBEARERMODE_VOICE;
cp.dwMinRate = 9600;
cp.dwMaxRate = 9600;
cp.dwMediaMode = LINEMEDIAMODE_INTERACTIVEVOICE;
cp.dwCallParamFlags = LINECALLPARAMFLAGS_IDLE;
cp.dwAddressMode = LINEADDRESSMODE_ADDRESSID;
cp.dwAddressID = 0;
cp.DialParams.dwDialPause = 0;
cp.DialParams.dwDialSpeed = 0;
cp.DialParams.dwDigitDuration = 0;
cp.DialParams.dwWaitForDialtone = 0;
cp.dwOrigAddressSize = 0;
cp.dwOrigAddressOffset = 0;
cp.dwDisplayableAddressSize = 0;
cp.dwDisplayableAddressOffset = 0;
cp.dwCalledPartySize = 0;
cp.dwCalledPartyOffset = 0;
cp.dwCommentSize = 0;
cp.dwCommentOffset = 0;
cp.dwUserUserInfoSize = 0;
cp.dwUserUserInfoOffset = 0;
cp.dwHighLevelCompSize = 0;
cp.dwHighLevelCompOffset = 0;
cp.dwLowLevelCompSize = 0;
cp.dwLowLevelCompOffset = 0;
cp.dwDevSpecificSize = 0;
cp.dwDevSpecificOffset = 0;
}
复制代码