Tech Off Thread

8 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Hosting a *.exe in a windows form

Back to Forum: Tech Off
  • User profile image
    Angus

    OK, I started playing this game, but it is full screen, is there any way I could host the *.exe inside a windows form so that it is not full screen, any help would be fantastic. By the way, I don't particualrly mind on what language is used, so long as it is either Visual C#, Visual C++, or Visual BASIC, and the coding is fairly simple.

    Thanks in advance

    Angus Higgins

  • User profile image
    Stitch 2.0

    I did something like this once, when building an application framework for a tool I wrote.

    Unfortunately, I don't have access to my computer at the moment, since I just moved to Switzerland.

    It was pretty easy, as far as I remember.

    You just had to load the exe into your appdomain, find out which is the entrypoint in the exe and then call that.

    Too bad, I don't have the code at hand....

    As soon as I have it, I'll post it...

  • User profile image
    Angus

    Thanks

    Angus Higgins

  • User profile image
    Stitch 2.0

    Thanks to the omnipresent internet, I have found my framework online. Wink

    I have posted it over here in the Sandbox...

    I hope this helps...

  • User profile image
    W3bbo

    Angus wrote:

    OK, I started playing this game, but it is full screen, is there any way I could host the *.exe inside a windows form so that it is not full screen, any help would be fantastic. By the way, I don't particualrly mind on what language is used, so long as it is either Visual C#, Visual C++, or Visual BASIC, and the coding is fairly simple


    Why not just call Win32 ShellExecute with the "windowed" constant?

  • User profile image
    Sven Groot

    W3bbo wrote:
    Angus wrote:

    OK, I started playing this game, but it is full screen, is there any way I could host the *.exe inside a windows form so that it is not full screen, any help would be fantastic. By the way, I don't particualrly mind on what language is used, so long as it is either Visual C#, Visual C++, or Visual BASIC, and the coding is fairly simple


    Why not just call Win32 ShellExecute with the "windowed" constant?


    It's up to the application to obey that. Even if it's just a normal GDI window, the app can ignore the specified parameter and open a window any way it likes.

    If the app used DirectDraw or Direct3D in exclusive mode, there is no way to get it to run windowed.

  • User profile image
    Angus

    W3bbo wrote:
    Angus wrote:

    OK, I started playing this game, but it is full screen, is there any way I could host the *.exe inside a windows form so that it is not full screen, any help would be fantastic. By the way, I don't particualrly mind on what language is used, so long as it is either Visual C#, Visual C++, or Visual BASIC, and the coding is fairly simple


    Why not just call Win32 ShellExecute with the "windowed" constant?



    How do you do that?

    Angus Higgins

  • User profile image
    W3bbo

    Angus wrote:
    W3bbo wrote:
    Angus wrote:

    OK, I started playing this game, but it is full screen, is there any way I could host the *.exe inside a windows form so that it is not full screen, any help would be fantastic. By the way, I don't particualrly mind on what language is used, so long as it is either Visual C#, Visual C++, or Visual BASIC, and the coding is fairly simple


    Why not just call Win32 ShellExecute with the "windowed" constant?



    How do you do that?

    Angus Higgins


    This is some antiquated VBA code that does it:


    Private Declare Function ShellExecute Lib "Shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

    Const SW_SHOW = 1
    Const SW_SHOWMAXIMIZED = 3

    Sub Run(ByVal Path As String)

    Dim RetVal As Long
    On Error Resume Next
    RetVal = ShellExecute(0, "open", Path, "", GetFolderPathFromFilePath(Path), SW_SHOWMAXIMIZED)

    End Sub

    Function GetFolderPathFromFilePath(ByVal Path As String) As String

    Path = Replace(Path, "/", "\")

    Dim SlashIndex As Integer
    SlashIndex = InStrRev(Path, "\")

    Path = Left(Path, SlashIndex)

    GetFolderPathFromFilePath = Path

    End Function

    You'll want to change "SW_SHOWMAXIMIZED" to the appropriate DWORD value for SW_WINDOWED.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.