Page 1 of 2 12 LastLast
Results 1 to 40 of 49

Thread: If I wanted to have a Windows PC that only ran VB6 programs...

  1. #1

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    If I wanted to have a Windows PC that only ran VB6 programs...

    If I wanted to have a Windows PC that I wanted to demonstrate only VB6 programs then I'd probably have a limited set of tools and utilities, is this true?

    Would I be able to create a functioning and useful system that had all the tools needed for a modern PC user? I admit a VB6 based browser might be a difficult proposition and asking too much. However, for some of the other tools? It might be possible to switch to something made solely in VB6.

    So that's my question, could you?

    "Would you" is another question altogether which we don't need to have answered, because of course you wouldn't - so at the moment I'm only asking "could you?".

    For example: There is XYplorer, the VB6 alternative to the Windows File Explorer.



    Winstep Nexus is a Windows dock alternative, written in VB5 which I reckon counts just as well



    So, are there other useful VB6 alternatives to the sort of tools you would typically find on a PC?

    Let's start with something simple, an editor. Is there an editor written in VB6?
    Last edited by yereverluvinuncleber; Jul 14th, 2021 at 08:03 AM. Reason: Edited to make it clear what the brief really is

  2. #2
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,837

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    There is plenty of free VB 6.0 projects you could look at:

    https://www.sourcecodester.com/visual-basic

    https://www.freeprojectz.com/visual-basic-projects
    Please remember next time...elections matter!

  3. #3
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Well I would say that if you wanted the pc setup to where a novice user could only run specific programs written in VB6 then that would probably be possible though a lot of work. If the user knows a few things about PCs then no not possible as there are many ways they could get around whatever you were to do.

  4. #4

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by TysonLPrice View Post
    There is plenty of free VB 6.0 projects you could look at:
    Yes, I know and thankyou, I am just looking for specific suggestions at the moment. It is more of a speculative question, I have an on old spec NOS laptop for running XP and I thought I'd try to use it to showcase a few VB6 apps. Recommendations for useful apps taken.

  5. #5

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by DataMiser View Post
    Well I would say that if you wanted the pc setup to where a novice user could only run specific programs
    No, not looking for that, just looking for good recommendations of VB6 equivalents to everyday programs, like the ones listed above in the OP. Thankyou anyway.

  6. #6

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    There is also PhotoDemon



    A free, portable, open-source photo editor for Microsoft Windows.

    That would make a possible replacement for Photoshop.

  7. #7

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    We have Dragokas "HiJackThis Fork" which is a development continuation of the "Trend Micro HiJackThis" tool to replace my usual A/V tool.



    Dragokas comes up with some interesting stuff so I'd like to assume it is a good av tool...

  8. #8

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    I'll make a list at the end of the tools available and I'll try to build that XP system with only VB6 utilities that I have been recommended to use. I need to find my XP Pro discs (wife has tidied them).

  9. #9

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by TysonLPrice View Post
    Tyson, that link was a good suggestion!

  10. #10
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Yereverluvinuncleber O Atube Catcher to download videos, including from youtube, it was developed in VB6 and I use it and recommend it.

  11. #11

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by Episcopal View Post
    Yereverluvinuncleber O Atube Catcher to download videos, including from youtube, it was developed in VB6 and I use it and recommend it.

    Bloody ~Hell! Episcopal, that is a good suggestion. I have been looking for a decent Youtube downloader for a while now having tried several and this one is written in VB6! Impressed!



    ...and your own editor? Is that one that could replace, say, notepad?
    Last edited by yereverluvinuncleber; Jul 14th, 2021 at 08:05 AM. Reason: Added screenshot of Atube Catcher

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    i am sure at some time (several years ago) i worked with a vb6 program for a internet cafe that locked the entire computer to a limited set of programs and timed out when the tariff expired
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  13. #13

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by westconn1 View Post
    a vb6 program ... that locked the entire computer to a limited set of programs
    Sounds a great program but... in this case the limitation is artificial and policed by me alone, in that I am only going to load VB6 programs on the machine.

    The idea is to find a variety of VB6 programs that can do all the tasks that are needed, not to prevent anyone from using anything other than VB6... That would be stranger still.

  14. #14
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by yereverluvinuncleber View Post
    ...and your own editor? Is that one that could replace, say, notepad?
    No, no. I just mentioned Atube because it was developed in VB6. It's not my authorship.

  15. #15
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by yereverluvinuncleber View Post
    There is also PhotoDemon



    A free, portable, open-source photo editor for Microsoft Windows.

    That would make a possible replacement for Photoshop.
    Incredible ...

  16. #16
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    This is my Correspondence Editor. This screen is from 2009 on Windows XP. It's in Portuguese. I'm currently refactoring the code, because in Runtime mode it's a bit slow when the text reaches 600 pages. I'm changing some algorithm to increase performance, because at the time I had less experience.


    What gave me the most work was working with editing tables...

    Menu table: Insert table, row or column, before or after.

    Delete Menu: Delete Table, Row or Column.

    Select: Select table, row or column.

    Menu Convert text to table, and table to text.

    Transform Menu: Row to Column, Column to Row.

    Classification menu: Ascending or descending.

    Rotate Menu: Rotate the table clockwise or counterclockwise, Converting Row to Column...

    Alignment Menu: Centers or not the table.

    Adjust Menu: Adjust the table, row or column, according to the size of its content.
    Attached Images Attached Images  
    Last edited by Episcopal; Jul 17th, 2021 at 06:26 PM.

  17. #17

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Episscopal, It looks to be grown-up, mature and competent software by just rating the UI. Where can I find a copy? I will need one for this XP laptop that I am going to build.

    IF you had to compare Correspondence Editor in functionality to another Windows tool which would it be? I have heard you previously state that is has the functionality of notepad but slightly less functionality than Wordpad? Would that be true?

    I'd love to try it.

  18. #18
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by yereverluvinuncleber View Post
    Episscopal, It looks to be grown-up, mature and competent software by just rating the UI. Where can I find a copy? I will need one for this XP laptop that I am going to build.

    IF you had to compare Correspondence Editor in functionality to another Windows tool which would it be? I have heard you previously state that is has the functionality of notepad but slightly less functionality than Wordpad? Would that be true?

    I'd love to try it.
    No, no....it goes beyond wordpad.....this application I developed is lost....I don't even know where the source code is....I just saved the component source for text editor. ...

    remember this image?
    https://www.vbforums.com/showthread....=1#post5512032

    I have the text editor usercontrol source, but the text editing application will have to make another one.... I'm already finalizing a widget for an Ecclesiastical Management software, where I'm going to embed this correspondence editor. When I finish it I will test it on Win11.

  19. #19
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Actually I work in programming only in my spare time ..... sometimes it takes me to finish my applications.

    This is a part of a 42 usercontrol I developed, for the Ecclesiastical Manager. This one by the way has a bluish theme....but I want to make the theme dark too...
    Attached Images Attached Images  

  20. #20
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Press left-Alt/left-Shift/PrintScreen to quickly go to High Contrast. Watch your program's UI fall apart.

    Press left-Alt/left-Shift/PrintScreen again to quickly go back.

    Don't screw around with fruity colors. If your program isn't usable in High Contrast mode it is broken.

  21. #21

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by Episcopal View Post
    this application I developed is lost...I don't even know where the source code is.
    Damn! so we cannot try it and it is no use for my laptop build. What happened to the program, how did you lose it? Find it man!

  22. #22
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Well, what I really care about is the usercontrol that contains the WordProcessor source, the Text Editor that will manipulate it, I'll make another one, and with much more resources...

    The truth is that I still have the source recorded on a cd, but as I formatted my machine several times in these 13 years, I had to record it on the cd. The problem is locating the cd among several ...

  23. #23
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by dilettante View Post
    Press left-Alt/left-Shift/PrintScreen to quickly go to High Contrast. Watch your program's UI fall apart.

    Press left-Alt/left-Shift/PrintScreen again to quickly go back.

    Don't screw around with fruity colors. If your program isn't usable in High Contrast mode it is broken.
    Dilettante, are you talking about my printscreen?

  24. #24

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    We could use NeumoPlayer as the VB6 Media player replacement.

    It is rather 'modern' looking too which suits current tastes.





  25. #25

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by Episcopal View Post
    The problem is locating the cd among several ...
    Find that CD! It is worth doing. It is your code, GITHUB exists as a place for this sort of storage.

  26. #26
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,176

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by Episcopal View Post
    Yereverluvinuncleber O Atube Catcher to download videos, including from youtube, it was developed in VB6 and I use it and recommend it.
    I second a vote of 'good work' for whoever created this program (Atube Catcher). I downloaded it today and am impressed as well as to its capabilities, all in one easy-to-use app.

    Thanks for posting.
    Sam I am (as well as Confused at times).

  27. #27

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by SamOscarBrown View Post
    I second a vote of 'good work' for whoever created this program (Atube Catcher).
    I am using it too! One of the easiest to use so far.

  28. #28

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Come on the Old Guard! Some of you must have come across VB6 programs that are actually usable in your years here...

  29. #29

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    As we have to have games, here is a shoot 'em up of the old school type, by the name of "Be Quits!". This was posted here a couple of years ago and is a tour de force in VB6 and DirectX programming that shows what the old dog can do.





    I have already installed and tried this one and I have to say, it is more difficult than Quake I but the gameplay is similar. It will need a cpu at least as good as a 3.0ghz system and I imagine a decentish GPU might help. The game runs on my old Dell laptop but not quite as quick as I'd like. My old Dell is quick in the CPU department but the GPU is the lowest of the low, it is, after all a business machine.

    I just checked and this game runs very well on a laptop/desktop with a decent GPU, luckily the target system I have planned to use has a decent GPU and so DirectX9 acceleration is available.
    Last edited by yereverluvinuncleber; Jul 28th, 2021 at 06:58 AM. Reason: Added directX testing on a GPU

  30. #30

  31. #31

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    I love your music composer Trick but I am unsure as to whether it has a place on a 'normal' desktop. I have never come across a music generator on anyone's computer before! Nevertheless, I think it is incredibly clever and has a great UI. It is more of a niche product but an amazing one. Do you have any other completed programs that a desktop user would use in his every day normal life? Non-programming utilities I mean, of course as you have dozens of advanced programming utilities and add-ons.

  32. #32

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    No, we'll have it, regardless as to whether anyone would have it or not, it is fantastic.

  33. #33
    Lively Member
    Join Date
    Nov 2020
    Posts
    67

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Here a lot of programs
    http://vb6awards.blogspot.com/2021/

  34. #34
    Fanatic Member Episcopal's Avatar
    Join Date
    Mar 2019
    Location
    Brazil
    Posts
    547

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by LeoFar View Post
    I had already forgotten about this blog. Thanks for posting.

  35. #35

    Thread Starter
    PowerPoster yereverluvinuncleber's Avatar
    Join Date
    Feb 2014
    Location
    Norfolk UK (inbred)
    Posts
    2,251

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by LeoFar View Post
    Yes, Leo, I have been trawling that blog already.

  36. #36
    PowerPoster
    Join Date
    Aug 2010
    Location
    Canada
    Posts
    2,452

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    I'm a bit late to the party on this one, but just wanted to "second" or "third" the recommendation for PhotoDemon. It's a great program written by a great guy. If you want to support open source VB6 development I recommend heading over to Tanner's Patreon page to pitch in. I've been kicking in a few bucks a month for over a year, and it's a small price to pay for some very useful software.

  37. #37
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    OP - I would start with a secure desktop that has been initiated from a Window Station. That way it can even be set as an alternate boot shell on Windows 10 Enterprise and Education, otherwise run side-by-side with Windows. The newly created desktop is clear of any Windows 10 clutter according to an inspection with SPY++. A custom taskbar, background wallpaper, and start menu fill the empty desktop. All have been made with VB6, but the source code is not included on my Github, exe's only.


  38. #38
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by TTn View Post
    OP - I would start with a secure desktop that has been initiated from a Window Station. That way it can even be set as an alternate boot shell on Windows 10 Enterprise and Education, otherwise run side-by-side with Windows. The newly created desktop is clear of any Windows 10 clutter according to an inspection with SPY++. A custom taskbar, background wallpaper, and start menu fill the empty desktop. All have been made with VB6, but the source code is not included on my Github, exe's only.

    That impressive. I never knew you could do that with Window Stations. I have some VB.Net code lying around that works with Window Stations but I've only ever used it for capturing the screen of whatever desktop session is the was console session, which basically means I can capture whatever the user sees, even WinLogon.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  39. #39
    Fanatic Member TTn's Avatar
    Join Date
    Jul 2004
    Posts
    685

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by Niya View Post
    That impressive. I never knew you could do that with Window Stations. I have some VB.Net code lying around that works with Window Stations but I've only ever used it for capturing the screen of whatever desktop session is the was console session, which basically means I can capture whatever the user sees, even WinLogon.
    I don't think you can see another desktop without a Windows Service or by registering your application as an accessibility app in the registry/ease of access. If you can find your code, try it out and let me know. I doubt it.

  40. #40
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,600

    Re: If I wanted to have a Windows PC that only ran VB6 programs...

    Quote Originally Posted by TTn View Post
    I don't think you can see another desktop without a Windows Service or by registering your application as an accessibility app in the registry/ease of access. If you can find your code, try it out and let me know. I doubt it.
    It is actually a Windows Service that runs under the LocalSystem account which I believe is the most powerful account on a Windows system, even more powerful than Administrator accounts. It's used as part of a system I created to implement my own home grown version of Team Viewer. One of the problems I ran into early in it's design was not being able to screen capture and transmit input to and from the WinLogon desktop. I had to dive into the world of Window Stations and Desktops to implement that functionality. Once I got it, I never really explored what other possiblities there were with these series of APIs. Here is a small piece of code I used to capture the screen of the console session:-
    Code:
    Public Class ScreenCapture
    
        Private Shared gshr_objSync As New Object
    
        Public Shared Function GetScreenshot() As Bitmap
    
            'Makes this method threadsafe. Multiple threads can call it at the same time and it would be ordered.
            SyncLock gshr_objSync
    
                Dim windowStation As Win32.SafeWindowStationHandle = Nothing
                Dim originalWindowStation As Win32.SafeWindowStationHandle = Nothing
                Dim originalDesktop As IntPtr = IntPtr.Zero
    
                Dim inputdesktopHdc As IntPtr
                Dim inputDesktopHwnd As IntPtr
    
                Dim ptrInputDesktop As IntPtr = IntPtr.Zero
                Dim bmp As Bitmap
    
                windowStation = Win32.OpenWindowStation("WinSta0", False, Win32.ACCESS_MASK.GENERIC_ALL)
    
                Try
                    If windowStation.IsInvalid Then
                        Throw New ScreenCaptureException("Failed to open window station", ScreenCaptureErrorCodes.FailedToOpenWinSta)
    
                    Else
                        originalWindowStation = Win32.GetProcessWindowStation()
                        If originalWindowStation.IsInvalid Then
                            Throw New ScreenCaptureException("Failed to get process window station", ScreenCaptureErrorCodes.FailedToGetProcWinSta)
                        Else
    
                            If Not Win32.SetProcessWindowStation(windowStation) Then
                                Throw New ScreenCaptureException("Failed to change current process's window station", ScreenCaptureErrorCodes.FailedToChangeWinSta)
                            Else
    
                                ptrInputDesktop = Win32.OpenInputDesktop(0, False, Win32.ACCESS_MASK.GENERIC_ALL)
    
                                If ptrInputDesktop = IntPtr.Zero Then
                                    Throw New ScreenCaptureException("Failed to open input desktop", ScreenCaptureErrorCodes.FailedToOpenInputDskTop)
                                Else
                                    originalDesktop = Win32.GetThreadDesktop(Win32.GetCurrentThreadId())
    
                                    If originalDesktop = IntPtr.Zero Then
                                        Throw New ScreenCaptureException("Unable to get original desktop", ScreenCaptureErrorCodes.FailedToGetOriginalDesktop)
                                    Else
                                        If Not Win32.SetThreadDesktop(ptrInputDesktop) Then
                                            Throw New ScreenCaptureException("Unable to change the current threads desktop", ScreenCaptureErrorCodes.FailedToChangeCurrentThreadDskTop)
                                        Else
                                            inputDesktopHwnd = Win32.GetDesktopWindow()
    
                                            If inputDesktopHwnd <> IntPtr.Zero Then
                                                inputdesktopHdc = Win32.GetDC(inputDesktopHwnd)
    
                                                If inputdesktopHdc = IntPtr.Zero Then
                                                    Throw New ScreenCaptureException("Unable to get desktop DC", ScreenCaptureErrorCodes.FailedToAcquireDskTopDC)
                                                Else
    
                                                    Try
                                                        bmp = CopyDC(inputdesktopHdc, 0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
                                                        Return bmp
                                                    Catch ex As Exception
    
                                                        Throw New ScreenCaptureException("Failed to copy device context", ScreenCaptureErrorCodes.CopyDCFailed, ex)
                                                    End Try
    
    
                                                End If
    
                                            End If
    
                                        End If
    
                                    End If
    
                                End If
    
                            End If
    
                        End If
    
                    End If
    
                Finally
    
                    Win32.ReleaseDC(inputDesktopHwnd, inputdesktopHdc)
                    Win32.CloseDesktop(ptrInputDesktop)
                    Win32.SetThreadDesktop(originalDesktop)
                    Win32.SetProcessWindowStation(originalWindowStation)
    
    
                    windowStation.Close()
    
                End Try
    
                Return Nothing
            End SyncLock
        End Function
    
        Private Shared Function CopyDC(ByVal hdc As IntPtr, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Bitmap
    
            Dim memDC As IntPtr = Win32.CreateCompatibleDC(hdc)
            Dim memhBitmap As IntPtr = Win32.CreateCompatibleBitmap(hdc, width, height)
            Dim stockBitmap As IntPtr = Win32.SelectObject(memDC, memhBitmap)
    
            Try
    
                If Not Win32.StretchBlt(memDC, x, y, width, height, hdc, x, y, width, height, Win32.TernaryRasterOperations.SRCCOPY) Then
                    Throw New Exception("Failed to copy device context")
                Else
                    memhBitmap = Win32.SelectObject(memDC, stockBitmap)
    
                    Dim returnBitmap As Bitmap = Bitmap.FromHbitmap(memhBitmap)
    
                    Return returnBitmap
                End If
    
            Finally
                Win32.DeleteObject(memhBitmap)
                Win32.DeleteDC(memDC)
            End Try
    
    
    
        End Function
    
    
    End Class
    Here's another important piece of code that allows me to execute any function as if it were being executed in the console session itself.
    Code:
    Private Shared Sub ExecuteOnInputDesktop(ByVal proc As Action)
            Dim windowStation As Win32.SafeWindowStationHandle = Nothing
            Dim originalWindowStation As Win32.SafeWindowStationHandle = Nothing
            Dim originalDesktop As IntPtr = IntPtr.Zero
    
            'Dim inputdesktopHdc As IntPtr
            'Dim inputDesktopHwnd As IntPtr
    
            Dim ptrInputDesktop As IntPtr = IntPtr.Zero
    
            'Open the interactive Window Station of the current session. This is the only Window Station that can
            'contain Desktops to be displayed.
            windowStation = Win32.OpenWindowStation("WinSta0", False, Win32.ACCESS_MASK.GENERIC_ALL)
    
            Try
                If windowStation.IsInvalid Then
                    Throw New WindowsMessagePlayerException("Failed to open window station", ScreenCaptureErrorCodes.FailedToOpenWinSta)
    
                Else
                    originalWindowStation = Win32.GetProcessWindowStation()
                    If originalWindowStation.IsInvalid Then
                        Throw New WindowsMessagePlayerException("Failed to get process window station", ScreenCaptureErrorCodes.FailedToGetProcWinSta)
                    Else
    
                        If Not Win32.SetProcessWindowStation(windowStation) Then
                            Throw New WindowsMessagePlayerException("Failed to change current process's window station", ScreenCaptureErrorCodes.FailedToChangeWinSta)
                        Else
    
                            'Open the Input Desktop. The Input Desktop is the one currently being
                            'displayed and used by the user. There can only be one at a time for obvious reasons.
                            ptrInputDesktop = Win32.OpenInputDesktop(0, False, Win32.ACCESS_MASK.GENERIC_ALL)
    
                            If ptrInputDesktop = IntPtr.Zero Then
                                Throw New WindowsMessagePlayerException("Failed to open input desktop", ScreenCaptureErrorCodes.FailedToOpenInputDskTop)
                            Else
                                originalDesktop = Win32.GetThreadDesktop(Win32.GetCurrentThreadId())
    
                                If originalDesktop = IntPtr.Zero Then
                                    Throw New WindowsMessagePlayerException("Unable to get original desktop", ScreenCaptureErrorCodes.FailedToGetOriginalDesktop)
                                Else
                                    If Not Win32.SetThreadDesktop(ptrInputDesktop) Then
                                        Throw New WindowsMessagePlayerException("Unable to change the current threads desktop", ScreenCaptureErrorCodes.FailedToChangeCurrentThreadDskTop)
                                    Else
                                        proc.Invoke()
                                    End If
    
                                End If
    
                            End If
    
                        End If
    
                    End If
    
                End If
    
            Finally
    
                'Win32.ReleaseDC(inputDesktopHwnd, inputdesktopHdc)
                Win32.CloseDesktop(ptrInputDesktop)
                Win32.SetThreadDesktop(originalDesktop)
                Win32.SetProcessWindowStation(originalWindowStation)
    
    
                windowStation.Close()
    
            End Try
    
        End Sub
    A lot of API functions like SendInput are sensitive to what Desktop/WindowStation/Session they are called from. The above function can in a sense project the function call from one session like where a Windows Service is executed to the session/Window Station/Desktop of the currently logged in user or even in WinLogon(no user logged in).
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width