Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pointer Chaos :)
Message
From
30/07/2001 16:52:23
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Pointer Chaos :)
Miscellaneous
Thread ID:
00537469
Message ID:
00537469
Views:
74
Hello,

now i have managed it to build the structure with CLSHeap thx to Larry Miller

but to parse the values back is even harder :(

here is the code .. if someone can find errors in it please let me now ..
i think i don't see the forest cause of all the trees ... or similar :)

in VFP:

oID = NumToLong(1)
oHostName = NumToLong(oHLServer.AllocString(""))
oAddress = NumToLong(oHLServer.AllocString(this.parent.txtIPAddr.value))
oIPAddr = NumToLong(0)
oPort = NumToWord(val(this.parent.txtPort.value))
oServerName = NumToLong(oHLServer.AllocString(""))
oMapName = NumToLong(oHLServer.AllocString(""))
oGameDir = NumToLong(oHLServer.AllocString(""))
oGame = NumToLong(oHLServer.AllocString(""))
oNumPlayers = NumToLong(0)
oMaxPlayers = NumToLong(0)
oProtocolVer = NumToLong(0)
oSvType = NumToLong(oHLServer.AllocString(""))
oSvOs = NumToLong(oHLServer.AllocString(""))

** Create Structure as a String variable
oHLStruct = oID + oHostName + oAddress + oIPAddr + oPort + oServerName + ;
oMapName + oGameDir + oGame + oNumPlayers + oMaxPlayers + oProtocolVer + ;
oSvType + oSvOs

** Allocate a block of memory with size of needed lenght
oHLPointer = oHLServer.Alloc(LEN(oHLStruct))
oHLServer.CopyTo (oHLPointer, oHLStruct)

oHLInfo = HLRequestDetail (oHLPointer)

** return 0 = function produced no error
if oHLInfo = 0

oHostName = GetMemString(LongToNum(SUBSTR(oHLStruct,5,4)))
oServerName = GetMemString(LongToNum(SUBSTR(oHLStruct,19,4)))
oMapName = GetMemString(LongToNum(SUBSTR(oHLStruct,23,4)))
oGameDir = GetMemString(LongToNum(SUBSTR(oHLStruct,27,4)))
oGame = GetMemString(LongToNum(SUBSTR(oHLStruct,33,4)))
oNumPlayers = LongToNum(GetMem(oHLPointer+37,4))
oMaxPlayers = LongToNum(GetMem(oHLPointer+41,4))
oProtocolVer = LongToNum(GetMem(oHLPointer+45,4))
oSvType = GetMemString(LongToNum(SUBSTR(oHLStruct,49,4)))
oSvOs = GetMemString(LongToNum(SUBSTR(oHLStruct,53,4)))

else
** fill with default values ...
endif

** Release the allocated Memory
oHLServer.DeAlloc(oHLPointer)
oHLServer.Destroy()

I get a memory error from the DLL, so i think i must have done something wrong
in the structure initialization.
but i have no clue what it is ..

and do i have to alloc the strings with more characters?
or doesn't it matter how "big" they are? (the dll writes to them)
maybe the Dll can't write to them 'cause they are allocetd to small ..
i don't know the behaviour of pointers

BIG THX

Christian Ehlscheid
Next
Reply
Map
View

Click here to load this message in the networking platform