Solved

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

Posted on 2004-09-10
8
177 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
  • 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
 

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 100
Question regarding Copy/Paste 16 86
Line meaning 9 76
firstChar challenge 13 83
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.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now