Solved

Function "RasGetEntryDialParams" can't retrieve phone number?

Posted on 2001-06-20
8
293 Views
Last Modified: 2010-04-06
Hello, I want to get the phone number by phonebook entry name. The function "RasGetEntryDialParams" can retrieve "szDomain" or "szUserName",but only can't retrieve "szPhoneNumber"(it always is blank), can you tall me what's the problem, Thanks

Function GetRasPhoneNumber(Entryname:string):String;
var DialParams : TRasDialParams;
    Fp         : LongBool;
    I          : Integer;
begin
  FillChar(DialParams, SizeOf(TRasDialParams), 0);
  with DialParams do
  begin
    dwSize:=Sizeof(TRasDialParams);
    StrPCopy(szEntryName, edUserName.text);
  end;

  I := RasGetEntryDialParams(nil, DialParams, Fp);

  if I <> 0 then
    Result := dialparams.szPhoneNumber
  else
    Result := '';
end;

0
Comment
Question by:yakelvin
8 Comments
 
LVL 13

Expert Comment

by:Epsylon
Comment Utility
What is the return value of the call to RasGetEntryDialParams?
Maybe it just doesn't work...
0
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
Hello

  May this article will help you

Creating your own dial-up application with RAS
http://www.kyler.com/pubs/ddj9855.html

Mohammed
0
 
LVL 17

Accepted Solution

by:
inthe earned 300 total points
Comment Utility
Hi,
ive done some reading and alot of people have problems with this getting the phone number (i suspect epsylon is right and your geting 632[incorrect size] as return code from RasGetEntryDialParams ,i tried messing with RasGetEntryProperties  to read szLocalPhoneNumber as thats supposed to work but for me also returned blank.

something i found that does work if you are not using them  already i would get the latest ras headers from :
ftp://delphi-jedi.org/api/RAS.zip

then can do:

uses RasHelperClasses;

procedure TForm1.Button1Click(Sender: TObject);
var
RasPhonebook: TRasPhonebook;
i : integer;
begin
 RasPhonebook := TRasPhonebook.Create;
 for i := 0 to RasPhonebook.Count -1 do begin
 if RasPhoneBook.Items[i].Name = 'My Entry Name' then
 ShowMessage(RasPhoneBook.Items[i].PhoneNumber);
 end;
end;

Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
Comment Utility
note
call RasPhonebook.Free afterwards.
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:yakelvin
Comment Utility
hello, inthe
function "RasGetEntryProperties" can return phone number(szLocalPhoneNumber). But at Win NT or Win 2000,if Ras dial has setup alternate phone number. szLocalPhoneNumber will return blank and dsAlternateOffset always is '0'.
do you know what's problem about this?
0
 
LVL 17

Expert Comment

by:inthe
Comment Utility
Hi,
yes but unfortunatly well not enough to fix it ..

i know if your just trying to use the api its a problem as there are various issues etc between the os's like size of buffer can be one (if you have a size problem you will get back 603),and the deviceinfo etc must be nil or 0 on win2k ,its all i kept reading about yesterday when looking for original answer.

you shold try the code i posted above works ok with alternative numbers i just tested by adding 3 more numbers to my dialup params ,so the author of that succedded ,but he is a ras specialist ;-)

Regards Barry
0
 

Author Comment

by:yakelvin
Comment Utility
Hi,
yes, I have try the code, it can get the szLocalPhoneNumber from phonebook, which has assigned alternative numbers.  

but another question, How can I get the alternative numbers? I can't find a function to do that. To be honest, get the alternative number is my main purpose.

thank you,
0
 

Author Comment

by:yakelvin
Comment Utility
Thank you for your help.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video discusses moving either the default database or any database to a new volume.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now