|
ForNow wrote: I am guessing that everytime you do a TlsSetValue withis dword index it bumps up the number
Huh? Bumps up what number?
The index is global - it is the same for ALL threads in the process.
What a given thread puts in the slot (designated by the index) is local to the given thread.
These may help:
Thread Local Storage[^]
Using Thread Local Storage in a Dynamic-Link Library[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Okay then my question is can I set A value for a Thread that is not the Current Thread
After I create My Thread Control does automatically transfer to the DLL_THREAD_ATTACH message
I have at that point a thread id for the the thread for which I wish to do a TLSetValue
is is this do-able ????
I would like to inform The DLL_THREAD_ATTACH message the nature of the thread like Set pointer via TlSsetValue
and have the DLL reterive it With TlsGetValue as my DLL is acting as a kind of server to the threads of the process and
it would be helpfull to know what the nature of the thread is
|
|
|
|
|
ForNow wrote: I would like to inform The DLL_THREAD_ATTACH message the nature of the thread like Set pointer via TlSsetValue
I don't think this will work. To set a value in the thread's local storage, you need to
be running in the context of that thread, in which case the DLL_THREAD_ATTACH notification
in the DLL entry point will have already been executed.
Can you just handle all this stuff in the thread proc itself?
Do you really need to do this in the DLL entry point?
You could initialize the thread's local storage at the beginning of the thread proc
then call a function in the DLL instead (your own "DLL_THREAD_ATTACH" message ).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think I found something to do what I need
Get access to the next to the TLS before DLL_THREAD_ATTACH
Before I start this discussion I have noticed the Microsoft has a very robus debugging features
I guess now with multicore/multithread/async procedures timing maybe very different while running code through a debugger and normal processing
Anyway I think I can use these debugging features to get what
Use WaitDebugEvent go into debug_loop and wait for CREATE_THREA_DEBUG_EVENT
comapre the the id From The CreateThread if qual use CREATE_THREAD_DEBUG_INFO structure
the second member is lpThreadBase at offset x'2c' is the ThreadArraypointer this is index by the return value from TlsAlloc
I havent tried this
going to tonite
Just thought of something dont know if I have access this peiece of stroage
I guess in User Mode
Will try this onite
Thnakx again
|
|
|
|
|
When using GetThreadContext to get a thread debugging structure the second data member lpthreadlocabase Msdn says the at offset 0x2c is threadLocalstoragepointer is this and the TLS slot one and the same ?????
|
|
|
|
|
Hi All,
I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog.
My Question::
1. If the message box is shown, is it possible to close that first and then close the CMyDlg.
Main Condition : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time.
Please help.
Regards
Sunil
Sunil
|
|
|
|
|
You're going to struggle. But you don't *have* to use MessageBox - there's nothing stopping you using a second dialog that you designed and have code control over - then you can post messages (ie, WM_COMMAND/IDCANCEL, WM_CLOSE) more easily.
MessageBox is a very useful straitjacket, but it still restricts you.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
sunilpv1982 wrote: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg.
Possible, maybe, but it doesn't make much sense. Why are trying to use
modal dialogs modelessly?
sunilpv1982 wrote: I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time.
How did you find the window to change its title?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for replying.
Mark Salsbery wrote: Possible, maybe, but it doesn't make much sense. Why are trying to use
modal dialogs modelessly?
If i use CMyDlg in a modeless fashion(also providing a parent window handle), the user will still be able to control the parent window. I want the user to respond within a timeout value. If there is no response then close the CMyDlg window and any message boxes opened within CMyDlg.
Mark Salsbery wrote: How did you find the window to change its title?
AfxMessageBox/MessageBox has a title. The ::FindWindow API gives the handle to the window by passing the title. In my case the title displayed in the MessageBox keeps changing with time(as a result of some SQL query).
Sunil
|
|
|
|
|
sunilpv1982 wrote: the user will still be able to control the parent window
You can disable the parent window. That's what MFC does to simulate a modal dialog.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi all,
I'm using Visual Studio 2005. I have a workspace in visual C++ 6.0 which provides a set of library functions[DLL]. I have a client application which uses one of the function in the library. This client was working perfectly in VC6.0, but when I ported to VC8, it started showing link error:
Signature of the Function in the library[DLL] Header:
ULONG sendInfo(const bool isRequest, TCHAR pParameters[MESSAGES_PARAMS][MESSAGE_SIZE], ULONG netCallId);
Implementation of the Function in the library[DLL] Source:
ULONG NIHAI_TAPI::sendInfo(const bool isRequest, TCHAR pParameters[MESSAGES_PARAMS][MESSAGE_SIZE], ULONG netCallId)
{
....
....
....
}
Client Application Call:
TCHAR messageParameters[MESSAGES_PARAMS][MESSAGE_SIZE];
ULONG netCallId;
bool request;
returnCode = tapiConnection.sendInfo(request, messageParameters, netCallId);
But I'm getting a link error:
nihai_worker.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: unsigned long __thiscall NIHAI_TAPI::sendInfo(bool,unsigned short (* const)[81],unsigned long)" (__imp_?sendInfo@NIHAI_TAPI@@QAEK_NQAY0FB@GK@Z) referenced in function "private: unsigned long __thiscall NIHAI_Worker::sendToTAPI(unsigned int,unsigned short (* const)[81],unsigned long)" (?sendToTAPI@NIHAI_Worker@@AAEKIQAY0FB@GK@Z)
Kindly suggest a resolution for the above problem.
Thanks in Advance.
regards,
Rajesh
|
|
|
|
|
One thing I know (there are soooome others) is that VC6 defaulted to not-unicode, and VC8 defaults to unicode.
TCHAR means different things depending on the defines. So your program could be thinking TCHAR = wchar_t (ie, short), while the lib you're linking against was compiled with TCHAR = char, and the two decorated functions no longer match...
So, to resolve it, you need to make sure both of your chunk of codes agree on what TCHAR means.
Iain.
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
u 2 fast -> i 2 drugz.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Well, I'm waiting for a colleague to finish a bit of work so I can carry on, so I'm pouncing for a little while. And I like to race you.
Of course, while I was typing my last response, Cedric wrote a better and faster answer than me. Boo Cedric, Boo!
Iain.
ps, Noone's delivered your urgent drugs yet?
Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.
|
|
|
|
|
Iain Clarke wrote: Of course, while I was typing my last response, Cedric wrote a better and faster answer than me. Boo Cedric, Boo!
Why don't we have a devil emoticon when we need it ?
|
|
|
|
|
Iain Clarke wrote: Boo Cedric, Boo!
Definitely! That guy is too smart.
Iain Clarke wrote: ps, Noone's delivered your urgent drugs yet?
Nope my friend...But since you are such a nice guy, ...plz plz plz urgent!!!
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
CPallini wrote: Definitely! That guy is too smart.
Well, it seems that you really abuse drugs
|
|
|
|
|
Hi Pallini and Iain,
Thanks for your response.
But I still have that error.
Both the Characterset are set to the following:
Character Set: Use Unicode Character Set
Treat wchar_t as Built-in Type: No(/Zc:wchar_t-)\
thanks and regards,
Rajesh
|
|
|
|
|
sorry for the silly question, did you linked to the import library.
|
|
|
|
|
Yes Rajkumar,
I have linked to the import library.
thanks in advance,
regards,
Rajesh
|
|
|
|
|
you may inspect the import library for the symbol may be this(
[libexplorer addin^], [libdump^]) tools helps or by simply open in binary editor. But basically these meant the symbol are not properly created in the import library, possibly check dllexport declarator is used for the class in the DLL class declaration.
|
|
|
|
|
Rajesh_Parameswaran wrote: Hi Pallini and Iain,
Since it is a reply to a Cedric post, I assume you're looking for the widest audience.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Actually i saw that was replied to you, but when OP had seen world is behind "Plz sir slow down", he moved it there.
|
|
|
|
|
Possibly.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
It seems a UNICODE vs ANSI build conflict, i.e. VC8 project makes UNICODE builds by default, while VC6 makes ANSI ones. Possibly you have a ANSI DLL and a UNICODE client. Try to change the client setting: choose Project->Properties menu item, then select Configuration Properties->General node and finally change the Character Set switch.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|