Solved

Creating a dll program that will be activate from a client as a separate Thread

Posted on 2004-09-10
8
184 Views
Last Modified: 2013-11-20
Hi,

I need to create a dll program ("hello world" for example).
the program will be activate from a MFC Client that will call this dll program as it was
a separate Thread.
How can i make a dll program and how can i make it to be as a separate thread?

Thanks , i need it extremely urgent.

Dani
0
Comment
Question by:dani333
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 

Author Comment

by:dani333
ID: 12025282
I forgot to tell that it should be in C++ windows XP environment.

0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12025385
This might not be suitable but why not just have the 'separate thread' as another program.  You can use CreateProcess or ShellExecute to start it from your first app programatically.

I say this because it is not easy having a window (modeless) being handled from a dll (keyboard support can disappear from your app if you don't code the support).

If the other thread has a modal dialog then just call an exported function from the dll which will start the dialog but then why does it need to be in another thread?
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 300 total points
ID: 12025399
I have just done a quick search here and found this.  It may be worth looking at

http://www.experts-exchange.com/Programming/Programming_Languages/MFC/Q_20177543.html?query=&clearTAFilter=true
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:dani333
ID: 12025711
I'm confuse, let me explain to u what i have now.

I created a client dialog based from which i choose a file to read, than i need to make some
calculation on the data from that file in another dll program, the dll program with the calculation
should be activate as a thread from my client.
I also created a dll App with  the calculation function.
Now i need to call the calculation function as a thread from my client and also show
a progress bar of the calculation progressing.
I insert the dll lib to my client recourse.

What should i do now,in order to set it up to work?

Thanks ,
Idan.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12025854
Create a worker thread to do the reading and processing.
That thread can post messages to your main app which handles the details of showing/updating the progress.
You do not actually require a separate dll to wrap the thread.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12025907
Look at CWinThread in help and also search on 'worker thread'.

This could be a good start - the logic is similar to what you describe as your requirement.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample/html/_sample_mfc_MTRECALC.asp
0
 

Author Comment

by:dani333
ID: 12029929
Hi again,
I'm trying to use a function from my dll,i mus use a dll.
I have a class in my dll App:
__declspec(dllexport) class MyDllClass: public CDialog
{
...
}
and a function in that class:
__declspec(dllexport) int MyDllFunction(void *,void *);

in my client i'm using:
__declspec(dllimport) class MyDllClass;
__declspec(dllimport) int MyDllFunction(void *,void *);
At the top of my header file.

I'm tring to use this function before even creating a thread and i'm getting this error:
void CClientDlg::OnOK()
{
   void * a,*b;
   MyDllFunction(a,b);
}
error LNK2001: unresolved external symbol "__declspec(dllimport) int __cdecl MyDllFunction(void *,void *)" (__imp_?XYZCompare@@YAHPAX0@Z)

What is the problem?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12030113
Just export what needs to be exported.
Do you need the class exporting?  (If you do then use an extension dll and AFX_EXT_CLASS  not a regular dll).
You might need to modify the .def file of the dll and have the function you export declared there.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question