|
6楼
楼主 |
发表于 2003-10-25 00:48:00
|
只看该作者
谢谢周老师,不过这个问题我自己查了将近一个月的MSDN,终于搞定了。
# g9 K) h) h2 w+ s( X有一个RasDial拨号函数的定义如下:9 S/ M) L& }% v
DWORD RasDial(
% S) S9 v3 G- ~LPRASDIALEXTENSIONS dialExtensions, 6 ?* }* H& Y W/ W: `! Q% p% o% z5 A
LPTSTR phoneBookPath , # V: j& l% }# f! I3 A9 D
LPRASDIALPARAMS rasDialParam , 9 p% W+ j6 V3 G. s, ?/ t& A
DWORD NotifierType,
& Y2 l8 X3 Y6 m( l+ L. }" eLPVOID notifier,
: ^1 v* M: I$ A4 [5 G, |LPHRASCONN pRasConn );
: t, O g e' M' [4 D9 ^6 ]: _
我的MSDN的解说如下:1 B# \0 V; _/ C
Parameters
, C$ N4 s& d# v) ~) U' tdialExtensions ; G7 _8 @, p" @5 P. d
This parameter is ignored and should be set to NULL. On Windows CE, RasDial always uses the default behaviors for the RASDIALEXTENSIONS options.
% S. U. x. d8 _; v/ bphoneBookPath / Y! d& e) S% C# M8 `+ @
This parameter is ignored and should be set to NULL. Dial-up networking stores phone-book entries in the registry rather than in a phone-book file. 3 a" a: O: H# h* @% R
rasDialParam
& o& n& W9 V* }* _$ Q; F' w- oPointer to a RASDIALPARAMS structure that specifies calling parameters for the RAS connection. / A0 C8 H( j/ d$ F1 m) F
The caller must set the RASDIALPARAMS structure’s dwSize member to the sizeof(RASDIALPARAMS) to identify the version of the structure being passed. % [( w4 i7 Y! R% f. \4 [+ a$ }
, K% Y1 L! X7 o9 wNotifierType
1 b8 a' l4 Z$ N( c9 e QSpecifies the nature of the notifier parameter. If notifier is NULL, NotifierType is ignored. If notifier is not NULL, set NotifierType to the following value: # v9 r) y$ @4 Z) o: X- S5 K
Value Description 9 h5 c. u h$ l' H$ K. M: Z" y
0xFFFFFFFF7 U) J& V' K* Z+ T
0xFFFFFFFF The notifier parameter is a handle to a window to receive progress notification messages. In a progress notification message, wParam indicates the connection state (rasconnstate) which the RAS connection is about to enter, while lParam indicates whether or not an error occurred. 7 S1 L4 J4 C) ^$ b( S* M
The progress notification message uses the WM_RASDIALEVENT message code. 7 V0 f1 [- n2 {8 u
2 {* ]; @9 y+ L- v* V4 o: z
! r. Q3 E- p2 ?2 y4 h
/ Q% {# L4 `9 n7 [" O& K
3 M8 l, U9 A: }" m6 Nnotifier . j4 \; k/ l- l4 ^' t. q3 f
Pointer to a window handle to receive RasDial event notifications. If this parameter is not NULL, RasDial sends the window a message for each RasDial event. Additionally, the RasDial call operates asynchronously: RasDial returns immediately, before the connection is established, and uses the window to communicate its progress.
' M0 [6 e( N: |$ DIf notifier is NULL, the RasDial call operates synchronously: RasDial does not return until the connection attempt has completed successfully or failed. 8 [% b4 L0 C0 U! W) t; _
' H* L. d5 O* l4 G2 U3 H8 Z
If notifier is not NULL, notifications to the window can occur at any time after the initial call to RasDial. Notifications end when one of the following events occurs:
0 H- H& g: @6 a# R" y- d' ~' S2 \2 m$ V$ \0 x' k v' l! @- [
The connection is established. In other words, the RAS connection state is RASCS_Connected.
8 T5 ^2 V5 X- N2 S( GThe connection fails. In other words, dwError is nonzero. U0 G5 {* I: n
RasHangUp is called on the connection. ; o& ^" l- S4 [% I* C0 Z2 C5 V
The callback notifications are made in the context of a thread captured during the initial call to RasDial.
; @+ M/ ]5 N; K/ N" ] k
7 x) D) P) m, y2 hpRasConn
" _4 W8 [! o1 @ b' }2 h* V. ZPointer to a variable of type HRASCONN. You must set the HRASCONN variable to NULL before calling RasDial. If RasDial succeeds, it stores a handle to the RAS connection into pRasConn.
2 L2 \" ^" B/ D# |" z2 `# B) G; rReturn Values* Y, w" n# H2 P) r8 r- d
Zero indicates success. In addition, the function stores a handle to the RAS connection into the variable pointed to by pRasConn. A nonzero error value, either from the set listed in the RAS header file or ERROR_NOT_ENOUGH_MEMORY, indicates failure.
1 W& i+ M \4 J7 S+ p5 h5 |( M7 R Y ^3 _
Include Raserror.h for definitions of the RAS error codes.
+ q8 w0 o" c& j; T! |3 Y9 L8 F% R5 h- O$ j( D
Remarks
. [9 `4 d9 y2 vThe szCallBackNumber and szPhoneNumber members of the structure pointed to by rasDialParam are not used and should be set to NULL.( m% ?: u; m: B5 C4 \
$ G! Q7 U9 _: s2 C6 Y* p- YRasDial will not automatically display the logon dialog box. This is currently done through the Remote Networking application. Applications are responsible for getting the information from the user.7 Y" W* d! U& {/ _
7 i2 W0 S9 j4 y, R( Z9 V' LErrors that occur after the immediate return can be detected by RasGetConnectStatus. Data is available until an application calls RasHangUp to hang up the connection.
7 ?9 w, Q9 Z" y9 Y+ o; n0 C
8 R" R" f* y. V9 `% {% dAn application must eventually call RasHangUp whenever a non-NULL connection handle is stored into pRasConn. This applies even if RasDial returns a nonzero (error) value. 2 G- N' t! h! M
' o& y5 d' Z1 d% n3 D
An application can safely call RasHangUp from a RasDial notifier handler. If this is done, however, the hangup does not occur until the routine returns.
! Z$ G6 Y: T4 B! W* l7 o2 Z7 K* Q9 X3 I" y* B2 Y2 T& o
The window handle-based notification only works if the underlying configuration supports the PostMessage function. PostMessage is exposed through the msgque component, which is a part of the GWES module. Event notification through a window handle can only work if GWES is part of the underlying configuration. 0 D- ?, W6 I! d5 N1 k# a) N
2 W5 Q) f. \0 D' ]+ A+ |) ?
看了好久才算是略略通了一点,要实现我原先预期的效果,首先要用RasDial函数进行拨号) O4 T7 R+ |" Y) M+ K
DWORD dwRet = RasDial(NULL, NULL, &RasDialParams, 0L, (RASDIALFUNC)RasDialFunc, &hRasConn);( A: Q3 d9 F) D8 r; r
第五个参数是个回调函数,一般都定义如下:' I2 P# \& r4 v5 p/ E. U5 {! r
void WINAPI CDialerDlg::RasDialFunc(UINT unMsg, RASCONNSTATE rasconnstate, DWORD dwError)% \: n4 ]9 x5 x; {% B8 W! u
{
. J x7 P( J; Y* G% h9 n3 b; \( m CDialerDlg * RasDlg = (CDialerDlg*)AfxGetApp()->m_pMainWnd;. _$ ]( E- J+ K+ }( ~
+ ~7 l- R }$ o7 g) N- D RasDlg->ostMessage(WM_RASDIALEVENT,(WPARAM)rasconnstate,(LPARAM)dwError);
' ?+ M! U( e. R/ g7 B! m; a+ i}
1 H5 e) R0 {- J+ w4 L# N这个回调函数将会把拨号的状态POST到各个窗口句柄。9 i; |' \2 p, G A% U0 Z7 U' }8 X5 h
- d5 {* X8 \5 @9 T! u. h, S V |
|