Just starting out? Need help? Post your questions and find answers here.
Tranquil
Addict
Posts: 952 Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe
Post
by Tranquil » Mon Feb 14, 2005 11:55 am
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`?
Tranquil
Pupil
Enthusiast
Posts: 715 Joined: Fri Apr 25, 2003 3:56 pm
Post
by Pupil » Mon Feb 14, 2005 12:00 pm
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;
}
Tranquil
Addict
Posts: 952 Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe
Post
by Tranquil » Mon Feb 14, 2005 12:27 pm
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.
Tranquil
Pupil
Enthusiast
Posts: 715 Joined: Fri Apr 25, 2003 3:56 pm
Post
by Pupil » Mon Feb 14, 2005 12:33 pm
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]
Tranquil
Addict
Posts: 952 Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe
Post
by Tranquil » Mon Feb 14, 2005 12:39 pm
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?
Tranquil
gnozal
PureBasic Expert
Posts: 4229 Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:
Post
by gnozal » Mon Feb 14, 2005 12:44 pm
There are no fixed length strings in Purebasic unlike Powerbasic for example, so we have to use the byte array stuff
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Pupil
Enthusiast
Posts: 715 Joined: Fri Apr 25, 2003 3:56 pm
Post
by Pupil » Mon Feb 14, 2005 12:45 pm
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..
Tranquil
Addict
Posts: 952 Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe
Post
by Tranquil » Mon Feb 14, 2005 1:13 pm
Oh I see! FRED? REQUEST!!
Tranquil
olejr
Enthusiast
Posts: 152 Joined: Sun Jul 11, 2004 7:48 pm
Location: Lillehammer, No(r)way
Contact:
Post
by olejr » Mon Feb 14, 2005 5:10 pm
You are not the first one to request it..