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