Solved

WTSQueryUserToken

Posted on 2006-07-06
2
1,165 Views
Last Modified: 2008-03-10
Hello,

   I am trying to use the WTSQueryUserToken function.  Does this declaration look correct?


'BOOL WTSQueryUserToken(
'     ULONG SessionId,
'     PHANDLE phToken
');

Declare Auto Function WTSQueryUserToken Lib "Wtsapi32.dll" (ByVal SessionId As Integer, ByRef phToken As IntPtr) As Boolean

 Declare Unicode Function GetLastError Lib "kernel32" () As Int32

Sub Test()

Try
            Dim hToken As IntPtr

            If WTSQueryUserToken(1, hToken) Then
                LogErrorData(GetLastError)
            Else
                LogErrorData("WTSQueryUserToken: " & GetLastError)
            End If

Catch ex as Exception
     Err.Raise ex.message
End Try
End Sub
0
Comment
Question by:pyrokin
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17055254
ULONG = UInt32 = UnmanagedType.U4

System.Runtime.InteropServices.MarshalAs attribute:

   Private Declare Auto Function WTSQueryUserToken Lib "Wtsapi32.dll" (<MarshalAs(UnmanagedType.U4)> ByVal SessionId As Integer, ByRef phToken As IntPtr) As Boolean

Bob
0
 
LVL 1

Author Comment

by:pyrokin
ID: 17055298
Thanks so much.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now