Article View: comp.os.ms-windows.programmer.win32
Article #2160SOLUTION: RasDial() and ERROR_NO_CONNECTION (668) on Win2K
From: Alan Mintz
Date: Mon, 19 Nov 2001 07:11
Date: Mon, 19 Nov 2001 07:11
33 lines
2750 bytes
2750 bytes
Several people have posted that, on Win2K or WinXP, they are getting ERROR_NO_CONNECTION (668) from RasDial() immediately when attempting to dial an outbound connection. The same thing happened to me. ***Short answer: Initialize *lphRasConn to NULL before calling RasDial(). It then works as expected. Narrative: Not having found this answer in any of those threads, or anywhere else, I did the hack of shelling out and calling RasDial.exe, which worked OK, but lacks the robustness of the API. I finally decided to attack it again. The solution is, as usual, somewhat misleading documentation. Like others, I read the description of the lphRasConn parameter to mean that it stuffs the referenced HRASCONN variable with the resulting handle if the connection succeeds. So, like others, I declared an HRASCONN variable, and passed its address to RasDial() _without_initializing_it_first. After all, why should the present value matter - it's only purpose is to receive the result? RasDial() shouldn't care what's there. If you look carefully at the man page, however, it says that this is an [in] parameter, and that you have to initialize the variable to which it points to NULL before calling RasDial(). This, of course, doesn't correlate with the rest of the description, and I have no idea why RasDial() cares what's there. Either the man page should state that it's an [in/out] parameter and what it does with the existing value, or correct the man page to call it an [out] parameter and fix RasDial() to ignore the existing value.
Technical Details
Message-ID:
<ca490044.0111182311.1fa1ad8e@posting.google.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1091e5,12b223987de00319,start X-Google-Attributes: gid1091e5,public X-Google-Thread: 113dfb,12b223987de00319,start X-Google-Attributes: gid113dfb,public X-Google-Thread: 104d65,12b223987de00319,start X-Google-Attributes: gid104d65,public X-Google-Thread: f5ca7,12b223987de00319,start X-Google-Attributes: gidf5ca7,public X-Google-ArrivalTime: 2001-11-18 23:11:07 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!postnews1.google.com!not-for-mail From: Alan_Mintz@yahoo.com (Alan Mintz) Newsgroups: comp.os.ms-windows.programmer.win32,microsoft.public.vc.mfc,borland.public.cppbuilder.winapi,borland.public.delphi.winapi Subject: SOLUTION: RasDial() and ERROR_NO_CONNECTION (668) on Win2K Date: 18 Nov 2001 23:11:07 -0800 Organization: http://groups.google.com/ Lines: 33 Message-ID: <ca490044.0111182311.1fa1ad8e@posting.google.com> NNTP-Posting-Host: 209.209.83.37 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1006153867 15362 127.0.0.1 (19 Nov 2001 07:11:07 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 19 Nov 2001 07:11:07 GMT