Solved

how to add RAS....

Posted on 1998-04-27
69
1,393 Views
Last Modified: 2012-06-27
hi folks,
i would like to add RAS in dailup networking, but i dont want the prompt screen for name phone number etc, i want to as the user name, password etc, and the programm will add the connection with phone number, IP adress, etc,

thanks
0
Comment
Question by:popy
  • 35
  • 20
  • 6
  • +3
69 Comments
 

Author Comment

by:popy
ID: 1337524
Edited text of question
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1337525
Would it be ok if the boxes came up and it the computer just started entering things in (screen would flicker)...there might be a way to do it behind the seans but I can't think of how...

0
 
LVL 3

Expert Comment

by:KE
ID: 1337526
I'm not sure that this works for 95, but try it anyway.
Launch "RASDIAL <CONNECTION> <UserID> <Password>"
by WinExec or similar.


0
 

Author Comment

by:popy
ID: 1337527
to KE: no it didnt work
to Greedy : well, exactly what i want it's that: i have form where i asking username and password..then when the guys click OK, it creat the connection in dailup network, with DNS server phone number etc
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1337528
I think the whole thing is held in the registry...unfortunatly at work I can't play with that stuff...I have this fear of screwing up my development machines...Make a new conection buy using the windows setup method then scan the registry for the name you created.  I would bet that it does something like put a key in \HKEY_CURRENT_USER\RemoteAccess\<YourAccount> and then has a bunch of strings like UserName and Passwords and stuff...damn I just tried it but I have to have a modem installed to make a dialupconection entry....well try that and see if it's just a registry thing...then export the key and change it allitle and then merge it back and see if the changes have been made.

0
 

Author Comment

by:popy
ID: 1337529
greedy : ok i tryed it with the registry, i exported it, etc, i worked great, i made a test on other puter and it worked fine, BUT it keep the the modem setting (mean the kind of modem) now i need to figure out how to put the modem setting of the user ;-(
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1337530
hummm...that's cool...this won't be too bad then...is this like for an ISP or something?...is the password just plain text in the registry???...do you want to push them off to install new modem if they don't have one installed and them like give them a drop down list on your form of all the installed modems that they have so they can associated a modem with this dial up conection?...Thier must be a way to dirrectly call setup modem because if you go to windows help and then go to modem/set up...it gives one of them little jump buttons in the help box that when clicked will bring up the install new modem dialogs.  Anyone have a help decompiler...hummm it makes a call to RUNDLL32.EXE...anyone have any dev specs on that.  I'll poke it with my hex editors and see if I can't see something.
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1337531
I guess all rundll32.exe does is "run a dll as an app"  so now to find the dll that it is calling...I'll left you do that. I must partake of the lunch soon as I will need my energy to sit here for another 6 hours.
0
 

Author Comment

by:popy
ID: 1337532
greedy : yes it's for ISP (i'm ISP in canada ;-) )  so usually modem are already in the computer, for the password it's encoded in HEX same thing for modem type it use, it's why the other puter keep the modem setting and when the guy trying to go to propriety or tryed to connect of course the window tell the modem bla bla bla ;-), i will check out for the help and let you know
0
 
LVL 2

Expert Comment

by:mvz121697
ID: 1337533
I recently implemented exactly what you are looking for.
All you need is in 'd_ras.zip'
It's an header file for the Ras-Api, with full source and
examples. Its on the Delphi Super Pages.

Also found it at:
http://www.kobira.co.jp/sakura/d_net_RasAPI.htm

Greetings,
MvZ
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1337534
I think it's in rnasetup.dll...but I've never used rundll32 to start anything so I don't know the syntax...oh well I must go and get some Kraft dinner and listen to Celin Dion and say aboot like 50 times...Do you know who Terance and Philip are -- Not without my Anus...are you in suckcatchewon...I here they got some damn find nudey bars up there.

0
 

Author Comment

by:popy
ID: 1337535
mvz : humm....it open the wizard too ;-(, maybe i didnt check right, if you got something i didnt see tell it to me, but all i can see it's the wizard, and i dont want to see this wizard, i want all automated

thanks
0
 

Author Comment

by:popy
ID: 1337536
mvz : ok i found rassetentryproperties: but i always gettin error 603 (dont know what it mean) can you provide me an exaple how to use this function please

thanks
0
 

Author Comment

by:popy
ID: 1337537
Adjusted points to 500
0
 
LVL 1

Expert Comment

by:lowlevel
ID: 1337538
use the following code-snippets in combo with d_Ras.zip. this is source that does a complete asynchronous log-in. Modify the rasdial command a bit (check MSDN docs) and you can make it synchronous (less programming fuss).
I'm currently making an activeX version of the RAS-api, based upon d_ras.zip, that can handle 95&NT, +SUR enhancements... the RAS-api sucks...

function inArrayLongInt (var pin : longInt; const haystack: array of longInt) : boolean;
var i : longint;
begin
  result:=false;
  for i:=low(haystack) to high(haystack) do
    if haystack[i]=pin then result:=true;
end;


procedure rasGetStatusString(rasScreenState: TRasConnState; dwError: dWord; var strError : string; var strScreenState : string);
var
  c: Array[0..100] of Char;
  s: string;
begin
  strError:=''; strScreenState:='';
  if dwError<>0 then begin
    RasGetErrorString(dwError, c, 100);
    strError:=c;
  end;

  s:='';
  case rasScreenState of
    RASCS_OpenPort              : s := 'Opening port.';
    RASCS_PortOpened            : s := 'Port opened.';
    RASCS_ConnectDevice         : s := 'Connecting device.';
    RASCS_DeviceConnected       : s := 'Device connected.';
    RASCS_AllDevicesConnected   : s := 'All devices connected.';
    RASCS_Authenticate          : s := 'Start authenticating.';
    RASCS_AuthNotify            : s := 'Authentication: notify.';
    RASCS_AuthRetry             : s := 'Authentication: retry.';
    RASCS_AuthCallback          : s := 'Authentication: callback.';
    RASCS_AuthChangePassword    : s := 'Authentication: change password.';
    RASCS_AuthProject           : s := 'Authentication: projecting.';
    RASCS_AuthLinkSpeed         : s := 'Authentication: link speed.';
    RASCS_AuthAck               : s := 'Authentication: acknowledge.';
    RASCS_ReAuthenticate        : s := 'Authentication: reauthenticate.';
    RASCS_Authenticated         : s := 'Authenticated.';
    RASCS_PrepareForCallback    : s := 'Preparing for callback.';
    RASCS_WaitForModemReset     : s := 'Waiting for modem reset.';
    RASCS_WaitForCallback       : s := 'Waiting for callback.';
    RASCS_Projected             : s := 'Projected.';
    RASCS_StartAuthentication   : s := 'Start authentication.';
    RASCS_CallbackComplete      : s := 'Callback complete.';
    RASCS_LogonNetwork          : s := 'Logging on network.';

    RASCS_Interactive           : s := 'Interactive.';
    RASCS_RetryAuthentication   : s := 'Retry Authentication.';
    RASCS_CallbackSetByCaller   : s := 'Callback set by caller.';
    RASCS_PasswordExpired       : s := 'Password expired.';

    RASCS_Connected             : s := 'Connected!';
    RASCS_Disconnected          : s := 'Disconnected.';
  else
    s:='unknown ScreenState to the internetkit';
  end;
  strScreenState:=s;
end;

procedure rasNotifier (msg: Integer; state: TRasConnState; dwError: Longint); stdcall;
var
  strError,
  strState      : string;
  completed     : boolean;
  mr            : word;
  //isp, pop      : string;
const
  eldcGoOn : array [0..0] of longint = ( //eldc = error list dial command
               ERROR_LINE_BUSY
  );
  eldcStop : array [0..2] of longint = (
               ERROR_PORT_OR_DEVICE,
               ERROR_PORT_NOT_AVAILABLE,
               { port not avail will, amongst other reasons, occur if a rasDial
                 sequence was "lost".
                 This can be achieved quite easilly by manually killing the dialer
                 process (ctrl-f2) during a dial-session.
                 Hopefully i can fix it some day that in this case, i'd manually
                 free the port through api. Dunno if that can even be done,
                 though.}
               ERROR_NO_DIALTONE
  );
begin
//these routines are outside the object, in the implementation section. gPDControl merely points to the object that implements the next procedure.
  gPDControl.fWhatNext:=wtdIDunno;
  if gPDControl.fCurrConn.hRAS=INVALID_HANDLE_VALUE then exit;

  rasGetStatusString ( state, dwError, strError, strState);

  with gPDControl do begin
    lblError.visible:=dwError<>0;
    lblTError.visible:=dwError<>0;
    lblStatus.caption:=strState;
    if dwError<>0
      then begin
      //aargh.. failed rasdial
        lblStatus.caption:=resData[rid_deConnectFailed];
        lblError.caption:='['+inttostr (dwError)+'] '+strError;

      //report this miserable failure ;-)
        with fCurrConn do
          fCallLog.log (pop, isp, cevConnect, dwError);
      //find out if it has any use to try another pop.
      //for instance, if a user has not connected his external modem to the commport,
      //an 692 error (ERROR_PORT_OR_DEVICE).. It won't do any good to continue a dial-attempt then.
        if inArrayLongInt (dwError,eldcGoOn)
          then fWhatNext:=wtdContinueDialing;
        if inArrayLongInt (dwError,eldcStop)
          then fWhatNext:=wtdBetterStop;
      end else begin
        lblStatus.font.color:=clNoError;
      end;
  end;

end;


procedure TxPOPDialer.doDial;
type
  pEntry = ^tEntry;
  tEntry = record
    ras : tRasEntry;
    additionalData : byte;
  end;
var
  size : record
    rasEntry, devInfo : longint;
  end;
  entry         : pEntry;
  pEntryName    : pChar;
  popData       : tPOPData;
  apiReturn     : longint;
  rasDialParams : tRasDialParams;
  isp,pop       : string;
  rasErrMess    : pChar;
  devType       : tKitSupportedDevices;
  rasLogonScriptFile : string;
begin
//first set all the properties for the RAS-entry correctly
  getmem (pEntryName, max_path);
  entry:=nil;
  try
    strPCopy (pEntryName,'entrynamehere');

  //get buffer sizes
    apiReturn:=rasGetEntryProperties (
      nil, pEntryName, nil, size.rasEntry,
      nil, size.devInfo);
    if (apiReturn<>error_cannot_find_phonebook_entry) and
       (apiReturn<>success) and (apiReturn<>ERROR_BUFFER_TOO_SMALL) then {cry, raise exception}

    getmem (entry,size.rasentry);
    fillChar (entry.ras, size.rasEntry, 0);
    entry.ras.dwSize:=sizeOf (tRasEntry);

    apiReturn:=rasGetEntryProperties (nil, pEntryName, entry,
                                      size.rasEntry, nil,
                                      size.devInfo);

    if not ((apiReturn=success) or
            (apiReturn=ERROR_CANNOT_FIND_PHONEBOOK_ENTRY) or
            (apiReturn=ERROR_CANNOT_OPEN_PHONEBOOK)) then reportNVE_RAS (
            exLoc, 'get entry properties','rasGetEntryProperties', apiReturn);

//check out MSDN docs on this.
    entry.ras.dwfOptions:=
       raseo_ipHeaderCompression or
       raseo_remoteDefaultGateway or
       //raseo_specificNameServers or
       //(raseo_terminalBeforeDial or raseo_terminalAfterDial) or
       raseo_swcompression;
    //entry.ras.ipAddrDNS:=tRasIPAddr(a:194, b:109, c:6, d:6); //*TODO*: implement raseo_specificNameServers
    entry.ras.dwfNetProtocols:=rasnp_ip;
    entry.ras.dwFramingProtocol:=rasfp_ppp;
    with fXSReg, fXSReg.isps.byName[isp] do
      rasLogonScriptFile:=rootPath+'ispData\'+isp+'\default.scp';
    if fileExists (rasLogonScriptFile) then
      strPCopy (entry.ras.szScript,rasLogonScriptFile);

//fill in crap.
    strPCopy (entry.ras.szAreaCode,popData.areaCode);
    POPData.phone:=fXSReg.profile.dialPrefix+POPData.phone;
    strPCopy (entry.ras.szLocalPhoneNumber,POPData.phone);
    strPCopy (entry.ras.szdeviceType,rasDTNames[devType]);
    strPCopy (entry.ras.szDeviceName,fDeviceName);
    entry.ras.dwCountryCode:=strtoint(popData.countryCode);

//set properties for entry.
    apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, size.rasEntry, nil, size.devInfo);
    if apiReturn<>success then reportNVE_RAS (
      exLoc, 'set entry properties',
      'rasSetEntryProperties', apiReturn);

  //set login/passwd
    fillchar (rasDialParams,sizeof(rasDialParams),0);
    rasDialParams.dwSize:=sizeOF (tRasDialParams);
    strCopy (rasDialParams.szEntryName,pEntryName);

    with fxsReg.profile.isps.byname[isp] do begin
      strpcopy (rasDialParams.szUserName,username);
      strpcopy (rasDialParams.szPassword,password);
    end;

    apiReturn:=rasDial (nil, nil, rasDialParams, 0, @rasNotifier, fCurrConn.hRAS);
    if apiReturn<>success then begin
      getmem (rasErrMess,max_path);
      try
        rasGetErrorString (apiReturn, rasErrMess, length (rasErrMess));
      finally
        freemem (rasErrMess);
      end;
    end;

  finally
    freemem (pEntryName); freemem (entry);
  end;
end; //dodial

0
 

Author Comment

by:popy
ID: 1337539
lowlevel : where di you take the tpopdata type and tkitsupporteddevices..???

thanks
0
 
LVL 1

Expert Comment

by:lowlevel
ID: 1337540
those are unimportant. what you need to fill in is the entry.ras structure. as you can see, this example source only uses them to fill in the entry.ras structure.

the entry.ras structure is documented at the MSDN library (search for "RASENTRY"), which i would paste here if i could, but the library is unavailable at the time i'm writing this.
0
 

Author Comment

by:popy
ID: 1337541
yes i read it and i tryed it, but i keep getting error 607 or 603 ;-(((
0
 
LVL 1

Expert Comment

by:lowlevel
ID: 1337542
const
  RASBASE = 600;
  ERROR_BUFFER_TOO_SMALL               = (RASBASE+3);
  ERROR_EVENT_INVALID                  = (RASBASE+7);

hmm when do you get these errors? and btw, the error-list is included with d_ras.zip...

0
 

Author Comment

by:popy
ID: 1337543
i getting teses error each time i tryed to using rasSetEntryProperties , think it's my pointer ;-(( the problem
0
 

Author Comment

by:popy
ID: 1337544
there is my code and i keep geeting error, also i'm not able tu use rasenumdevice, cause it keep getting error in compilation or 603 ;-(, do you have any hint..??
i trybed to use your example

procedure TfrmTest.Button1Click(Sender: TObject);
 type
      pEntry = ^tEntry;
      tEntry = record
        ras : tRasEntry;
        additionalData : byte;
      end;
    var
      size : record
        rasEntry, devInfo : longint;
      end;
      entry         : pEntry;
      pEntryName    : pChar;
      apiReturn     : longint;
      rasDialParams : tRasDialParams;
      isp,pop       : string;
      rasErrMess    : pChar;
      tel           : pChar;
      area          : Pchar;
      rasLogonScriptFile : string;
      rootpath : string;
      dev : trasdevinfo;
      mode,devi : longint;
begin
   getmem (pEntryName, max_path);
   entry:=nil;
   strPCopy (pEntryName,'Internet Laurentides');
   apiReturn:=rasGetEntryProperties (
          nil, pEntryName, nil, size.rasEntry,
          nil, size.devInfo);
        if (apiReturn<>error_cannot_find_phonebook_entry) and
           (apiReturn<>success) and (apiReturn<>ERROR_BUFFER_TOO_SMALL) then
             begin
                getmem (entry,size.rasentry);
                fillChar (entry.ras, size.rasEntry, 0);
                entry.ras.dwSize:=sizeOf (tRasEntry);
                entry.ras.dwfOptions:=
                raseo_ipHeaderCompression +
                raseo_remoteDefaultGateway +
                raseo_specificNameServers +
                raseo_swcompression +
                raseo_specificNameServers;
                entry.ras.ipaddrDns.a:=207;
                entry.ras.ipaddrDns.b:=253;
                entry.ras.ipaddrDns.c:=19;
                entry.ras.ipaddrDns.d:=2;
                entry.ras.ipaddrDnsAlt.a:=207;
                entry.ras.ipaddrDnsAlt.b:=253;
                entry.ras.ipaddrDnsAlt.c:=19;
                entry.ras.ipaddrDnsAlt.d:=3;
                entry.ras.dwfNetProtocols:=rasnp_ip;
                entry.ras.dwFramingProtocol:=rasfp_ppp;
                isp:='laurentides';
                rootpath:='c:\';
                rasLogonScriptFile:=rootPath+'ispData\'+isp+'\default.scp';
                if fileExists (rasLogonScriptFile) then
                strPCopy (entry.ras.szScript,rasLogonScriptFile);
                area:='514';
                strPCopy (entry.ras.szAreaCode,area);
                tel:='433-3008';
        strPCopy (entry.ras.szLocalPhoneNumber,tel);

        strPCopy (entry.ras.szdeviceType,'modem');
        dev.dwSize:=sizeof(dev);
        entry.ras.dwCountryCode:=strtoint('1');
        apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, size.rasEntry, nil, size.devInfo);
        if apiReturn<>success then
        MessageDlg('Error',mtError,[mbOK],0);
      end;
       freemem (pEntryName);
end;
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337545
Hi popy,

Have you looked at the source code of RASDAILEx (everything free) of F. Piette? It has enhanced features then RasDail itself!! I suggest you have a look at it.... I think it has pritty all what you need....

http://www.rtfm.be/fpiette/indexuk.htm

Regards, Zif.

Let me now if it was what you were looking for...
0
 

Author Comment

by:popy
ID: 1337546
zifnad: yes i already looked at it, it dont do what i need, i need to add connection in RAS without going by the wizard, i tryed the code up, and it keep giving me errors ;-( if you have idea  what wrong with my code i will be happy ;-)
0
 

Author Comment

by:popy
ID: 1337547
Adjusted points to 700
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337548
Hi popy,

I don't understand? Sorry!

Here is a code snippet of RadDailer (f.piette);

procedure TRasDialerForm.DoConnect;
begin
    SaveSettings;
    InfoListBox.Clear;
    Caption := ProgName + ' - Dialing';
    TimeAutoForm.Section := 'RAS_ENTRY_' + CrunchName(EntryNameComboBox.Text);
    if not TimeAutoForm.Check then begin
        LogMessage('Time Restriction Apply');
        Disconnected;
        Exit;
    end;
    DialingServer   := EntryNameComboBox.Text;
    DialingUserName := UserNameComboBox.Text;
    DialingPassword := PasswordEdit.Text;
    Dial(DialingServer, DialingUserName, DialingPassword);
end;

It looks like if you put directely the name in DialingUserName and same for DialingPassWord that it doesn't askes for a password and username.... I must admit that I haven't tested it though...

    DialingUserName := 'MyUser';
    DialingPassword := 'MyPassword';

This should work, although I can't test it... What's error if you try this?

Have you already spoken on the mailing list of F.Piette? He 's responds almost immediately.

Regards, ZiF.
0
 

Author Comment

by:popy
ID: 1337549
zifnad : my point is to use setrasproperties from d_ras, and rnaph.dll,  and each time i trying to use it , i keep giving me error, i alreay tryed the f.piette code, it working fine, but when i want to add connection the code popup the connection wizard of windows, me i dont want to have connection wizard,. i want to add connection right away with phone number, ip adrress etc etc
there is my problem, look at the code ii put up you will understand

thanks
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337550
Popy, what system do you use and what version of Delphi, system...
0
 

Author Comment

by:popy
ID: 1337551
i using win95, with delphi 3.0 standard (without patch dont know where to find them)
0
 
LVL 1

Expert Comment

by:Greedy
ID: 1337552
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337553
yep, or http://www.user.xpoint.at/r.fellner/DELPHIP.HTM (at bottem of this page).

Ok when do you get your errors? When compiling (at which line)?
When running (after which line)?
0
 

Author Comment

by:popy
ID: 1337554
i getting error in the execution : at this line
apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, size.rasEntry, nil, size.devInfo)
603 or 607, and one time i got 1727 ;-),
603 is buffer too small
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337555
first explain me this (help me a little, thanks) why do you use instead of rasSetEntryProperties RasSetEntryDialParams when your goal is just making a connection.
0
 

Author Comment

by:popy
ID: 1337556
ok, because i making programm, where new user on the internet (usualy newbie) just have to click on it, and put his username, password and the pop server where to dail, after clicking OK, the programm will add automatly the connection with all parametter like phone number, username, password, DNS server etc, and for sur i dont want to have the wizard windows, i want to do all automatly, and rasSetEntryProperties his the only i found to do that...hope it will help you
if you need more there is my ICQ 102293 ;-)
P.S. sorry for my bad english ;-)
0
 
LVL 1

Expert Comment

by:lowlevel
ID: 1337557
i'll take a look at this entire case again sometime today / tommorow, and i'll get back to you.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Expert Comment

by:ZifNab
ID: 1337558
Popy,

I can't test this all, so what happens if you change to this :

apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(trasEntry), nil, size.devInfo)

or

apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(Entry), nil, size.devInfo)

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337559
Popy, was reading comments above... About Greedy's solution... you only had to change the modem properties (Correct?) F.Piette has also a source code for this....

And what error do we get now?

Regards, ZiF.
0
 

Author Comment

by:popy
ID: 1337560
with apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(trasEntry), nil, size.devInfo)  i got error 87

and with
apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(Entry), nil, size.devInfo)
i got error 603 ;-(
0
 

Author Comment

by:popy
ID: 1337561
humm..yes i remember that, itryed with the regitry before, and i keep my modem, i will take a look at the f.piette source again
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337562
Hi Popy,

The source for modem settings is not with RASDAIL, you've to get f. Piette his page.

Secondly I don't understand something : Why using longint as DWORD is correctly?

  size : record
               rasEntry, devInfo : longint;  <- shouldn't this be DWord? (not that it makes some change, but ...) Please correct me if I'm wrong.
             end;

Thirdly, maybe we've to make also a devinfo structure?

tRasDevInfo = record
 Size : DWORD;
 DeviceType : String[RAS_MaxDeviceType+1];
 DeviceName : String[RAS_MaxDeviceName+1];
end;

And then use it in our RasSetEntryProperties....

apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(tRasEntry), nil, SizeOf(tRasDevInfo)) or something like this. I really think it has something to do with this. Try some things out... Like giving a DevInfo Buffer and a size of this buffer, etc ...
Damn I hate when I can't test something...

Hope you keep me informed, because I find this really interesting. Have to go now,
Regards Zif.


0
 

Author Comment

by:popy
ID: 1337563
humm...you can test it with d_ras i found it at delphi exchange unit is RAS.pas, i used it for my programm, you can find it at http://www.kobira.co.jp/sakura/d_net_RasAPI.htm
it have all exeample with it, and i added my code in this example

regards popy

0
 

Author Comment

by:popy
ID: 1337564
by the way, i keep getting error 87 with the last try
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337565
Ok Popy, I'm back, do you know what error 87 means? What things have you tried?

I can't test it here, because I don't have the RAS DLL here on my computer at work...
Regards, ZiF.
0
 

Author Comment

by:popy
ID: 1337566
no i dont know what error 87 mean ;-(, i tryed the both code you gave me, and i put Dword instead longint, i will continue to look for the 87

regards, popy
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337567
And this?

pRasDevInfo = ^tRasDevInfo;
tRasDevInfo = record
        Size : DWORD;
        DeviceType : String[RAS_MaxDeviceType+1];
        DeviceName : String[RAS_MaxDeviceName+1];
       end;

RasDevInfo : pRasDevInfo;
Entry : pEntry

apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(Entry), nil, SizeOf(RasDevInfo))
or
apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(tRasEntry), rasdevinfo, SizeOf(RasDevInfo))
or
apiReturn:=rasSetEntryProperties (nil, pEntryName, entry, SizeOf(tRasEntry), rasdevinfo, SizeOf(tRasDevInfo))
0
 

Author Comment

by:popy
ID: 1337568
didnt work, still having error 87, or raise exeption at the execution
0
 
LVL 1

Expert Comment

by:lowlevel
ID: 1337569
popy: what exception?

a while back, greedy wrote:
>i think the whole thing is held in the registry... unfortunatly at work I can't play with that stuff.... <snip>

under NT, RAS-entries are stored in phone-book files. So this approach won't work under NT, and it's a hack in the first place.

As for the error's you guys have been getting:
87 - invalid parameter
603 - buffer too small
1727 -  The remote procedure call failed and did not execute.

87 and 603 are normal for incorrect api-calls.
maybe my first example was a bit too much, let me try it again.
the following source uses only the units from d_ras.zip

procedure rasSetEntryProp;
var
  entry : tRASEntry;
  sEntry : dword; //or longint, doesn't matter. both r 4 bytes in size..
  apiReturn : longint;
  pName     : pChar;
begin
  {fill entry structure with good data}
  entry.dwSize:=sizeOf (tRASEntry);
  sEntry:=entry.dwSize;
 
  getmem (pName, max_path);
  strpcopy (pName, 'entryName');
 
  apiReturn:=rasSetEntryProperties (nil, pName, entry, sEntry, nul, 0); //the last two params aren't used.

  freemem (pName);
end;

try this. If you get 603, check if the sEntry has changed before/after the APIcall.

One of the biggest problems i have right now with the RAS-api is the versioning of it. M$, in their !wisdom, have made things very complicated, with 4 different versions of RASEntry structures, for instance. I'm currently making this RAS-activeX which should make things really easy for app-programmers, but it's a pain in the arse to write.

Anyway, I don't think you guys have read the MSDN docs on this call, so i'll post them here (have got xs to them now :)

------------  RasSetEntryProperties MSDN documentation --------

The RasSetEntryProperties function changes the connection information for an entry in the phone book or creates a new phone-book entry.

DWORD RasSetEntryProperties(
  LPCTSTR lpszPhonebook,  // pointer to full path and filename of
                          // phone-book file
  LPCTSTR lpszEntry,      // pointer to an entry name
  LPRASENTRY lpRasEntry,  // buffer that contains entry information
  DWORD dwEntryInfoSize,  // size, in bytes, of the lpRasEntry
                          // buffer
  LPBYTE lpbDeviceInfo,   // buffer that contains device-specific
                          // configuration information
  DWORD dwDeviceInfoSize  // size, in bytes, of the lpbDeviceInfo
                          // buffer
);
 
Parameters
lpszPhonebook
Windows NT: Pointer to a null-terminated string that specifies the full path and filename of a phone-book (.PBK) file. If this parameter is NULL, the function uses the current default phone-book file. The default phone-book file is the one selected by the user in the User Preferences property sheet of the Dial-Up Networking dialog box.
lpszEntry
Pointer to a null-terminated string containing an entry name.
If the entry name matches an existing entry, RasSetEntryProperties modifies the properties of that entry.

If the entry name does not match an existing entry, RasSetEntryProperties creates a new phone-book entry. For new entries, call the RasValidateEntryName function to validate the entry name before calling RasSetEntryProperties.

lpRasEntry
Pointer to a RASENTRY structure that contains the new connection data to be associated with the phone-book entry specified by the lpszEntry parameter.
The structure might be followed by an array of null-terminated alternate phone number strings. The last string is terminated by two consecutive null characters. The dwAlternateOffset member of the RASENTRY structure contains the offset to the first string.

dwEntryInfoSize
Specifies the size, in bytes, of the buffer specified by the lpRasEntry parameter.
lpbDeviceInfo
Pointer to a buffer containing device-specific configuration information. This is opaque TAPI device configuration information. For more information about TAPI device configuration, see the lineGetDevConfig function in the Win32 Telephony (TAPI) Programmer's Reference.
Windows NT: This parameter is unused. The calling function should set this parameter to NULL.

dwDeviceInfoSize
Specifies the size, in bytes, of the lpbDeviceInfo buffer.
Windows NT: This parameter is unused. The calling function should set this parameter to zero.

Return Values
If the function succeeds, the return value is zero.

If the function fails, the return value can be one of the following error codes.

Value Meaning
ERROR_BUFFER_INVALID The address or buffer specified by lpRasEntry is invalid.
ERROR_CANNOT_OPEN_PHONEBOOK The phone book is corrupted or missing components.


Remarks
Windows CE: For Windows CE version 1.0, the lpbDeviceInfo and lpdwDeviceInfoSize parameters are ignored and should be set to NULL. To set device specific configuration information use the RasSetEntryDevConfig function.

For Windows CE version 2.0 and later, device configuration information can be set by using lpbDeviceInfo and lpdwDeviceInfoSize parameters.

QuickInfo
  Windows NT: Requires version 4.0 or later.
  Windows: Requires Windows 95 OSR2 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in ras.h.
  Import Library: Use rasapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also
Remote Access Service Overview, RAS Server Administration Functions, RASENTRY, RasCreatePhonebookEntry, RasGetEntryProperties, RasValidateEntryName


---------------------  RASENTRY MSDN documentation -------------


RASENTRY
The RASENTRY structure describes a phone-book entry. The RasSetEntryProperties and RasGetEntryProperties functions use this structure to set and retrieve the properties of a phone-book entry.

typedef struct tagRASENTRY {
  DWORD      dwSize;
  DWORD      dwfOptions;
  //
  // Location/phone number.
  //
  DWORD      dwCountryID;
  DWORD      dwCountryCode;
  TCHAR      szAreaCode[ RAS_MaxAreaCode + 1 ];
  TCHAR      szLocalPhoneNumber[ RAS_MaxPhoneNumber + 1 ];
  DWORD      dwAlternateOffset;
  //
  // PPP/Ip
  //
  RASIPADDR  ipaddr;
  RASIPADDR  ipaddrDns;
  RASIPADDR  ipaddrDnsAlt;
  RASIPADDR  ipaddrWins;
  RASIPADDR  ipaddrWinsAlt;
  //
  // Framing
  //
  DWORD      dwFrameSize;
  DWORD      dwfNetProtocols;
  DWORD      dwFramingProtocol;
  //
  // Scripting
  //
  TCHAR      szScript[ MAX_PATH ];
  //
  // AutoDial
  //
  TCHAR       szAutodialDll[ MAX_PATH ];
  TCHAR       szAutodialFunc[ MAX_PATH ];
  //
  // Device
  //
  TCHAR      szDeviceType[ RAS_MaxDeviceType + 1 ];
  TCHAR      szDeviceName[ RAS_MaxDeviceName + 1 ];
  //
  // X.25
  //
  TCHAR      szX25PadType[ RAS_MaxPadType + 1 ];
  TCHAR      szX25Address[ RAS_MaxX25Address + 1 ];
  TCHAR      szX25Facilities[ RAS_MaxFacilities + 1 ];
  TCHAR      szX25UserData[ RAS_MaxUserData + 1 ];
  DWORD      dwChannels;
  //
  // Reserved
  //
  DWORD       dwReserved1;
  DWORD       dwReserved2;
#if (WINVER >= 0x401)
  //
  // Multilink
  //
  DWORD       dwSubEntries;
  DWORD       dwDialMode;
  DWORD       dwDialExtraPercent;
  DWORD       dwDialExtraSampleSeconds;
  DWORD       dwHangUpExtraPercent;
  DWORD       dwHangUpExtraSampleSeconds;
  //
  // Idle timeout
  //
  DWORD       dwIdleDisconnectSeconds;
#endif
#if (WINVER >= 0x500)
  //
  // Port Name
  //
  TCHAR       szPortName[ RAS_MaxDeviceName + 1 ];
#endif
} RASENTRY;
 
Members
dwSize
Specifies the size, in bytes, of the RASENTRY structure. Before calling RasSetEntryProperties or RasGetEntryProperties, set dwSize to sizeof(RASENTRY) to identify the version of the structure.
dwfOptions
A set of bit flags that specify connection options. You can set one or more of the following flags. Flag Description
RASEO_UseCountryAndAreaCodes If this flag is set, the dwCountryID, dwCountryCode, and szAreaCode members are used to construct the phone number. If this flag is not set, these members are ignored.
This flag corresponds to the Use Country and Area Codes check box in the Phone dialog box.
 
RASEO_SpecificIpAddr If this flag is set, RAS tries to use the IP address specified by ipaddr as the IP address for the dial-up connection. If this flag is not set, the value of the ipaddr member is ignored.
Setting the RASEO_SpecificIpAddr flag corresponds to selecting the Specify an IP Address setting in the TCP/IP settings dialog box. Clearing the RASEO_SpecificIpAddr flag corresponds to selecting the Server Assigned IP Address setting in the TCP/IP settings dialog box.

Currently, an IP address set in the phone-book entry properties or retrieved from a server overrides the IP address set in the network control panel.
 
RASEO_SpecificNameServers If this flag is set, RAS uses the ipaddrDns, ipaddrDnsAlt, ipaddrWins, and ipaddrWinsAlt members to specify the name server addresses for the dial-up connection. If this flag is not set, RAS ignores these members.
Setting the RASEO_SpecificNameServers flag corresponds to selecting the Specify Name Server Addresses setting in the TCP/IP Settings dialog box. Clearing the RASEO_SpecificNameServers flag corresponds to selecting the Server Assigned Name Server Addresses setting in the TCP/IP Settings dialog box.

 
RASEO_IpHeaderCompression If this flag is set, RAS negotiates to use IP header compression on PPP connections.
If this flag is not set, IP header compression is not negotiated.

This flag corresponds to the Use IP Header Compression check box in the TCP/IP settings dialog box. It is generally advisable to set this flag because IP header compression significantly improves performance. The flag should be cleared only when connecting to a server that does not correctly negotiate IP header compression.
 
RASEO_RemoteDefaultGateway If this flag is set, the default route for IP packets is through the dial-up adapter when the connection is active. If this flag is clear, the default route is not modified.
This flag corresponds to the Use Default Gateway on Remote Network check box in the TCP/IP settings dialog box.
 
RASEO_DisableLcpExtensions If this flag is set, RAS disables the PPP LCP extensions defined in RFC 1570. This may be necessary to connect to certain older PPP implementations, but interferes with features such as server callback. Do not set this flag unless specifically required.
RASEO_TerminalBeforeDial If this flag is set, RAS displays a terminal window for user input before dialing the connection.
 
RASEO_TerminalAfterDial If this flag is set, RAS displays a terminal window for user input after dialing the connection.
Do not set this flag if a dial-up networking script is to be associated with the connection, because scripting has its own terminal implementation.

 
RASEO_ModemLights This flag is currently ignored.  
RASEO_SwCompression If this flag is set, software compression is negotiated on the link. Setting this flag causes the PPP driver to attempt to negotiate CCP with the server. This flag should be set by default, but clearing it can reduce the negotiation period if the server does not support a compatible compression protocol.
RASEO_RequireEncryptedPw If this flag is set, only secure password schemes can be used to authenticate the client with the server. This prevents the PPP driver from using the PAP plain-text authentication protocol to authenticate the client. The CHAP and SPAP authentication protocols are also supported. Clear this flag for increased interoperability, and set it for increased security.
This flag corresponds to the Require Encrypted Password check box in the Security dialog box. See also RASEO_RequireMsEncryptedPw.

 
RASEO_RequireMsEncryptedPw If this flag is set, only Microsoft's secure password schemes can be used to authenticate the client with the server. This prevents the PPP driver from using the PPP plain-text authentication protocol, MD5-CHAP, MS-CHAP, or SPAP. The flag should be cleared for maximum interoperability and should be set for maximum security. This flag takes precedence over RASEO_RequireEncryptedPw.
This flag corresponds to the Require Microsoft Encrypted Password check box in the Security dialog box. See also RASEO_RequireDataEncryption.

 
RASEO_RequireDataEncryption If this flag is set, data encryption must be negotiated successfully or the connection should be dropped. This flag is ignored unless RASEO_RequireMsEncryptedPw is also set.
This flag corresponds to the Require Data Encryption check box in the Security dialog box.

 
RASEO_NetworkLogon If this flag is set, RAS logs on to the network after the point-to-point connection is established.
This flag currently has no effect under Windows NT.

 
RASEO_UseLogonCredentials If this flag is set, RAS uses the user name, password, and domain of the currently logged-on user when dialing this entry. This flag is ignored unless RASEO_RequireMsEncryptedPw is also set.
Note that this setting is ignored by the RasDial function, where specifying empty strings for the szUserName and szPassword members of the RASDIALPARAMS structure gives the same result.

This flag corresponds to the Use Current Username and Password check box in the Security dialog box.

 
RASEO_PromoteAlternates This flag has an effect when alternate phone numbers are defined by the dwAlternateOffset member. If this flag is set, an alternate phone number that connects successfully becomes the primary phone number, and the current primary phone number is moved to the alternate list.
This flag corresponds to the check box in the Alternate Numbers dialog box.

 
RASEO_SecureLocalFiles Windows NT only: If this flag is set, RAS checks for existing remote file system and remote printer bindings before making a connection with this entry. Typically, you set this flag on phone-book entries for public networks to remind users to break connections to their private network before connecting to a public network.


dwCountryID
Specifies the TAPI country identifier. Use the RasGetCountryInfo function to enumerate country identifiers. This member is ignored unless the dwfOptions member specifies the RASEO_UseCountryAndAreaCodes flag.
dwCountryCode
Specifies the country code portion of the phone number. The country code must correspond to the country identifier specified by dwCountryID. If dwCountryCode is zero, the country code is based on the country identifier specified by dwCountryID. This member is ignored unless dwfOptions specifies the RASEO_UseCountryAndAreaCodes flag.
szAreaCode
Specifies the area code as a null-terminated string. If the dialing location does not have an area code, specify an empty string (""). Do not include parentheses or other delimiters in the area code string. (For example, "206" is a valid area code; "(206)" is not. This member is ignored unless the dwfOptions member specifies the RASEO_UseCountryAndAreaCodes flag.
szLocalPhoneNumber
Specifies a null-terminated string containing a telephone number. The way RAS uses this string depends on whether the dwfOptions member specifies the RASEO_UseCountryAndAreaCodes flag. If the flag is set, RAS combines szLocalPhoneNumber with the country and area codes specified by the dwCountryID, dwCountryCode , and szAreaCode members. If the flag is not set, RAS uses the szLocalPhoneNumber string as the entire phone number.
dwAlternateOffset
Specifies the offset, in bytes, from the beginning of the structure to a list of consecutive null-terminated strings. The last string is terminated by two consecutive null characters. The strings are alternate phone numbers that RAS dials in the order listed if the primary number (see szLocalPhoneNumber) fails to connect. The alternate phone number strings are ANSI or Unicode, depending on whether you use the ANSI or Unicode version of the structure.
ipaddr
Specifies the IP address to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificIpAddr flag.
ipaddrDns
Specifies the IP address of the DNS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag.
ipaddrDnsAlt
Specifies the IP address of a secondary or backup DNS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag.
ipaddrWins
Specifies the IP address of the WINS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag.
ipaddrWinsAlt
Specifies the IP address of a secondary WINS server to be used while this connection is active. This member is ignored unless dwfOptions specifies the RASEO_SpecificNameServers flag.
dwFrameSize
Specifies the network protocol frame size. The value should be either 1006 or 1500. This member is ignored unless dwFramingProtocol specifies the RASFP_Slip flag.
dwfNetProtocols
Specifies the network protocols to negotiate. This member can be a combination of the following flags. Flag Description
RASNP_NetBEUI Negotiate the NetBEUI protocol.
RASNP_Ipx Negotiate the IPX protocol.
RASNP_Ip Negotiate the TCP/IP protocol.


dwFramingProtocol
Specifies the framing protocol used by the server. PPP is the emerging standard. SLIP is used mainly in UNIX environments. This member can be one of the following flags. Flag Description
RASFP_Ppp Point-to-Point Protocol (PPP)  
RASFP_Slip Serial Line Internet Protocol (SLIP)
RASFP_Ras Microsoft proprietary protocol implemented in Windows NT 3.1 and Windows for Workgroups 3.11


To use Compressed SLIP, set the RASFP_Slip flag and set the RASEO_IpHeaderCompression flag in the dwfOptions member.

szScript
Specifies a null-terminated string containing the name of the script file. The filename should be a full path.
Windows NT: To indicate a Windows NT SWITCH.INF script name, set the first character of the name to "[".

szAutodialDll
Specifies a null-terminated string containing the full path and filename of the dynamic-link library (DLL) for the customized AutoDial handler. If szAutodialDll contains an empty string (""), RAS uses the default dialing user interface and the szAutodialFunc member is ignored.
szAutodialFunc
Specifies a null-terminated string containing the exported name of the RASADFunc function for the customized AutoDial handler. An AutoDial DLL must provide both ANSI and Unicode versions of the RASADFunc handler. However, do not include the "A" or "W" suffix in the name specified by szAutodialFunc.
szDeviceType
Specifies a null-terminated string indicating the RAS device type referenced by szDeviceName. This member can be one of the following string constants. String Description
RASDT_Modem A modem accessed through a COM port.
RASDT_Isdn An ISDN card with corresponding NDISWAN driver installed.
RASDT_X25 An X.25 card with corresponding NDISWAN driver installed.
RASDT_Vpn A virtual private network connection.
RASDT_Pad A Packet Assembler/Disassembler.


Windows 95: The RASDT_Vpn device type is supported on Windows 95 only if Microsoft Dial-Up Networking Version 1.2 is installed. The RASDT_X25 and RASDT_Pad device types are not supported on Windows 95.

Windows 98: The RASDT_Vpn device type is supported on Windows 98. However, the RASDT_X25 and RASDT_Pad device types are not currently supported on Windows 98

szDeviceName
Contains a null-terminated string containing the name of a TAPI device to use with this phone-book entry. To enumerate all available RAS-capable devices, use the RasEnumDevices function.
szX25PadType
Contains a null-terminated string that identifies the X.25 PAD type. Set this member to "" unless the entry should dial using an X.25 PAD.
Windows NT: Under Windows NT, the szX25PadType string maps to a section name in PAD.INF.

szX25Address
Contains a null-terminated string that identifies the X.25 address to connect to. Set this member to "" unless the entry should dial using an X.25 PAD or native X.25 device.
szX25Facilities
Contains a null-terminated string that specifies the facilities to request from the X.25 host at connection. This member is ignored if szX25Address is an empty string ("").
szX25UserData
Contains a null-terminated string that specifies additional connection information supplied to the X.25 host at connection. This member is ignored if szX25Address is an empty string ("").
dwChannels;
dwReserved1
Reserved; must be zero.
dwReserved2
Reserved; must be zero.
dwSubEntries
Specifies the number of multilink subentries associated with this entry. When calling RasSetEntryProperties, set this member to zero. To add subentries to a phone-book entry, use the RasSetSubEntryProperties function.
dwDialMode
Windows NT 5.0 or later: Indicates whether RAS should dial all of this entry's multilink subentries when the entry is first connected. This member can be one of the following values. Value Meaning
RASEDM_DialAll Dial all subentries initially.
RASEDM_DialAsNeeded Adjust the number of subentries as bandwidth is needed. RAS uses the dwDialExtraPercent, dwDialExtraSampleSeconds, dwDialHangUpExtraPercent, and dwHangUpExtraSampleSeconds members to determine when to dial or disconnect a subentry.


dwDialExtraPercent
Windows NT 5.0 or later: Specifies a percent of the total bandwidth available from the currently connected subentries. RAS dials an additional subentry when the total bandwidth used exceeds dwDialExtraPercent percent of the available bandwidth for at least dwDialExtraSampleSeconds seconds.
This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag.

dwDialExtraSampleSeconds
Windows NT 5.0 or later: Specifies the number of seconds that current bandwidth usage must exceed the threshold specified by dwDialExtraPercent before RAS dials an additional subentry.
This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag.

dwHangUpExtraPercent
Windows NT 5.0 or later: Specifies a percent of the total bandwidth available from the currently connected subentries. RAS terminates (hangs up) an existing subentry connection when total bandwidth used is less than dwHangUpExtraPercent percent of the available bandwidth for at least dwHangUpExtraSampleSeconds seconds.
This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag.

dwHangUpExtraSampleSeconds
Windows NT 5.0 or later: Specifies the number of seconds that current bandwidth usage must be less than the threshold specified by dwHangUpExtraPercent before RAS terminates an existing subentry connection.
This member is ignored unless the dwDialMode member specifies the RASEDM_DialAsNeeded flag.

dwIdleDisconnectSeconds
Specifies the number of seconds after which the connection is terminated due to inactivity. Note that unless the idle timeout is disabled, the entire connection is terminated if the connection is idle for the specified interval. This member can specify a number of seconds, or one of the following values. Value Meaning
RASIDS_Disabled There is no idle timeout for this connection.  
RASIDS_UseGlobalValue Use the user preference value as the default.  


szPortName
Specifies a null-terminated string containing the name of the port. The port name will depend on the RAS device type. For example, typical port names for a modem device would be "COM1" or "COM2.". For virtual private networks, the port name identifies the VPN connection.
Remarks
Unless the operating system is Windows NT 5.0 or later, the RAS Connection Manager ignores the dwDialMode, dwDialExtraPercent, dwDialExtraSampleSeconds, dwHangUpExtraPercent, and dwHangUpExtraSampleSeconds members. RAS uses these members for the Bandwidth Allocation Protocol (BAP). BAP is available only on Windows NT 5.0 or later versions.

QuickInfo
  Windows NT: Requires version 4.0 or later.
  Windows: Requires Windows 95 OSR2 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in ras.h.
  Unicode: Defined as Unicode and ANSI structures.

See Also
Remote Access Service Overview, RAS Server Administration Union, RASADFunc, RasGetCountryInfo, RasSetEntryProperties, RasSetSubEntryProperties

0
 
LVL 1

Expert Comment

by:lowlevel
ID: 1337570
popy: what exception?

a while back, greedy wrote:
>i think the whole thing is held in the registry... unfortunatly at work I can't play with that stuff.... <snip>

under NT, RAS-entries are stored in phone-book files. So this approach won't work under NT, and it's a hack in the first place.

As for the error's you guys have been getting:
87 - invalid parameter
603 - buffer too small
1727 -  The remote procedure call failed and did not execute.

87 and 603 are normal for incorrect api-calls.
maybe my first example was a bit too much, let me try it again.
the following source uses only the units from d_ras.zip

procedure rasSetEntryProp;
var
  entry : tRASEntry;
  sEntry : dword; //or longint, doesn't matter. both r 4 bytes in size..
  apiReturn : longint;
  pName     : pChar;
begin
  {fill entry structure with good data}
  entry.dwSize:=sizeOf (tRASEntry);
  sEntry:=entry.dwSize;
 
  getmem (pName, max_path);
  strpcopy (pName, 'entryName');
 
  apiReturn:=rasSetEntryProperties (nil, pName, entry, sEntry, nul, 0); //the last two params aren't used.

  freemem (pName);
end;

try this. If you get 603, check if the sEntry has changed before/after the APIcall.

One of the biggest problems i have right now with the RAS-api is the versioning of it. M$, in their !wisdom, have made things very complicated, with 4 different versions of RASEntry structures, for instance. I'm currently making this RAS-activeX which should make things really easy for app-programmers, but it's a pain in the arse to write.

Anyway, I don't think you guys have read the MSDN docs on this call, so i'll post them here (have got xs to them now :)

------------  RasSetEntryProperties MSDN documentation --------

The RasSetEntryProperties function changes the connection information for an entry in the phone book or creates a new phone-book entry.

DWORD RasSetEntryProperties(
  LPCTSTR lpszPhonebook,  // pointer to full path and filename of
                          // phone-book file
  LPCTSTR lpszEntry,      // pointer to an entry name
  LPRASENTRY lpRasEntry,  // buffer that contains entry information
  DWORD dwEntryInfoSize,  // size, in bytes, of the lpRasEntry
                          // buffer
  LPBYTE lpbDeviceInfo,   // buffer that contains device-specific
                          // configuration information
  DWORD dwDeviceInfoSize  // size, in bytes, of the lpbDeviceInfo
                          // buffer
);
 
Parameters
lpszPhonebook
Windows NT: Pointer to a null-terminated string that specifies the full path and filename of a phone-book (.PBK) file. If this parameter is NULL, the function uses the current default phone-book file. The default phone-book file is the one selected by the user in the User Preferences property sheet of the Dial-Up Networking dialog box.
lpszEntry
Pointer to a null-terminated string containing an entry name.
If the entry name matches an existing entry, RasSetEntryProperties modifies the properties of that entry.

If the entry name does not match an existing entry, RasSetEntryProperties creates a new phone-book entry. For new entries, call the RasValidateEntryName function to validate the entry name before calling RasSetEntryProperties.

lpRasEntry
Pointer to a RASENTRY structure that contains the new connection data to be associated with the phone-book entry specified by the lpszEntry parameter.
The structure might be followed by an array of null-terminated alternate phone number strings. The last string is terminated by two consecutive null characters. The dwAlternateOffset member of the RASENTRY structure contains the offset to the first string.

dwEntryInfoSize
Specifies the size, in bytes, of the buffer specified by the lpRasEntry parameter.
lpbDeviceInfo
Pointer to a buffer containing device-specific configuration information. This is opaque TAPI device configuration information. For more information about TAPI device configuration, see the lineGetDevConfig function in the Win32 Telephony (TAPI) Programmer's Reference.
Windows NT: This parameter is unused. The calling function should set this parameter to NULL.

dwDeviceInfoSize
Specifies the size, in bytes, of the lpbDeviceInfo buffer.
Windows NT: This parameter is unused. The calling function should set this parameter to zero.

Return Values
If the function succeeds, the return value is zero.

If the function fails, the return value can be one of the following error codes.

Value Meaning
ERROR_BUFFER_INVALID The address or buffer specified by lpRasEntry is invalid.
ERROR_CANNOT_OPEN_PHONEBOOK The phone book is corrupted or missing components.


Remarks
Windows CE: For Windows CE version 1.0, the lpbDeviceInfo and lpdwDeviceInfoSize parameters are ignored and should be set to NULL. To set device specific configuration information use the RasSetEntryDevConfig function.

For Windows CE version 2.0 and later, device configuration information can be set by using lpbDeviceInfo and lpdwDeviceInfoSize parameters.

QuickInfo
  Windows NT: Requires version 4.0 or later.
  Windows: Requires Windows 95 OSR2 or later.
  Windows CE: Requires version 1.0 or later.
  Header: Declared in ras.h.
  Import Library: Use rasapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also
Remote Access Service Overview, RAS Server Administration Functions, RASENTRY, RasCreatePhonebookEntry, RasGetEntryProperties, RasValidateEntryName


---------------------  RASENTRY MSDN documentation -------------


RASENTRY
The RASENTRY structure describes a phone-book entry. The RasSetEntryProperties and RasGetEntryProperties functions use this structure to set and retrieve the properties of a phone-book entry.

typedef struct tagRASENTRY {
  DWORD      dwSize;
  DWORD      dwfOptions;
  //
  // Location/phone number.
  //
  DWORD      dwCountryID;
  DWORD      dwCountryCode;
  TCHAR      szAreaCode[ RAS_MaxAreaCode + 1 ];
  TCHAR      szLocalPhoneNumber[ RAS_MaxPhoneNumber + 1 ];
  DWORD      dwAlternateOffset;
  //
  // PPP/Ip
  //
  RASIPADDR  ipaddr;
  RASIPADDR  ipaddrDns;
  RASIPADDR  ipaddrDnsAlt;
  RASIPADDR  ipaddrWins;
  RASIPADDR  ipaddrWinsAlt;
  //
  // Framing
  //
  DWORD      dwFrameSize;
  DWORD      dwfNetProtocols;
  DWORD      dwFramingProtocol;
  //
  // Scripting
  //
  TCHAR      szScript[ MAX_PATH ];
  //
  // AutoDial
  //
  TCHAR       szAutodialDll[ MAX_PATH ];
  TCHAR       szAutodialFunc[ MAX_PATH ];
  //
  // Device
  //
  TCHAR      szDeviceType[ RAS_MaxDeviceType + 1 ];
  TCHAR      szDeviceName[ RAS_MaxDeviceName + 1 ];
  //
  // X.25
  //
  TCHAR      szX25PadType[ RAS_MaxPadType + 1 ];
  TCHAR      szX25Address[ RAS_MaxX25Address + 1 ];
  TCHAR      szX25Facilities[ RAS_MaxFacilities + 1 ];
  TCHAR      szX25UserData[ RAS_MaxUserData + 1 ];
  DWORD      dwChannels;
  //
  // Reserved
  //
  DWORD       dwReserved1;
  DWORD       dwReserved2;
#if (WINVER >= 0x401)
  //
  // Multilink
  //
  DWORD       dwSubEntries;
  DWORD       dwDialMode;
  DWORD       dwDialExtraPercent;
  DWORD       dwDialExtraSampleSeconds;
  DWORD       dwHangUpExtraPercent;
  DWORD       dwHangUpExtraSampleSeconds;
  //
  // Idle timeout
  //
  DWORD       dwIdleDisconnectSeconds;
#endif
#if (WINVER >= 0x500)
  //%
0
 

Author Comment

by:popy
ID: 1337571
lowlevel : ok when it compile it said to me error incompatible type, the entry was not in pointer then i tryed this : var
        entry : ^tRASEntry;
didnt worked  gave this error at the execution : error 87 again ;-(

after i tryed : apiReturn:=rasSetEntryProperties(nil, pName, @entry, sEntry, nil, 0);
still getting error 87

P.S. i read the MSDN doc, but my english is bad, then i didnt understood all explanation on it ;-(
regard Popy
0
 

Author Comment

by:popy
ID: 1337572
Adjusted points to 800
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337573
Hi all,

 I suggest to look at these :

 www.mittelschule.ch/pilif/index.html (maybe we can learn something out of these comp.)
 
 delphi.lehner.at/ftp/rasapi.zip --> excellent library! Look at it...

 I suggest to use this library on the code of RasSetEntryProperties like above.

Give me a sign, if it works... or what errors it produces....

Next week I've got a new computer at home and then I'll be able to work on this object myself!...

Regards, Zif.
0
 

Author Comment

by:popy
ID: 1337574
zif : damnit,  still having the error 87 with both source ;-(
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337575
Yo popy,

 At the moment I'm only try to collect as much information as I can of this subject.

 Would you like to try out this component? And give me some problems there occure?

 http://delphi.lehner.at/ftp/dialup.zip

Regards, ZiF.
0
 

Author Comment

by:popy
ID: 1337576
ok, this component working, i can dial etc, but it dont do want with the rassetentrie.....

thanks
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337577
Hi popy,

Ask asked to several people on the net and to my friends about this, seems that everybody who tried to work with RasSetEntryProperties always get the same error :

ERROR_INCORRECT_PARAMETER

I'll let you know as soon as I get more info....

Regards, ZiF.


0
 

Author Comment

by:popy
ID: 1337578
ok thanks zif,
 i will continue to take a look too on my side

regards
popy
0
 

Author Comment

by:popy
ID: 1337579
damnit, i just get the version 2.1 of D_RAS , with examples of rasSetEntryProperties and in the demo it keep ketting error 87 ;-( guess before post the new version david tested it...think it's my windows dont know,
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337580
Hi poppy, I see it appears now also at torry's pages : www.torry.ru/vcl/comms/d_ras.zip.

Is it this, are did you had a beta?
0
 

Author Comment

by:popy
ID: 1337581
yes i get this version 2.1,  and in there it have a demo for this procedure, and good news, i got it, i can add my connection, now it's just have to set the username and password, and think i will make component with my procedure ;-)

regards
popy
0
 

Author Comment

by:popy
ID: 1337582
also it just have to had the autodial function if someone know how i will appreciate

regards
popy
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337583
Great Popy! It finally works! What do you mean exaclty with the autodial function?
0
 

Author Comment

by:popy
ID: 1337584
well, to put the propertie when someone click on netscape , explorer etc, the win API will call automatly the RAS for connecting on the internet

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337585
Mmm. Nice, but wouldn't it be easier to make a sort of popup window. I mean, clicking on your ICON (RAS Dailer) lets the user select which internet program has to start?
0
 

Author Comment

by:popy
ID: 1337586
yes i tought about it too, and i think i will go on this way too

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337587
Yo Popy, maybe this is a better idea (I think so) Make a program, that when started appears at the 'tray' bar (right bottom task bar). Left clicking gives a menu.
 
 Adding browsers, ftp's, ....
 Deleting  ........................
 Starting .........................

Clicking Right starts the default browser at once.

Regards, ZiF.
0
 
LVL 8

Accepted Solution

by:
ZifNab earned 900 total points
ID: 1337588
Hi Popy,

just received this from a friend of mine! I suggest you'd also look at his great freeware page! : http://www.mittelschule.ch/pilif/

Hi togehter!

I send this message to two poeple, because this could be interesting
for both of them:

Today I downloaded the RASAPI-Package by Davide Moretti from
www.torry.ru I've tested it first under NT and everything worked as it
sould (mostly, I've tested the two Ras***EntryProperties functions,
because they interest me very much).

In the following test under a fresh Win95 (no subrelease, no update),
the RasSetEntryProperties did not work. I always got the error 87 (I
think): ERROR_INCORRECT_PARAMETER. It was not possible to edit an
exisiting entry: The Property-Dialog of the RasTest-Application was
correctely showed but when I clicked OK I got "RasSetEntryProperties
failed".

So I visited Microsoft's Homepage on
http://www.microsoft.com/win32dev/apiext and downloaded the
RasAPI-Extension-Samples (first I tought, that there must be a Bug in
the RNAPH.DLL, that it is not possible to save the settings). I runned
the two samples in the DOS-Box and everything worked!

The next step was to read the C-Sourcecode and -ping! I've found
something very interesting:

Pb95.c:


// REQUIRED:
//  Make sure area code is full. It is safe to put a space when the
entry
//  is blank.  You might also use TAPI APIs to get a default area code
if
//  necessary, or throw out a dialog box and get it from the user.
This
//  is irrespective of the RASEO_UseCountryAndAreaCodes flag.
//
if (!lpEntryInfo->szAreaCode[0])
      lstrcpy (lpEntryInfo->szAreaCode, " ");

I thought that tis my be interesting, so I restarted the
RasTest-Application, checked the checkbox to use Country and Aear-Codes
and entered 41 into the "Aera Code"-Editfield ..... Everything worked
now!

I am now working on a general RasSetEntry-Procedure which works in
every Application and on every plattform. When I will have finished, I
will send it to you.

Again, thanks to Davide for the Ras.pas-Unit!

Pilif

And thanks to Pilif.
Regards, ZiF.

PS. If you don't like the answer just reject it, but I think we don't have any fluid left, everything that could be said is said.
0
 

Author Comment

by:popy
ID: 1337589
hi zif : yes i like the anwers so can you tell me before is that you who make the app.???

i will grade after, you know when we grade we cant talk ;-)


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337590
Hi popy,

Nope, I didn't make the application. Which One? The url I gave you is from Pilif, and it's his program too. I stumbled on his page when I was surfing around the net and found it (altough I can't use it) quite beautifull looking (screen shots). It's freeware and it's made in delphi, so all the source is there too. I thought Pilif already solved the problem of RasSetEntryProperties, because it looked then that he worked a lot on this subject. But also he had the same error problems when I contacted him. But this day I received a mail from him back that he found out the problem and was making a solution. So now I'm eagerly waiting to see his new version of the program! Besides, I got a modem this week and now it's the time to start program with it too ;-).

Is this application something you also want to program?

c.u. Tom.


0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1337591
Hi popy, just curious,  where do you live, what do you do?
0
 

Author Comment

by:popy
ID: 1337592
i living at Montreal, and i'm ISP there ;-)

oups,  i forgot to grade your answers ;-)
i will do it in the next comment
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

746 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

11 Experts available now in Live!

Get 1:1 Help Now