?
Solved

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

Posted on 2004-09-10
8
Medium Priority
?
185 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 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

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…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

752 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