bindings/win32, RAS, error 632

Stewart Gordon smjg_1998 at yahoo.com
Fri Apr 10 10:22:37 PDT 2009


Leonid Krashenko wrote:
<snip>
>> What value are you actually getting for RASENTRYNAME.sizeof?
>>
>> And does buf.sizeof give the same value as 
>> buf.length*RASENTRYNAME.sizeof, as it should?
> 
> Yes, it does;
> RASENTRYNAME size = 532
> WINVER = 0x501 (-version=WindowsXP)

Which agrees with my calculation.

<snip>
> Delphi:
> SizeOf(TRasEntryName) = 264
> bufsize = 26400
> 
> MinGW C++ variant of this program has WINVER = 0x400, entry size = 264 
> (works fine too).

You're comparing apples and oranges somewhat here.  Delphi and MinGW 
with version set to 0x400, D bindings with version set to 0x501.  If you 
try comparing like with like, _then_ what works and what doesn't?

That said, on re-reading your original post, I can guess what you're 
doing wrong: trying to work around the missing extern (C) attributes in 
ras.d instead of fixing them.  And consequently, merely renaming the 
functions and not actually fixing the calling convention.  I got it to 
link by fixing this error, and then....

----------
C:\Documents and Settings\Stewart\My Documents\D>type rastest.d
import win32.ras, std.stdio;

void main() {
     RASENTRYNAME[100] buf;
     buf.ptr.dwSize = RASENTRYNAME.sizeof;
     uint entriesNum, length = buf.sizeof;
     writefln("structure size: ", RASENTRYNAME.sizeof);

     auto err = RasEnumEntries(null, null, buf.ptr, &length,
       &entriesNum);
     writefln("RasEnumEntries returned: ", err);
}

C:\Documents and Settings\Stewart\My Documents\D>dmd rastest.d win32\ras.d

C:\Documents and Settings\Stewart\My Documents\D>rastest
structure size: 264
RasEnumEntries returned: 0

C:\Documents and Settings\Stewart\My Documents\D>dmd -version=WindowsXP 
rastest.d win32\ras.d

C:\Documents and Settings\Stewart\My Documents\D>rastest
structure size: 532
RasEnumEntries returned: 0
----------

FTM what version of Windows are you trying it on?  This is under XP (I'm 
away from my usual computer for a week and a bit).

Stewart.



More information about the Digitalmars-d mailing list