Click here to Skip to main content
16,011,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: 'GetUserName' failure Pin
21-Jun-01 5:29
suss21-Jun-01 5:29 
QuestionPanel in C++?? Pin
Farah Mansor20-Jun-01 16:45
Farah Mansor20-Jun-01 16:45 
AnswerRe: Panel in C++?? Pin
20-Jun-01 17:01
suss20-Jun-01 17:01 
GeneralSimple CMainFrame App problem Pin
John Treubig20-Jun-01 16:42
John Treubig20-Jun-01 16:42 
GeneralWindows explorer command line Pin
Avneesh Bhatnagar20-Jun-01 16:18
Avneesh Bhatnagar20-Jun-01 16:18 
GeneralRe: Windows explorer command line Pin
20-Jun-01 16:54
suss20-Jun-01 16:54 
GeneralRe: Windows explorer command line Pin
Avneesh Bhatnagar20-Jun-01 17:25
Avneesh Bhatnagar20-Jun-01 17:25 
GeneralThreads and DLLs (Advanced Issues) Pin
Joe Hastings20-Jun-01 15:32
Joe Hastings20-Jun-01 15:32 
Hi, I have a couple of questions regarding the usage of DLLs in a single process from within several threads. I am using dynamically loaded DLLs (to borrow a term from elsewhere on this website), that is I am calling AfxLoadLibrary and then GetProcAddress to find my functions. All of the dlls and the exe are built using MFC as a shared library. Please do not tell me I should be using COM to address any of these issues Wink | ;)

1. Is there a way that the main thread in the EXE can call AfxLoadLibrary while a worker-thread is inside of a function in the DLL w/o causing lots of nasty problems? Right now I have hacked up a solution where it suspends any threads it thinks might be using the DLL, and it seems to work, but it causes memory leaks since that thread probably allocated memory inside of the DLL functions it might have called.

2. On a completely different note, would there be a way to call AfxLoadLibrary within each thread, and have each thread obtain its own HINSTANCE so that each thread could call AfxFreeLibrary independently of the others? I have tried to do this, and noticed that all copies of the dll functions seem to be the same. I know that in general, DLLs are loaded on a process basis rather than a thread basis, and was wondering if there was a way to override this behavior? If this were possible, #1 wouldn't be so much of an issue.

3. What is the safest way to share CWnd objects between threads, and within functions inside of DLLs? Basically, the main EXE opens the HINSTANCE to the dll, and then creates a separate thread to perform various lengthy operations in DLL functions, passing the thread an HWND (window created in EXE), and the thread then passes that HWND as an arguement into the GetProcAddress(ed) function. Inside the DLL, I call: CWnd::FromHandle. This seems to work if I use functions like SetWindowText or SendMessage, but does not work if I call PostMessage on that HWND (or use the CWnd wrapper). Since using SendMessage is dangerous because I don't want to overload the EXEs message pump, I'd really like to be able to use PostMessage. One weird issue here is that CStatic::SetWindowText works fine, while CProgressCtrl::SetPos does not seem to have any effect.

Mach5 Enterprises, LLC. http://www.mach5.com/
"Web Intelligence for the New Economy"
GeneralRe: Threads and DLLs (Advanced Issues) Pin
20-Jun-01 15:52
suss20-Jun-01 15:52 
GeneralRe: Threads and DLLs (Advanced Issues) Pin
Stephen Kellett21-Jun-01 5:07
Stephen Kellett21-Jun-01 5:07 
GeneralRe: Threads and DLLs (Advanced Issues) Pin
Joe Hastings22-Jun-01 3:15
Joe Hastings22-Jun-01 3:15 
Generalstandard search algorithm Pin
Nick Blumhardt20-Jun-01 15:12
Nick Blumhardt20-Jun-01 15:12 
GeneralRe: standard search algorithm Pin
20-Jun-01 15:17
suss20-Jun-01 15:17 
GeneralRe: standard search algorithm Pin
markkuk20-Jun-01 19:42
markkuk20-Jun-01 19:42 
GeneralRe: standard search algorithm Pin
Nick Blumhardt20-Jun-01 21:57
Nick Blumhardt20-Jun-01 21:57 
Generalsendinput & message queue saturation Pin
Amit Jain20-Jun-01 14:49
Amit Jain20-Jun-01 14:49 
GeneralRe: sendinput & message queue saturation Pin
20-Jun-01 15:20
suss20-Jun-01 15:20 
GeneralRe: sendinput & message queue saturation Pin
Amit Jain21-Jun-01 4:37
Amit Jain21-Jun-01 4:37 
GeneralUSB Keyboard Pin
DrunkerII20-Jun-01 13:58
DrunkerII20-Jun-01 13:58 
GeneralRe: USB Keyboard Pin
20-Jun-01 15:21
suss20-Jun-01 15:21 
QuestionHow to detect an application launch ? Pin
20-Jun-01 10:01
suss20-Jun-01 10:01 
AnswerRe: How to detect an application launch ? Pin
20-Jun-01 10:03
suss20-Jun-01 10:03 
GeneralRe: How to detect an application launch ? Where to start searching for shell extension ? Pin
20-Jun-01 10:40
suss20-Jun-01 10:40 
GeneralRe: How to detect an application launch ? Where to start searching for shell extension ? Pin
Michael Dunn20-Jun-01 20:58
sitebuilderMichael Dunn20-Jun-01 20:58 
Generalanother Important Question Pin
Fady Elias20-Jun-01 9:50
Fady Elias20-Jun-01 9:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.