So, I was exploring the user32 functions when I discovered about desktops. I wrote a small program about that. here it is:
Code: Select all
desk = GetThreadDesktop_(GetCurrentThreadId_())
desk2 = CreateDesktop_("newdesktop", #Null, #Null, 0, #GENERIC_ALL, #Null)
SetThreadDesktop_(desk2)
SwitchDesktop_(desk2)
MessageBox_(GetDesktopWindow_(), "I am in a new desktop!", "Desktops", #MB_OK | #MB_ICONERROR)
SetThreadDesktop_(desk)
SwitchDesktop_(desk)
CloseDesktop_(desk2)
ExitProcess_(0)
It works fine as a normal user. However, when I try to launch it as an administrator, the desktop gets created, it gets activated but the message box does not appear. I don't know if it's necessary to mention, but the User Account Control is at its default settings and I am using windows 10. I also tried that on different operating system versions with the User Account Control feature (vista, 7, 8, 8.1, 11) and they all had the same exact problem.
Can someone explain to me what am I doing wrong?