Groups | Blog | Home
all groups > dotnet interop > april 2004 >

dotnet interop : WTSSetUserConfig help. Urgent!!!


Thomas Nygaard
4/26/2004 2:11:03 AM
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
Thomas Nygaard
4/26/2004 4:36:03 AM
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

Mattias Sjögren
4/26/2004 12:19:33 PM

[quoted text, click to view]

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

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
AddThis Social Bookmark Button