PC Review


Reply
Thread Tools Rate Thread

CreateWindowStation

 
 
Paul
Guest
Posts: n/a
 
      20th Feb 2004
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 :-)


 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      20th Feb 2004
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.
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      22nd Feb 2004
Thanks, I'll give the coding a go this week.

"Mattias Sjögren" <(E-Mail Removed)> wrote in message
news:%23su3Xy%(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      24th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:%23su3Xy%(E-Mail Removed)...
> 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.



 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      24th Feb 2004
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.
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      25th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:%23e3pAGy%(E-Mail Removed)...

> 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.



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
P/Invoke CreateWindowStation and protected memory Bill V. Microsoft C# .NET 1 7th Jun 2008 11:21 AM
CreateWindowStation Paul Microsoft Dot NET Framework 5 25th Feb 2004 11:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:46 AM.