Page 1 of 1
Why does GetNetworkParams_() do not work?
Posted: Mon Feb 14, 2005 11:55 am
by Tranquil
Code: Select all
Structure FIXED_INFO
HostName.s
DomainName.s
*CurrentDNSServer.l
*CurrentDNSServerList.l
NodeType.l
ScopeId.l
EnableRouting.l
EnableProxy.l
EnableDNS.l
EndStructure
OpenConsole()
res=GetNetworkParams_(info.FIXED_INFO,sizeof(fixed_info))
If res=#ERROR_BUFFER_OVERFLOW
PrintN("Buffer to small.")
EndIf
If res=#ERROR_INVALID_PARAMETER
PrintN("Invalid Parameters.")
EndIf
PrintN(info\HostName)
Input()
End
ends with invalid Parameters, but don't know why!?
Can anyone help`?
Posted: Mon Feb 14, 2005 12:00 pm
by Pupil
The second argument should be a pointer to a ULong..
And your structure is completely wrong, this is what it says in MS SDK:
Code: Select all
typedef struct {
char HostName[MAX_HOSTNAME_LEN + 4];
char DomainName[MAX_DOMAIN_NAME_LEN + 4];
PIP_ADDR_STRING CurrentDnsServer;
IP_ADDR_STRING DnsServerList;
UINT NodeType;
char ScopeId[MAX_SCOPE_ID_LEN + 4];
UINT EnableRouting;
UINT EnableProxy;
UINT EnableDns;
}
Posted: Mon Feb 14, 2005 12:27 pm
by Tranquil
Thanks Pupil, you are right, so I corrected it to:
Code: Select all
Structure FIXED_INFO
HostName.s
DomainName.s
CurrentDNSServer.s
CurrentDNSServerList.s
NodeType.l
ScopeId.s
EnableRouting.l
EnableProxy.l
EnableDNS.l
EndStructure
OpenConsole()
size.l=SizeOf(FIXED_INFO)
res=GetNetworkParams_(info.FIXED_INFO,@size.l)
If res=#ERROR_BUFFER_OVERFLOW
PrintN("Buffer to small.")
EndIf
If res=#ERROR_INVALID_PARAMETER
PrintN("Invalid Parameters.")
EndIf
PrintN(info\HostName)
Input()
End
But it doen't work eighter.

Its maybe the unsigned long what is expected here but PB is only giving a signed one!? Now I get Buffer to small.
Posted: Mon Feb 14, 2005 12:33 pm
by Pupil
Actually, all stucture items that is of type char array you should declare as an array of bytes, i.e. something like this:
Code: Select all
'char HostName[MAX_HOSTNAME_LEN + 4]'
Becomes this in PB:
HostName.b[#MAX_HOSTNAME_LEN + 4]
Posted: Mon Feb 14, 2005 12:39 pm
by Tranquil
Uf, this is bad but it works. But makes more work for coding. Can't see the reason why to do this in that way. Is that a normal behavior?
Posted: Mon Feb 14, 2005 12:44 pm
by gnozal
There are no fixed length strings in Purebasic unlike Powerbasic for example, so we have to use the byte array stuff

Posted: Mon Feb 14, 2005 12:45 pm
by Pupil
You need to do this because PB has no fixed length strings.. And you'll never get GetNetworkParams() to work if you set a string type there because a string is just a pointer to a set of nullterminated bytes..
Posted: Mon Feb 14, 2005 1:13 pm
by Tranquil
Oh I see! FRED? REQUEST!!

Posted: Mon Feb 14, 2005 5:10 pm
by olejr
You are not the first one to request it..
