该用户从未签到
|
6楼
楼主 |
发表于 2003-10-25 00:48:00
|
只看该作者
谢谢周老师,不过这个问题我自己查了将近一个月的MSDN,终于搞定了。
) R% @, s) x; B) N有一个RasDial拨号函数的定义如下:: @* m* k2 z* s% I
DWORD RasDial(
- K" N, n% R) L3 y0 x; D" U# B2 NLPRASDIALEXTENSIONS dialExtensions, ; \8 H# Q% s2 n
LPTSTR phoneBookPath ,
1 M" I2 ]! a0 FLPRASDIALPARAMS rasDialParam ,
# K1 G) S3 s sDWORD NotifierType,
9 f+ n' x% M$ z# r! j7 kLPVOID notifier,
8 P9 S: E4 [; I x# JLPHRASCONN pRasConn );, Q& w3 Q% }' Z5 U5 w1 P+ n
; A8 b5 z, N& j, k# I; b2 b6 l
我的MSDN的解说如下:
; h) ?5 L% z* O+ r2 y$ yParameters7 k, l! L, a0 ^. v% k" \! C# h8 x+ ?& O
dialExtensions , X' Y- x( J: o/ Z
This parameter is ignored and should be set to NULL. On Windows CE, RasDial always uses the default behaviors for the RASDIALEXTENSIONS options.
$ g* _( N( s, XphoneBookPath ) ^7 J' G w i0 J
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. - y5 h0 c! I' ~8 n
rasDialParam 0 U @9 W7 C) v. E; c0 _) Y* a2 ]
Pointer to a RASDIALPARAMS structure that specifies calling parameters for the RAS connection.
5 m5 L' E! F1 ~- B1 W$ hThe caller must set the RASDIALPARAMS structure’s dwSize member to the sizeof(RASDIALPARAMS) to identify the version of the structure being passed.
) `% z! O$ D. \! A0 }: i/ P. d3 V; F T6 V
NotifierType
4 W, ]0 O3 V# q: {0 t7 W; FSpecifies the nature of the notifier parameter. If notifier is NULL, NotifierType is ignored. If notifier is not NULL, set NotifierType to the following value:
" A1 q' L- Z( V2 n7 W% \Value Description
2 ~/ p! R9 M' U# c( _* Q1 u1 q0xFFFFFFFF
0 f1 |$ @) F+ B+ q0 `3 E3 @9 h1 _) O0xFFFFFFFF 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 D U9 A$ z$ i, q The progress notification message uses the WM_RASDIALEVENT message code.
2 E$ t+ t- `" n' O6 k o0 ?3 e' l6 L2 k( U* U" w1 N, r0 B5 ^
1 f8 _2 ], v' w" T8 v+ |! i
7 k1 A* S7 w9 x6 v. m. _7 ?& f0 G
, M3 w; A9 L Z* y& O8 {4 q. Hnotifier
# z5 Y$ u# N8 y7 ]( F8 \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. % n6 u$ i( L2 O' i5 S
If notifier is NULL, the RasDial call operates synchronously: RasDial does not return until the connection attempt has completed successfully or failed.
! k- a! l+ y9 J) x* Y: S7 ~$ U. t# h( N e8 P# Y% v/ |' I9 R
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:
! G/ p9 |& O f$ T) \
1 k3 _5 B' ~' {- g9 F; nThe connection is established. In other words, the RAS connection state is RASCS_Connected. 0 A, Q* f4 T. P5 h+ M+ I% Q
The connection fails. In other words, dwError is nonzero.
4 C2 S9 {" N+ eRasHangUp is called on the connection. $ U* v. z6 X( ?5 v1 c k0 a
The callback notifications are made in the context of a thread captured during the initial call to RasDial. ' Z G, q0 i. O4 P
8 t2 e/ [& [* h {$ S
pRasConn " X4 I7 x5 y/ Q% v8 c
Pointer 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. 5 N0 |5 ~) U) V& h, }) v
Return Values
) u* I8 ^ K* cZero 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. ! E4 Q' n7 e# A1 R: m. ~6 m4 D, B
- ~2 ?8 N/ [2 c+ h/ u# R% k' Y( p
Include Raserror.h for definitions of the RAS error codes., h1 L. ?* D" |9 o3 `* ?, v
- d t. `! D( R% @1 [) f* Y
Remarks; k/ x! b' L. U; o' ?0 q% ^" g; H
The szCallBackNumber and szPhoneNumber members of the structure pointed to by rasDialParam are not used and should be set to NULL.
2 x# b9 q$ h# v) s3 Z0 }$ ^$ e) M4 q: d. Z, ]: }6 X0 F& ?
RasDial 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.( M. e" a! V+ C* m2 m
6 E% k/ n$ W, W% z4 d
Errors 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 c. w R! c. I- W
, w) J$ c/ y J! {An 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.
' ]* G" Z+ K' p, g- M
1 d/ [ K7 V' n8 H2 |2 {* K% xAn application can safely call RasHangUp from a RasDial notifier handler. If this is done, however, the hangup does not occur until the routine returns.
7 K* H8 y; M, S+ c
1 P7 W, k0 M6 m7 F/ d- HThe 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.
3 @0 O* F, X7 f1 v; i. O! H( h @) _
3 }" M! ?% K0 F' F( \: y1 ?! y5 ]看了好久才算是略略通了一点,要实现我原先预期的效果,首先要用RasDial函数进行拨号1 ?% T, H8 e: e9 M
DWORD dwRet = RasDial(NULL, NULL, &RasDialParams, 0L, (RASDIALFUNC)RasDialFunc, &hRasConn);
7 }8 N* L7 v* r+ q- c; a第五个参数是个回调函数,一般都定义如下:! N$ [; K3 S! ?4 ?! e' a
void WINAPI CDialerDlg::RasDialFunc(UINT unMsg, RASCONNSTATE rasconnstate, DWORD dwError)
) Y$ p3 j {6 t$ z- i! v6 a{
" P. z/ a& J0 e CDialerDlg * RasDlg = (CDialerDlg*)AfxGetApp()->m_pMainWnd;
+ F# @8 a k9 ~" a& z1 c: q+ F: M1 D
) V: b9 _! R9 t6 {1 e1 M l' ? RasDlg->ostMessage(WM_RASDIALEVENT,(WPARAM)rasconnstate,(LPARAM)dwError);
5 d1 ~# b; o" D' ~}( o, ~7 ?" Q7 ~* N" w1 @9 \; d
这个回调函数将会把拨号的状态POST到各个窗口句柄。6 M2 z3 j$ ]6 s, u+ z4 F
$ @ i& v) M- W5 H( j+ ~- ` |
|