Solved

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

Posted on 2004-09-10
8
180 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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to match SAS datasets by multiple key variables and then rename and create new variables? 2 89
sum28 challenge 31 112
haveThree challenge 22 118
Message not shown 5 50
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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