Windows CE for >
来源:互联网 发布:苹果软件信任设置 编辑:程序博客网 时间:2024/05/13 01:49
Windows CE for <<RAS 拨号编程>>
#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/n/r");
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 /n/r");
CloseHandle(hPort);
}
else
{
//close the serial port
CloseHandle(hPort);
//printf("Close serial port successful/n/r");
}
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("正在打开端口/n/r");
break;
case RASCS_PortOpened:
printf("端口已经打开/n/r");
break;
case RASCS_ConnectDevice:
printf("正在连接设备/n/r");
break;
case RASCS_Connected:
//int i;
//printf("已连接/n/r");
//scanf("%d",i);
//if(i==1)
//{
// RasHangUp(hRasConn);
//}
break;
case RASCS_Disconnected:
printf("连接已断开/n/r");
break;
default:
printf("未知/n/r");
break;
}
break;
default:
return DefWindowProc(hWnd, Msg, wParam, lParam);
}
return TRUE;
}
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
HWND hwnd;
MSG msg;
WNDCLASS wc;
wc.style = 0;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = 0;
wc.hCursor = 0;
wc.hbrBackground = NULL;
wc.lpszMenuName = 0;
wc.lpszClassName = _T("embo");
RegisterClass(&wc);
hwnd = CreateWindow(_T("embo"),_T("EmboConnection"),0,0,0,0,0,NULL,NULL,hInstance,NULL);
ShowWindow(hwnd,0);
CreatePort();
RASDIALPARAMS rdParams;//拨号参数
//初始化拨号参数
rdParams.dwSize=sizeof(RASDIALPARAMSW);
wcscpy(rdParams.szEntryName,_T("Embo Connection"));
wcscpy(rdParams.szPhoneNumber,_T(""));
wcscpy(rdParams.szCallbackNumber,_T(""));
wcscpy(rdParams.szUserName,_T(""));
wcscpy(rdParams.szPassword,_T(""));
wcscpy(rdParams.szDomain,_T(""));
DWORD dwRet;
//拨号连接
//printf("connecting /n/r");
dwRet = RasDial(NULL,NULL,&rdParams,0xFFFFFFFF,hwnd ,&hRasConn);
if(dwRet != 0)//connection successful
{
RasHangUp(hRasConn);
}
while ( GetMessage(&msg, NULL, 0, 0) != FALSE )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
- Windows CE for >
- Perl 5.6 for Windows CE
- "sysgen_" dependency for Windows CE
- Shell Reference for Windows Embedded CE
- C library extensions for Windows CE
- Building QTWekit for Windows CE From trunk
- QT for Windows CE 5.0/6.0
- Windows CE Virtual Memory Layout for Debugging
- Windows CE Virtual Memory Layout for Debugging
- Windows CE
- Windows CE
- windows CE
- windows ce
- windows ce
- Windows CE
- Windows CE
- Microsoft Windows CE Toolkit for Visual Basic 6.0 教程
- Windows CE 5.0 for VMWare虚拟机和BSP下载
- Joomla模块学习之后台mod_login模块
- VC++使用ADO连接SQL Server数据库
- 细谈C/C++中的前置++和后置++
- WinCe系统3G和RAS拨号 - 基于 .NET Compact Framework和C++
- Poj1465 Multiple(BFS+余数判重)
- Windows CE for >
- Intel奔腾指令速查手册
- bbossgroups-3.0 发布,新增子项目bboss mvc
- WINCE基于MC8630的3G模块的控制和加载
- 关于PETS5级考试方面谈谈自己的想法
- Intel 64 and IA-32 架构,软件开发人员手册,2A&2B,指令集,A-Z(CHM版)[
- 升级linux 2.6.37.2内核
- IntelCPU机器指令手册
- Intel IA-32 架构软件开发者手册,第二卷:指令集(上)