1.连接不上。
2。无法得到状态信息。
请指点?、#include <windows.h>
#include "ras.h"
#include "resource.h"
#include <TCHAR.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
static TCHAR szAppName[] = TEXT ("adsl") ;
char text[50];
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow){
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = (LPCSTR)IDR_MENU1; //在窗口类中定义菜单的字符串名
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("adsl!"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
RASCONNSTATE rasstate;
LPHRASCONN m_hrasconn;
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
//HWND hbutton;
int wmpara; //这个参数是提取出WM_COMMAND消息参数WPAPAM的低16位
switch (message)
{
case WM_CREATE :
/*代码省略 */
return 0 ;
case WM_COMMAND:
wmpara=LOWORD(wParam);
switch(wmpara)
{
case ID_CONNECITON:// 点击菜单中“连接按钮”进入ID_CONNECITON:处理中
HRASCONN hRasConn;//连接句柄
RASDIALPARAMS RasDialParams;
RasDialParams.dwSize = sizeof(RASDIALPARAMS);
_tcscpy(RasDialParams.szEntryName,_T("宽带拨号器"));
_tcscpy(RasDialParams.szPhoneNumber, _T(""));
_tcscpy(RasDialParams.szCallbackNumber, _T(""));
_tcscpy(RasDialParams.szUserName,"xxxxxx s@adsl");
_tcscpy(RasDialParams.szPassword,"xxxxx");
tcscpy(RasDialParams.szDomain, _T(""));
int temp;
temp=RasDial(NULL,NULL,&RasDialParams,0xFFFFFFFF,hwnd,&hRasConn);//(不知哪里设置有误,总无法连接上。)
if(temp!=0){
MessageBox (NULL, TEXT ("connection error!!"), szAppName, MB_ICONERROR) ;
hRasConn = NULL;}
else
{
MessageBox (NULL, TEXT ("connection success!!"), szAppName, MB_ICONERROR) ;
}
return 0;
case ID_ABORT:
//
return 0;
case ID_EXIT:
DestroyWindow(hwnd);//
return 0;
}
case WM_RASDIALEVENT://为什么总不进入此事件处理呢?????????
rasstate= (RASCONNSTATE)wParam;
switch(rasstate)
{
case RASCS_OpenPort:
_tcscpy(text,"打开端口……");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_PortOpened:
_tcscpy(text,"端口已打开.");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_ConnectDevice:
_tcscpy(text,"连接设备");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_DeviceConnected:
_tcscpy(text,"设备已连接.");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_Authenticate:
_tcscpy(text,"验证用户及密码");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_Authenticated:
_tcscpy(text,"通过");
InvalidateRect(hwnd,NULL,1);
case RASCS_Connected:
_tcscpy(text,"已连接");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_Disconnected:
_tcscpy(text,"连接已断开");
InvalidateRect(hwnd,NULL,1);
m_hrasconn=NULL;
return 0;
} case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, text, -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ;}
2。无法得到状态信息。
请指点?、#include <windows.h>
#include "ras.h"
#include "resource.h"
#include <TCHAR.h>
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
static TCHAR szAppName[] = TEXT ("adsl") ;
char text[50];
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow){
HWND hwnd ;
MSG msg ;
WNDCLASS wndclass ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc = WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
wndclass.lpszMenuName = (LPCSTR)IDR_MENU1; //在窗口类中定义菜单的字符串名
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox (NULL, TEXT ("This program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow (szAppName, // window class name
TEXT ("adsl!"), // window caption
WS_OVERLAPPEDWINDOW, // window style
CW_USEDEFAULT, // initial x position
CW_USEDEFAULT, // initial y position
CW_USEDEFAULT, // initial x size
CW_USEDEFAULT, // initial y size
NULL, // parent window handle
NULL, // window menu handle
hInstance, // program instance handle
NULL) ; // creation parameters ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
RASCONNSTATE rasstate;
LPHRASCONN m_hrasconn;
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect ;
//HWND hbutton;
int wmpara; //这个参数是提取出WM_COMMAND消息参数WPAPAM的低16位
switch (message)
{
case WM_CREATE :
/*代码省略 */
return 0 ;
case WM_COMMAND:
wmpara=LOWORD(wParam);
switch(wmpara)
{
case ID_CONNECITON:// 点击菜单中“连接按钮”进入ID_CONNECITON:处理中
HRASCONN hRasConn;//连接句柄
RASDIALPARAMS RasDialParams;
RasDialParams.dwSize = sizeof(RASDIALPARAMS);
_tcscpy(RasDialParams.szEntryName,_T("宽带拨号器"));
_tcscpy(RasDialParams.szPhoneNumber, _T(""));
_tcscpy(RasDialParams.szCallbackNumber, _T(""));
_tcscpy(RasDialParams.szUserName,"xxxxxx s@adsl");
_tcscpy(RasDialParams.szPassword,"xxxxx");
tcscpy(RasDialParams.szDomain, _T(""));
int temp;
temp=RasDial(NULL,NULL,&RasDialParams,0xFFFFFFFF,hwnd,&hRasConn);//(不知哪里设置有误,总无法连接上。)
if(temp!=0){
MessageBox (NULL, TEXT ("connection error!!"), szAppName, MB_ICONERROR) ;
hRasConn = NULL;}
else
{
MessageBox (NULL, TEXT ("connection success!!"), szAppName, MB_ICONERROR) ;
}
return 0;
case ID_ABORT:
//
return 0;
case ID_EXIT:
DestroyWindow(hwnd);//
return 0;
}
case WM_RASDIALEVENT://为什么总不进入此事件处理呢?????????
rasstate= (RASCONNSTATE)wParam;
switch(rasstate)
{
case RASCS_OpenPort:
_tcscpy(text,"打开端口……");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_PortOpened:
_tcscpy(text,"端口已打开.");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_ConnectDevice:
_tcscpy(text,"连接设备");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_DeviceConnected:
_tcscpy(text,"设备已连接.");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_Authenticate:
_tcscpy(text,"验证用户及密码");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_Authenticated:
_tcscpy(text,"通过");
InvalidateRect(hwnd,NULL,1);
case RASCS_Connected:
_tcscpy(text,"已连接");
InvalidateRect(hwnd,NULL,1);
return 0;
case RASCS_Disconnected:
_tcscpy(text,"连接已断开");
InvalidateRect(hwnd,NULL,1);
m_hrasconn=NULL;
return 0;
} case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
GetClientRect (hwnd, &rect) ;
DrawText (hdc, text, -1, &rect,
DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ;}
解决方案 »
- 关于MFC处理文本的问题,请大家指教啊,急
- winsock重叠I/O的那些事?
- 紧急求救:CrystalReports9,preview 时,敲字母数字死进程问题
- 我要用USB接口驱动三个摄像头...
- 高手白捡的分儿哟!关于多维数组的图形化表示方法的。
- 急求开发图像实时显示软件问题!
- 如何判断两个字符串是否完全一样,用StrCmpN()需要包含什么头文件。
- 对"手机发短信"的编程是用什么来写的?
- VS2012能不能同时使用unicode和多字符集?就是工程里面使用的是unicode,在部分代码里面#ifdef XXX 之类的弄个多字符集?
- VC ADO SQL 2000 连接问题
- 对下面着个程序的出错, 不知如何解决
- toolbar上的按钮上放一透明ico图片, 透明部分是黑色, 为什么?
查看一下 RasError.h 就知道原因了
用getlasterror查找错误得返回值.