bindings/win32, RAS, error 632

Leonid Krashenko jetbird at gmail.com
Thu Apr 9 11:02:12 PDT 2009


Hello!

I have a question about using bindings/win32, RAS.

I've
1. compiled win32.lib (-version=WindowsXP),
2. used "implib rasapi32.lib rasapi32.def" with written by hand  
rasapi32.def with following content (linkdef (don't know why) can't find  
any of that symbols):
Code:
LIBRARY RASAPI32
DESCRIPTION 'rasapi32.dll'
EXETYPE NT

EXPORTS
_D5win323ras20RasGetConnectStatusAFT5win323ras8HRASCONNPS5win323ras14RASCONNSTATUSAZk  
= RasGetConnectStatusA
_D5win323ras18RasGetErrorStringAFkPakZk = RasGetErrorStringA
_D5win323ras15RasEnumEntriesAFPaPaPS5win323ras13RASENTRYNAMEAPkPkZk =  
RasEnumEntriesA



3. compiled the following code:
Code:
PhoneBookEntries getPhoneBookEntries() {
     auto entries = new PhoneBookEntries;

     RASENTRYNAME[100] buf;
     buf.ptr.dwSize = RASENTRYNAME.sizeof;
     uint entriesNum, length = buf.length*RASENTRYNAME.sizeof;

// THIS IS IMPORTANT err VARIABLE
     auto err = RasEnumEntries(null, null, buf.ptr, &length, &entriesNum);

// ....

     return entries;
}



with cmd: Code:

dmd -c -ofmain.obj main.d -version=WindowsXP
dmd -c -ofrasdial.obj rasdial.d -version=WindowsXP
dmd main.obj rasdial.obj -ofdialer rasapi32.lib win32.lib  
-version=WindowsXP



4. and always get 'err' variable equal to 632, "ERROR_INVALID_STRUCTURE"  
(see http://msdn.microsoft.com/en-us/library/aa377380(VS.85).aspx for  
RasEnumEntries function details),

BUT the analogous DELPHI code works perfectly:
Code:
procedure getPhoneBookEntries(list: TStrings);
var
   BuffSize          : Integer;
   Entries           : Integer;
   Entry             : Array[1..MaxEntries] of TRasEntryName;
   X,Result_         : Integer;
begin
   list.Clear;
   Entry[1].dwSize:=SizeOf(TRasEntryName);
   BuffSize:=SizeOf(TRasEntryName)*MaxEntries;
   Result_:=RasEnumEntries(nil, nil, @Entry[1], BuffSize, Entries);


...

There is something I do wrong here... but what?



More information about the Digitalmars-d mailing list