|
There are quite a few run-time library functions that have global/static variables whose storage specification changes for the multithreaded versions. The multithreaded versions use the __declspec( thread ) keywords to specify thread-local storage for those variables which means that each thread gets its own copies of each variable.
|
|
|
|
|
Thank you. Didn't know it. Or better didn't think about
I just got it as - I don't know which functions have some global/static parts and I don't know if it can or cannot change. Therefore I decided to took the run-time library as a block - either use it, but then compile carefully with appropriate switch or dump it completely.
|
|
|
|
|
I'm not using LoadLibrary method.
I'm importing the .tlb of the DLL file and then linking to my program.
To create a new instance of the DLL, im using the methods CoInitializeEx with the parameters 0 and COINIT_MULTITHREADED and then CoCreateInstance with the parameters CLSID_DLL, NULL, CLSCTX_ALL, IID_IUnknown, (LPVOID*)&pointer);
|
|
|
|
|
CoCreateInstance does some COM dancing around and then calls LoadLibrary for you.
|
|
|
|
|
It sounds to me like your problem is with global variables in the DLL - i.e. there's only one variable X but when you run two threads they'll both be able to change it. Same thing applies to any static variables in functions.
If this is the problem then it implies that the DLL's author wasn't expecting the DLL to be run in different threads in which case it assumedly wasn't linked with the Multithreaded runtime libraries which will create a different set of issues.
A solution is not too easy. You could:
1. Use thread local storage (see "Using Thread Local Storage in a Dynamic-Link Library" in the SDK documentation) to sort out the variables (or use __declspec(thread) which might be easier). However, you will need to understand which variables should and which shouldn't be accessable to all threads.
2. Re-build using the mutli-threaded libraries.
However, You might still have issues with any resources the DLL uses (such as intentionally shared variables). To sort this out you'd need to use some type of synchronisation object such as a mutex (or create a critical section) to control multi-threaded access. There's lots of stuff about this in the SDK.
Depending what the DLLs actually does, it might be easier to rewite it yourself or look for an alternative.
|
|
|
|
|
About the item 1, I will analyze further the method __declspec(thread) and try to use it.
But in the 2nd item, you told me to rebuild DLL using the multi-threaded libraries. In Visual C++ 6, Project->Settings, C/C++ tab with Code Generation option selected, it has an combo box called "Use run-time library". The option selected there already is "Multithreaded DLL". There's another way to configure this? How it does?
Dennis
|
|
|
|
|
|
hi all
can any body help me how to create dynamic menus in adlg based applications
generating popup menus(CMenu) dynamically ..
|
|
|
|
|
|
hi pal thanx 4 ur reply,
but i've been using that i nead to create different popup menus at differnt locations
like iam creating a Explorer kind of thing i should get different menus dynamically when i select each item from a tree control of the explorer
for example the windows explorer like...
The menu generated should be changed dynamically when i change my selection in the tree
|
|
|
|
|
You'll need to dynamically create and populate the menu before displaying it. See CMenu::CreatePopupMenu() and related APIs.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
hi,
u can look into InsertMenu/ModifyMenu...(MF_POPUP)
hope this is of some help to u!
regards
uday
|
|
|
|
|
hi all,
iam a beginner and iam indulged in a project being developed in VC++
QUESTION:
How to access or manipulate the functions present inside the DLL without knowing the fn()name and the parameter values.plz do help me...
|
|
|
|
|
If you don't know the function name and parameter set, how do you know, what the function does and what it should return?
|
|
|
|
|
ok i accept,
then is there any way to get the fun name and parameter set in a generic way before i access the function from my program , and this all should happen dynamically
|
|
|
|
|
Yes and no. There's a way, how to get the name of the functions, but problem is with parameter set. The best you can get without disassembling is a number of bytes that should be transferred to the function.
If you look at the SDK tool called depends.exe, you'll see what can you get.
If this is enough for you, you can look at the ImageHlp library as described in MSDN. This will help you to parse the info stored inside the dll (which is PE executable)
|
|
|
|
|
In addition to the above response, you can also use the DumpBin.exe utility to see all publicly exported functions available to you.
The parameters needed and usage will still be needed in advanced though.
I Dream of Absolute Zero
|
|
|
|
|
Hey,
A sort question really. How do I get text from one of the lines in a listbox?
I thought I could do something like this:
SendMessage(listbox1, LB_GETTEXT, 1, 0);
But how should I then use a buffer to save the text?
humpa humpa
|
|
|
|
|
From the MSDN doc:
LB_GETTEXT
wParam = (WPARAM) index;
lParam = (LPARAM) (LPCTSTR) lpszBuffer; Parameters:
index
Value of wParam. Specifies the zero-based index of the string to retrieve.
lpszBuffer
Value of lParam. Pointer to the buffer that will receive the string. The buffer must have sufficient space for the string and a terminating null character. An LB_GETTEXTLEN message can be sent before the LB_GETTEXT message to retrieve the length, in characters, of the string.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
As Ravi said. Here is a small example:
int
GetListboxSel( HWND hCtrl_Source, char* szItem, const int nItemLen )
{
const int nIndex = (int)::SendMessage( hCtrl_Source, LB_GETCURSEL, 0, 0L );
if ( nIndex != -1 )
{
const int nLen = (int)::SendMessage( hCtrl_Source, LB_GETTEXTLEN, nIndex, 0L );
if ( nLen < nItemlen )
::SendMessage( hCtrl_Source, LB_GETTEXT, nIndex, (LPARAM)szItem );
else
*szItem = '\0';
}
else
*szItem = '\0';
return nIndex;
}
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
CString strAnswer;
CListBox* pListBox = (CListBox*)GetDlgItem(IDC_MY_LISTBOX_CTRL);
pListBox->GetText(m_plAnswers->GetCurSel(), strAnswer);
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
I'm trying to wrap a pure MFC control into an ActiveX, and use it on an WTL App dialog.
Problem: TAB works spuriosly (it has some functionality within the MFC control's child controls), Return works not at all (the control doesn't see it).
Any ideas?
Here's the deal:
ActiveX Server: ATL DLL with MFC Support
ActiveX control:
ATL Full Control,
the MFC child window is created in OnCreate
Client:
WTL modal dialog based app, Control added to the resource.
Any stuff I need to add/call?
(I tried to add the OnPreTranslateAccelerator and SetFocus that ATL Wizard adds to a full control containing a windows control, but this didn't change anything)
HEEEEEEEEEEEEEEEELP!
[edit]Tabstop does work[/edit]
I never really know a killer from a savior boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
hello everyone
can anyone tell me how to capture the dialog based control button key press events.i am usin g a vc++.net environement. my requirment is if i have a a button by id IDC_LEFT i want to perform an action as long the button is pressed down and should stop doin the action when released. how do i read that particular action and perform the required action.
anykind of information or help is appriciated.
thanx shashi
|
|
|
|
|
Hi all,
I have a word Add-in from which i will open a word new
document. For this document I want to remove maximize,
resize option. I'm able to remove the resize option using
style &= (~(WS_THICKFRAME));
and applying this style property to the document window using user32.dll
library imported function.
Similarly I tried to remove maximize but its not working.
Any help in this regard is highly appreciated either through C# or
VC++(native).
Thx & Regards
Satish Jupalli
|
|
|
|
|
What about removing WS_SYSMENU option
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|