?
Solved

statistics of a ras connection ?

Posted on 2003-02-28
17
Medium Priority
?
393 Views
Last Modified: 2010-04-04
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
Comment
Question by:DelphiFan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 6
17 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 8041529
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
 

Author Comment

by:DelphiFan
ID: 8042225
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
 
LVL 6

Expert Comment

by:DaFox
ID: 8045873
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
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!

 

Author Comment

by:DelphiFan
ID: 8047314
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
 
LVL 6

Accepted Solution

by:
DaFox earned 400 total points
ID: 8047550
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
 

Author Comment

by:DelphiFan
ID: 8047578
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
 

Author Comment

by:DelphiFan
ID: 8047775
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
 

Author Comment

by:DelphiFan
ID: 8049278
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
 

Author Comment

by:DelphiFan
ID: 8049451
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
 

Author Comment

by:DelphiFan
ID: 8063817
anybody awake ??????
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8064377
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
 

Author Comment

by:DelphiFan
ID: 8066232
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
 
LVL 6

Expert Comment

by:DaFox
ID: 8066772
> 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
 

Author Comment

by:DelphiFan
ID: 8068158
hi,

problem solved !!!!!

add

{$DEFINE WINVER_0x500_OR_GREATER}

at the top of Ras.pas

0
 

Author Comment

by:DelphiFan
ID: 8068167
Markus,

i give you the poinsts you deserve ;)
0
 

Author Comment

by:DelphiFan
ID: 8068171

thank you verry much ;)
0
 
LVL 6

Expert Comment

by:DaFox
ID: 8070756
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question