• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 399
  • Last Modified:

statistics of a ras connection ?

hi,

i would like to get connection statistics from a ras (remote access service) connection.you know "bytes sent" , bytes received" etc etc.On windows 95/98 this information is saved in the registry under "HKEY_DYN_DATA\PerfStats\StatData" but i have windows 2000 (pro)  after a search  with google i came to the conclusion i can use a function (api)

"RasGetConnectionStatistics()" this function needs the handle to the connection you want the stats from

anybody know how to do this ?



thanks ...
0
DelphiFan
Asked:
DelphiFan
  • 11
  • 6
1 Solution
 
DaFoxCommented:
Hi,

take a look at the IPHelperAPI conversion by the jedis: ftp://delphi-jedi.org/api/IPHlpAPI.zip
This zip files also contains a demo.

Markus
0
 
DelphiFanAuthor Commented:
hi,

that's not really what i want ... it includes a netstate.exe clone i know what i need i only can't get it working.i use ftp://delphi-jedi.org/api/ras.zip

there is a sourcefile that has RasGetConnectionStatistics()

i just need to know how i get this working  in Delphi

function information

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/rras/rras/rasgetconnectionstatistics.asp

thanks for your help through Markus it is appriciated
0
 
DaFoxCommented:
What exactly is your problem? Could you show some source?
RasGetConnectionStatistics() is defined in ras.pas.
You have to pass a connection and a statistics structure (TRasStats). To get the connection handle use RasConnectionsEnum().

Markus
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
DelphiFanAuthor Commented:
hi Markus,

yes you're right but that is exactely te problem.if you open Ras.pas you will see

function RasGetConnectionStatistics(hRasConn: THRasConn;
  var lpStatistics: TRasStats): DWORD; stdcall;

when i make a call to this function Delphi tells me

undeclarerd identifier "RasGetConnectionStatistics"

Ras.pas is in my uses clause also delphi complains there is something wrong with TRasStats (same error undeclarerd identifier) i would like to display the stats in a label so i write

Label4.Caption :=RasGetConnectionStatistics(ConnectionListView.Selected);

same happens delphi does not seem to recognize the ras functions any idea ?
0
 
DaFoxCommented:
Hi.

The functions you're looking for are support on Windows 2000 and above. Therefore the jedis added compiler directives (WINVER_0x500_OR_GREATER = Win2k and above).
What Delphi version do you have? I guess Delphi 5, right?
Because I had the same problem since Delphi 5 is older than Win2k...

In ras.pas, add this line

{$DEFINE WINVER_0x500_OR_GREATER}

and try again. ;-)

Markus
0
 
DelphiFanAuthor Commented:
hi Markus,

no i have Delphi 6 enterprise

and i on windows 2000 oooh i was asking myself what those lines ment i knew it where compil:er directives but ...

ok will try it .....
0
 
DelphiFanAuthor Commented:
hi,

i would like to add all availible ras connections to a TComboBox so i write

procedure TSTatisticsForm.FormCreate(Sender:TObject);
var
 RasConn  : TRasConn;
 bsize    : Integer;
 ConnectionCount:Integer;
begin
RasEnumConnections(@RasConn,bSize,ConnectionCount);
ComboBox1.Items.Add(IntoStr(ConnectionCount));
end;
didn't test it yet
0
 
DelphiFanAuthor Commented:
hi,

i use this to get the list of availible connections ......

procedure TForm1.FormCreate(Sender: TObject);
var
  RasEntryName: array[1..20] of TRasEntryName;
  i, x, BufSize, Entries: DWord;
begin
ComBoBox1.Clear;
  RasEntryName[1].dwSize := SizeOf(RasEntryName[1]);
  BufSize := SizeOf(RasEntryName);
  x := RasEnumEntries(nil, nil,
     @RasEntryName, BufSize, Entries);
  //if (x = 0) or (x = ERROR_BUFFER_TOO_SMALL) then
    for i := 1 to Entries do
       if ( i < 21) and (RasEntryName[i]
          .szEntryName[0] <> #0) then
         ComboBox1.Items.Add(StrPas
          (RasEntryName[i].szEntryName));
end;


that works

now i gotta try and get RasGetConnectionStatisTics() working


ciao !
0
 
DelphiFanAuthor Commented:
Delphi keeps on complaining aout this function

here is my own call

function RasGetConnectionStatistics(hRasConn: THRasConn;
  var lpStatistics: TRasStats): DWORD; stdcall;external 'rasapi32.dll' name 'RasGetConnectionStatistics';

or i just use Ras.pas

i mean the file is in my uses clause and delphi still says

"undeclarerd identifier RasGetConnectionStatistics"
"undeclarerd identifier TRasStats"

they are both defined .....

TRasStats is defined in Ras.pas (on line 1696)

any idea ? verry strange if you ask me

0
 
DelphiFanAuthor Commented:
anybody awake ??????
0
 
DaFoxCommented:
Sorry, I was ill the last few days

Are you sure that you added {$DEFINE WINVER_0x500_OR_GREATER} to ras.pas?

unit Ras;

{$DEFINE WINVER_0x500_OR_GREATER}  // <--

...

I just tested it again, it definitly works on my system (Windows 2000, Delphi 5)

Markus
0
 
DelphiFanAuthor Commented:
hi,

oooh sorry to hear that Markus,

well that compiler directive is already there(developers did that)daim it Delphi hates me ??????

my ideas are up.......
0
 
DaFoxCommented:
> well that compiler directive is already there(developers did that)

Er, really? All I can see in the jedi ras.pas are the $ifdefs, but no $define. If that would be in there all the $ifdefs would be useless, because then Delphi wouldn't check what OS you're using and take the $define value instead. BTW: What do you mean by developers did that? (the jedis?) Did I misunderstood something?

Markus
0
 
DelphiFanAuthor Commented:
hi,

problem solved !!!!!

add

{$DEFINE WINVER_0x500_OR_GREATER}

at the top of Ras.pas

0
 
DelphiFanAuthor Commented:
Markus,

i give you the poinsts you deserve ;)
0
 
DelphiFanAuthor Commented:

thank you verry much ;)
0
 
DaFoxCommented:
Now I got it. You have to change ras.inc on your own. That's how the jedis wanted us to do it ;-)

Markus
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 11
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now