473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

CreateWindowStation

Does anyone have the vb code to use this function I have found the API
import for this but not the layout of the structures that need to be passed
to the routine. I'm also looking for vb versions of

- CreateWindowStation
- SetProcessWindowStation
- CreateDesktop
- SetThreadDesktop
- GetGUIThreadInfo

Any help would be great. VB.NET please.

Thanks
P :-)
Nov 20 '05 #1
5 4258
Paul,

Try this

Structure RECT
Public left, top, right, bottom As Integer
End Structure

Structure GUITHREADINFO
Public cbSize As Integer
Public flags As Integer
Public hwndActive As IntPtr
Public hwndFocus As IntPtr
Public hwndCapture As IntPtr
Public hwndMenuOwner As IntPtr
Public hwndMoveSize As IntPtr
Public hwndCaret As IntPtr
Public rcCaret As RECT
End Structure

Structure SECURITY_ATTRIBUTES
Public nLength As Integer
Public lpSecurityDescriptor As IntPtr
Public bInheritHandle As Boolean
End Strucure

Declare Auto Function CreateWindowStation Lib "user32.dll" (lpwinsta
As String, dwFlags As Integer, dwDesiredAccess As Integer, lpsa As
IntPtr) As IntPtr

Declare Function SetProcessWindowStation Lib "user32.dll" (hWinSta As
IntPtr) As Boolean

Declare Auto Function CreateDesktop Lib "user32.dll" (lpszDesktop As
String, lpszDevice As IntPtr, pDevmode As IntPtr, dwFlags As Integer,
dwDesiredAccess As Integer, lpsa As IntPtr) As IntPtr

Declare Function SetThreadDesktop Lib "user32.dll" (hDesktop As
IntPtr) As Boolean

Declare Function GetGUIThreadInfo Lib "user32.dll" (idThread As
Integer, ByRef lpgui As GUITHREADINFO) As Boolean

For CreateWindowStation and CreateDesktop, you can change the lpsa
parameter to ByRef lpsa As SECURITY_ATTRIBUTES if you actually want to
specify it (not pass NULL).

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #2
Thanks, I'll give the coding a go this week.

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Paul,

Try this

Structure RECT
Public left, top, right, bottom As Integer
End Structure

Structure GUITHREADINFO
Public cbSize As Integer
Public flags As Integer
Public hwndActive As IntPtr
Public hwndFocus As IntPtr
Public hwndCapture As IntPtr
Public hwndMenuOwner As IntPtr
Public hwndMoveSize As IntPtr
Public hwndCaret As IntPtr
Public rcCaret As RECT
End Structure

Structure SECURITY_ATTRIBUTES
Public nLength As Integer
Public lpSecurityDescriptor As IntPtr
Public bInheritHandle As Boolean
End Strucure

Declare Auto Function CreateWindowStation Lib "user32.dll" (lpwinsta
As String, dwFlags As Integer, dwDesiredAccess As Integer, lpsa As
IntPtr) As IntPtr

Declare Function SetProcessWindowStation Lib "user32.dll" (hWinSta As
IntPtr) As Boolean

Declare Auto Function CreateDesktop Lib "user32.dll" (lpszDesktop As
String, lpszDevice As IntPtr, pDevmode As IntPtr, dwFlags As Integer,
dwDesiredAccess As Integer, lpsa As IntPtr) As IntPtr

Declare Function SetThreadDesktop Lib "user32.dll" (hDesktop As
IntPtr) As Boolean

Declare Function GetGUIThreadInfo Lib "user32.dll" (idThread As
Integer, ByRef lpgui As GUITHREADINFO) As Boolean

For CreateWindowStation and CreateDesktop, you can change the lpsa
parameter to ByRef lpsa As SECURITY_ATTRIBUTES if you actually want to
specify it (not pass NULL).

Mattias

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

Nov 20 '05 #3
Hi.

The codes works great I can now create a new desktop and switch to this,
however the desktop shows blank with no icons and when I try to use the
CreateProcess API on open a new application on the desktop it says there was
an application fault. If I try CreateProceesWithLogon nothing happens. Any
ideas ?

Thanks
Paul

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Paul,

Try this

Structure RECT
Public left, top, right, bottom As Integer
End Structure

Structure GUITHREADINFO
Public cbSize As Integer
Public flags As Integer
Public hwndActive As IntPtr
Public hwndFocus As IntPtr
Public hwndCapture As IntPtr
Public hwndMenuOwner As IntPtr
Public hwndMoveSize As IntPtr
Public hwndCaret As IntPtr
Public rcCaret As RECT
End Structure

Structure SECURITY_ATTRIBUTES
Public nLength As Integer
Public lpSecurityDescriptor As IntPtr
Public bInheritHandle As Boolean
End Strucure

Declare Auto Function CreateWindowStation Lib "user32.dll" (lpwinsta
As String, dwFlags As Integer, dwDesiredAccess As Integer, lpsa As
IntPtr) As IntPtr

Declare Function SetProcessWindowStation Lib "user32.dll" (hWinSta As
IntPtr) As Boolean

Declare Auto Function CreateDesktop Lib "user32.dll" (lpszDesktop As
String, lpszDevice As IntPtr, pDevmode As IntPtr, dwFlags As Integer,
dwDesiredAccess As Integer, lpsa As IntPtr) As IntPtr

Declare Function SetThreadDesktop Lib "user32.dll" (hDesktop As
IntPtr) As Boolean

Declare Function GetGUIThreadInfo Lib "user32.dll" (idThread As
Integer, ByRef lpgui As GUITHREADINFO) As Boolean

For CreateWindowStation and CreateDesktop, you can change the lpsa
parameter to ByRef lpsa As SECURITY_ATTRIBUTES if you actually want to
specify it (not pass NULL).

Mattias

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

Nov 20 '05 #4
Paul,
Any ideas ?


No sorry, I don't have enough experience with these APIs so I'd have
to play with it some more before attempting to guess what may be
wrong.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #5
Hi.

Write I've managed to get a new desktop and launch the process on the
desktop, the problem I'm having now is finding the window handle to the
newly spawned application. I've tried numerious examples of FindWindow etc
and it always returns 0. I think the problem is with the
SetDesktopThread(myNewDesktop) as this returns the following error

"The Following Windows Error Occured with SetThreadDesktop: 170 - The
requested resource is in use"

So I'm guessing this is why I cant find the window as the process thread is
not talking to the newly created desktop ?
Any ideas ?

PS: Sorted out the problem with the SwitchDesktop, as this can only be
called for the interactive window station so this works on WinSta0 and not
my newly created Window Station.

Thanks
Paul

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Paul,
Any ideas ?


No sorry, I don't have enough experience with these APIs so I'd have
to play with it some more before attempting to guess what may be
wrong.

Mattias

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

Nov 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: sean | last post by:
Hi, I have a C# Winform application. I'm trying to run the application under a custom window station and desktop. First, I have an original (non-dotnet) process that does a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.