Restored from previous forum. Originally posted by Eikeland.
Hi,
I'm calling an DLL and receive a pointer to an array of a structure.
Here is how I do it now, it works, but is it a faster way to do this with out the copy memory function?
/Richard
The Code:
Structure WTS_SERVER_INFO
pServerName.s ; server name
EndStructure
Procedure Test3()
lpBuffer.l
sres.s
Count.l = 0
i.l = 0
p.l
WpInf.WTS_SERVER_INFO
If OpenLibrary(#WTSAPI,"WTSAPI32.DLL")
If CallFunction(#WTSAPI,"WTSEnumerateServersA","VALHALLA",#NULL,1,@lpbuffer,@Count)
p = lpbuffer
For i = 0 To Count -1
CopyMemory(p,WpInf,SizeOf(WTS_SERVER_INFO))
sres = sres + WpInf\pServerName + Chr(10)
p+SizeOf(WTS_SERVER_INFO)
Next
MessageRequester("Test3","Servers: " + Str(Count) + Chr(10) + sres,0)
Else
MessageRequester("Test3","Could not call WTSEnumerateServersA", 0)
EndIf
CloseLibrary(#WTSAPI)
EndIf
Return Arry of Structure
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
El_Choni
Code: Select all
Structure WTS_SERVER_INFO
pServerName.s ; server name
EndStructure
Procedure Test3()
lpBuffer.l
sres.s
Count.l = 0
i.l = 0
p.l
If OpenLibrary(#WTSAPI, "WTSAPI32.DLL")
If CallFunction(#WTSAPI,"WTSEnumerateServersA", "VALHALLA", #NULL,1, @lpbuffer, @Count)
Dim *WpInf.WTS_SERVER_INFO(Count)
*WpInf() = lpbuffer
For i=0 To Count-1
; sres+*WpInf(i)\pServerName+Chr(10) ; This line should work, but it doesn't
sres+PeekS(PeekL(*WpInf()+(i*4)))+Chr(10)
Next
MessageRequester("Test3", "Servers: "+Str(Count)+Chr(10)+sres, 0)
Else
MessageRequester("Test3", "Could not call WTSEnumerateServersA", 0)
EndIf
CloseLibrary(#WTSAPI)
EndIf
EndProcedure