🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.ms-windows.programmer.win32
Article #2184

Re: RasEnumConnections always returns 0 entries

#2184
From: John Lockwood
Date: Sun, 18 Jan 1998 00:00
67 lines
2969 bytes
That's because your passing NumConnections as is to the function,
which expects a pointer to the number.  Try passing @NumConnections.
You see, if you want to spot pointer errors, ask a C++ programmer; we
have more experience making them.  ;-)


John

Vic Metcalfe <vic@brutus.tlug.org> wrote:

>I am trying to get a list of active RAS connections on an NT 4.0 RAS
>server.  I'm programming with Delphi 3.0, but if that's the problem I
>can switch to VC++ 4.0.  Every time I call RasEnumConnections, it
>returns 0 (no error) but does not list any active connections.  If I run
>the Remote Access Admin however, it correctly lists the connections.  In
>the code example below, the third showmessage shows that bufsize,
>numconnections and result are all zero.

>I've looked for help on Dejanews, but everyone seems to be talking about
>detecting and/or initiating RAS connections on the client side. 
>Shouldn't this be the same as detecting client side connections?  It
>seems to me that this should be a really easy task, and I must be
>missing something really simple.  I hope someone will be able to point
>out the error to me!

>Thanks in advance,
>  Vic.

>function TForm1.UpdateConnectList:longint;
>var
>  n:longint;
>  bufsize:longint;
>  RASConnect: Array[1..500] OF TRASConn;
>  NumConnections: DWord;
>  RASEvent:Word;
>begin
>  RASEvent := RegisterWindowMessage(RASDialEvent);
>  If RASEvent = 0 THEN
>     RASEvent := WM_RASDialEvent;
>  bufsize:=sizeof(RasConnect);
>  NumConnections:=500;
>  RasConnect[1].dwSize:=sizeof(TRasConn);
>  showmessage('Buffer size: '+inttostr(bufsize)+'  NumConnections: '+
>    inttostr(NumConnections));
>  result:=RasEnumConnections(@RASConnect, BufSize, NumConnections);
>  if result<>0 then
>  begin
>    RasGetErrorString(result,pchar(@rasconnect),sizeof(rasconnect));
>    showmessage('Error: '+pchar(@rasconnect));
>    exit;
>  end;
>  showmessage('Buffer size: '+inttostr(bufsize)+'  NumConnections: '+
>    inttostr(NumConnections)+'  Result: '+inttostr(Result));
>  ConnectList.items.clear;
>  for n:=1 to NumConnections do
>  begin
>    { ConnectList is a TListBox on Form1. }
>    ConnectList.Items.Add(RasConnect[n].szEntryName);
>  end;
>end;


------------------------

John Lockwood Consulting
http://www.jlockwood.com
Technical Details
Message-ID: <34c24450.0@calwebnnrp>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <34C2110A.166E918B@zymsys.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 113dfb,727dba52da29726b
X-Google-Attributes: gid113dfb,public
X-Google-Thread: fb362,727dba52da29726b
X-Google-Attributes: gidfb362,public
From: johnl@ihatespammy.calweb.com (John Lockwood)
Subject: Re: RasEnumConnections always returns 0 entries
Date: 1998/01/18
Message-ID: <34c24450.0@calwebnnrp>
X-Deja-AN: 317116506
X-NNTP-Posting-Host: news.calweb.com
References: <34C2110A.166E918B@zymsys.com>
Organization: "CalWeb Internet Services Inc.  Your affordable ISP."
Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.delphi.internet