Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / April 2004

Tip: Looking for answers? Try searching our database.

WTSSetUserConfig help. Urgent!!!

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas Nygaard - 26 Apr 2004 10:11 GMT
I am trying to call the WTSSetUserConfig function from VB.Net but it does not seem to work. I always get the error: "The user does not exist". But when I am using the function WTSQueryUserConfig to get the information i works ok.

My code is as follows

Const WTSUserConfigTerminalServerProfilePath = &HF

Private Declare Auto Function WTSSetUserConfig Lib "wtsapi32"
         Alias "WTSSetUserConfigA" (ByVal pServerName As String,
         ByVal pUserName As String, ByVal WTSConfigClass As Integer,
         ByVal pBuffer As String, ByRef pBytes As Integer) As Boolea

sub test(
       Dim buffer As Strin
       Dim pBytes As Intege
       Dim server As String = "\\server
       Dim user As String = "user
       Dim res As Intege
       buffer = "\\server\profile
       pBytes = Len(buffer
       res = WTSSetUserConfig(server, user, WTSUserConfigTerminalServerProfilePath, buffer, pBytes
       If res > 0 The
           MsgBox(buffer
       Els
           Throw New System.ComponentModel.Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error()
       End I
end su
Mattias Sj?gren - 26 Apr 2004 11:19 GMT
> Private Declare Auto Function WTSSetUserConfig Lib "wtsapi32" _
>          Alias "WTSSetUserConfigA"

Don't mix the Auto modifier with an explicit Alias specifying the ANSI
version of the function. I suggest you remove the Alias clause.

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Thomas Nygaard - 26 Apr 2004 12:36 GMT
Hi Mattias
thanks a lot it worked. I changed the code to

   Private Declare Ansi Function WTSSetUserConfig Lib "wtsapi32"
          Alias "WTSSetUserConfigA" (ByVal pServerName As String,
         ByVal pUserName As String, ByVal WTSConfigClass As Integer,
         ByVal pBuffer As String, ByRef pBytes As Integer) As Boolea

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.