Hi, I'm trying to get something done in vb.net which I've already done in vb6 (lost the code): creating a new desktop and switching to it. I have a C# code (written by somebody else, got it from http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=5277&lngWId=10) which works very well. I've tried to manually convert the code to vb.net, but everytime I run the app, I get an error of which I cannot find the source. Somehow I'm doing something wrong, but I can't tell what.
The C# code is:
I've manually converted this to the following vb.net code:
Never mind the API calls, the're all in place
The System.IO.File.WriteAllText line is not important to me...
Can somebody tell me what I'm doing wrong?
Thank you
The C# code is:
VB.NET:
static void CreateNewDesktop()
{
DesktopThreadID = GetThreadDesktop(GetCurrentThreadId());
DesktopInputID = OpenInputDesktop(0, false, DESKTOP_SWITCHDESKTOP);
DesktopHandle = CreateDesktop(DesktopName, "", 0, 0, GENERIC_ALL, 0);
if (DesktopHandle != 0)
{
SetThreadDesktop(DesktopHandle);
SwitchDesktop(DesktopHandle);
System.IO.File.WriteAllText(Application.StartupPath + "\\Desktop.Dif", DesktopInputID.ToString() + "|" + DesktopThreadID.ToString() + "|" + DesktopHandle.ToString());
}
}
I've manually converted this to the following vb.net code:
VB.NET:
Public Function Create(ByVal Name As String, Optional ByVal AutoSwitch As Boolean = False) As Integer
DesktopThreadID = GetThreadDesktop(GetCurrentThreadId)
DesktopInputID = OpenInputDesktop(0, False, DESKTOP_SWITCHDESKTOP)
DesktopHandle = CreateDesktop(Name, "", 0, 0, GENERIC_ALL, 0)
If DesktopHandle <> 0 Then
SetThreadDesktop(DesktopHandle)
SwitchDesktop(DesktopHandle)
Return 1
End If
End Function
Never mind the API calls, the're all in place
The System.IO.File.WriteAllText line is not important to me...
Can somebody tell me what I'm doing wrong?
Thank you