Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > Platform/API C++

Reply
 
LinkBack Thread Tools Display Modes
Old 07-24-2005, 11:57 AM   #1 (permalink)
Spiderman_gtp
Registered User
 
Join Date: Jul 2005
Posts: 2
Spiderman_gtp is on a distinguished road
Running Applications inside Applications inplace

Running Borland C++ and Visual C++ - mulit-OS

I have 2 separate applications, A and B. I want to run application B inside of application A. Sounds a bit like OLE or Active X, but neither program A or B is OLE server or an Active X component.

Does anyone know of an easy way to run an application inside another application?

Thanks,
-spiderman
Spiderman_gtp is offline   Reply With Quote
Old 07-24-2005, 12:11 PM   #2 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
I've moved this thread to the API section, since this is highly system specific. If it were to be done under *nix you would create a second thread with pthreads, then call fork()/dup() in order to make a child process under the current parrent.
But for a windows app, I have no idear which calls is needed.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-25-2005, 02:29 AM   #3 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
I had nothing todo today, so I made a quick google search, and it came up with this.
http://www.cswl.com/whiteppr/white/multithreading.html
I dont know if it will be usefull, but it might be.
I also found this article but since it's in danish I don't think it will be of much use to you, altho The basic multithreadded "hello world" example is:
Code:
#include <iostream>
#include <string>
#if defined(__linux__)
    // Under *nix every threads are 
    // handled in the pthread.h header
    #include <pthread.h>

    // And sleep() is in the unistde.h
    #include <unistd.h>
    #define SLEEP(x)    sleep(x)
#elif defined(_WIN32)
    // under windows nearly every functionality
    // is placed in windows.h even threadding
    #include <windows.h>
    #define SLEEP(x)    Sleep(1000*x)
#endif

using namespace std;

// The threads will run as long as this is true
bool running = true;

#if defined(__linux__)
// This is the thread definition for *nix
void * threadProcedure(void * parameter)
#elif defined(_WIN32)
// And this is the defiition for windows
DWORD WINAPI threadProcedure(LPVOID parameter)
#endif
{
    string * str = (string*)parameter;
    while(running)
    {
        cout << (*str);
        cout.flush();
        SLEEP(1);
    }
    return 0;
}

int main(int argc, char ** argv)
{
    string hello("Hello ");
    string world("World ");
#if defined(__linux__)
    pthread_t helloThread, worldThread;
    // Start the thread which writes "Hello"
    pthread_create(&helloThread,NULL,threadProcedure,&hello);
    // Start the thread which writes "World"
    pthread_create(&worldThread,NULL,threadProcedure,&world);
#elif defined(_WIN32)
    HANDLE helloThread, worldThread;
    // Start the thread which writes "Hello"
    helloThread = CreateThread(NULL,0,threadProcedure,&hello,0,NULL);
    // Start the thread which writes "World"
    worldThread = CreateThread(NULL,0,threadProcedure,&world,0,NULL);
#endif

    SLEEP(10);
    // Time to stop the threads
    running = false;
#if defined(__linux__)
    // Wait for the "hello" thread to stop
    pthread_join(helloThread,NULL);
    // wait for the "world" thread to stop
    pthread_join(worldThread,NULL);
#elif defined(_WIN32)
    // Wait for the "hello" thread to stop
    WaitForSingleObject(helloThread,INFINITE);
    // Wait for the "world" thread to stop
    WaitForSingleObject(worldThread,INFINITE);
#endif
    return 0;
}
So if you're familliar with reading code, you might be able to figureout how to extend it to be used with what you want.
Since there is nothing within the Windows API, which provides the fork()/dup()/execp() calls you'd normaly use under *nix, I am stumped, as to how you would complete that task.
But perhaps the msdn library will reveal something, after a few hundred hours of scavenging through it.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 07-28-2005, 08:46 AM   #4 (permalink)
Spiderman_gtp
Registered User
 
Join Date: Jul 2005
Posts: 2
Spiderman_gtp is on a distinguished road
Multiplatform

Thanks for that - i am pretty familiar with reading code, win or *nix. After more research on my part, for several reasons, looks like i will have to make the encapsulated application into a dll as well as an exe, depending on how it is accessed (directly via exe or from inside the other app via dll).

You'd think there would be an easy way to do this?....
Spiderman_gtp is offline   Reply With Quote
Old 07-28-2005, 08:56 AM   #5 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,726
redhead is on a distinguished road
You could place the major part of your apps in dll's, then just create a small wrapper app for the exe, so your A.exe is a wrapper for A.dll and is using and linking to B.dll, aswell as the same for your B app.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 12:28 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting