Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-09-10
8
Medium Priority
?
190 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 45

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 45

Accepted Solution

by:
AndyAinscow earned 600 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
Independent Software Vendors: 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 45

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 45

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 45

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

604 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