WEB开发网
开发学院手机开发Windows Mobile 开发 windows ce gprs 拨号程序 阅读

windows ce gprs 拨号程序

 2010-08-22 12:44:00 来源:WEB开发网   
核心提示:#include "stdafx.h"#include "ras.h"HANDLE hPort = INVALID_HANDLE_VALUE;HRASCONN hRasConn = NULL;BOOL CreatePort(){DWORD dwNumBytesWritten;BO

#include "stdafx.h"

#include "ras.h"

HANDLE hPort = INVALID_HANDLE_VALUE;

HRASCONN hRasConn = NULL;

BOOL CreatePort()

{

DWORD dwNumBytesWritten;

BOOL fRet;

BYTE Bytes[]={'A','T','+','C','G','D','C','O','N','T','=','1',',','"','I','P','"',',',

'"','C','M','N','E','T','"',0x0D,'A','T','D','T','*','9','9','#',0x0D};

//open the serial port

hPort = CreateFile(TEXT("COM8:"),GENERIC_READ | GENERIC_WRITE,0,NULL,OPEN_EXISTING,0,NULL);

if ( hPort == INVALID_HANDLE_VALUE )

{

// Could not open the port.

//printf("Open the serial port failed ");

return FALSE;

}

//BYTE Bytes[]={'A','T',0x0D};

//DWORD CgdcontSize = sizeof(Cgdcont);

DWORD BytesSize = sizeof(Bytes);

//fRet = WriteFile(hPort,Cgdcont,CgdcontSize, &dwNumBytesWritten,NULL);

fRet = WriteFile(hPort,Bytes,BytesSize, &dwNumBytesWritten,NULL);

fRet = ReadFile(hPort,Bytes,4,&dwNumBytesWritten,NULL);

if(fRet)

{

//printf("open the serial port successful ");

CloseHandle(hPort);

}

else

{

//close the serial port

CloseHandle(hPort);

//printf("Close serial port successful ");

}

return TRUE;

}

LRESULT CALLBACK WndProc (HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)

{

RASCONNSTATE RasState = (RASCONNSTATE)wParam;

switch(Msg)

{

case WM_RASDIALEVENT:

switch(RasState)

{

case RASCS_OpenPort:

printf("正在打开端口 ");

break;

case RASCS_PortOpened:

printf("端口已经打开 ");

break;

case RASCS_ConnectDevice:

1 2  下一页

Tags:windows ce gprs

编辑录入:coldstar [复制链接] [打 印]
赞助商链接