
Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Thanks Mattias
however a new error has occured:
Operator '+' is not defined for types 'System.IntPtr' and 'Integer'.
at - buffer + (sizeof(GetType(WTS_SESSION_INFO)) * index
I can see why this happend, but how to fix it? In sample it was given this
way.
My guess is that with every itteration in for statement the code tryes to
increment the pointer, it fails because it is done by adding an integer.
What should be added to the pointer to find the new pointer of next
WTS_SESSION_INFO structure?
> Nikolay,
>
[quoted text clipped - 6 lines]
>
> Mattias
Mattias Sj?gren - 29 Dec 2004 12:17 GMT
>I can see why this happend, but how to fix it?
You can convert the IntPtr to an Integer with its ToInt32 method. You
can go the other way with the IntPtr constructor taking an Integer.
Since you can't do arithmetic directly on IntPtrs you have to do this
roundtripping. Something like
Dim ptr As Integer = buffer.ToIn32()
Dim wtssiSize As Integer = Marshal.SizeOf(GetType(WTS_SESSION_INFO))
For ...
sessionInfo(index) = Marshal.PtrToStructure(New IntPtr(ptr),
GetType(WTS_SESSION_INFO));
ptr += wtssiSize
Next
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nikolay Petrov - 29 Dec 2004 12:57 GMT
Tnanks Mattias, that works perfectly.
I'll going to post my code in web, once it's done, because i'vs searched
half an year of way to use terminal services APIs.
thanks again