|
I didn't read the article you provided but I suppose its just describe a class to encapsulate the thread. Now concerning your problem: this is really simple, you just need to change the value and that's it . As you said, both pointers point to the same memory adress, so if you make change in your main thread, the modifications will be accessible in the other thread.
BUT, you will have to protect the data to avoid that both threads try to access it at the same time. Thus, you might look at this link[^] for CRITICAL_SECTION objects (I suppose you don't use MFC from the name of the article you gave). And look at the functions InitializeCriticalSection then EnterCriticalSection and LeaveCriticalSections to try to access your variable (EnterCriticalSection will return only when no other thread as entered the same CRITICAL_SECTION object) and finally DeleteCriticalSection to release the object.
|
|
|
|
|
Consider using a synchronized smart pointer.
See following link:
http://code.axter.com/sync_ptr.h
The above synchronized smart pointer will automatically lock and unlock access to your data.
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Cplusplus
|
|
|
|
|
Hi Axter,
Thanks a lot for your reply. I used a techinique that I found from http://www.relisoft.com/resource/resource.html and It works very well. The technique is to create an object that has a reference to a critical section object and that enters to critical section in the constructor and leaves in the destructor. Since destructor is automatically called at the end of the scope it makes sure that the memory is released.
Thanks and Regards,
stkl
|
|
|
|
|
Hi Cedric,
Thanks for your quick response . I think this should solve the problem. However still I couldn't try this out. I tried to access a pointer variable from two threads and it worked fine even without using critical sections. However when I tried to use a variable in a structure, it didn’t work. The structure and variable within it both are pointers. I tried to access a member variable of a class as well. Both class and the member variable are defined in the heap. This didn’t work either. I think the reason may be access problems you mentioned. Any way I'll try this out and let you know. Thanks again
stkl
|
|
|
|
|
Hi forum members, I need your help to get the handle of the "all programs" menu of the star menu, when the menu of "all programs" is selected, I am usign CBT HOOKS to get the handles that have the current focus, when the star menu is selected i get the "DV2ControlHost" window class, and I have found those windows classes with Enumchildwindows function:
Shell_TrayWnd
TrayNotifyWnd
TrayClockWClass
SysPager
ToolbarWindow32
ReBarWindow32
TF_FloatingLangBar_WndTitle
CiceroUIWndFrame
WMP9DeskBand
MSTaskSwWClass
Desktop User Pane
DesktopSFTBarHost
SysListView32
Desktop More Programs Pane
The "Desktop More Programs Pane" window class has a child that is a button and its name is "all programs", after that the "all programs" button is pressed , appears the "menu of the programs" but I cannot get the window handle of the "all programs" menu.I have used the getmenu(), getsysmenu() functions and the message WM_SYSCOMMAND message but it didn't work.so, Do you know how to get the "all programs "
Thanks in advance
|
|
|
|
|
Hi
I just want to get a process Id from a Processhandle which has been opened with PROCESS_TERMINATE access . I tried methods like enumerating the processes and NtQueryProcessInformation . All these funtions are failing if the Process has been opened with the PROCESS_TERMINATE access . But if the Process is opened with any other access I am able to get the process id by using the above mentioned methods . I request you to help me in this regard
|
|
|
|
|
Hi,
How can I post string from one application to another?.
NSS
-- modified at 23:40 Tuesday 4th October, 2005
|
|
|
|
|
sthalasayanam wrote:
How can I post string from one application to another?.
Try WM_COPYDATA message. here is an example :-
http://www.codeproject.com/threads/ipc_wmcopy.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Thanks.
Why do we have to use SendMessage() instead of PostMessage() if WM_COPYDATA event is to be posted to another windows.
|
|
|
|
|
sthalasayanam wrote:
Why do we have to use SendMessage() instead of PostMessage() if WM_COPYDATA event is to be posted to another windows.
Actually there is basic difference between PostMessage and SendMessage.. When you Post message using PostMessage... it just post the message in message queue and return immediately... but in case SendMessage i doesn't return till the target program acknowledge it properly... Now i believe you get the point why WM_COPYDATA using SendMessage instead of PostMessage
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi...
I am currently working on embedded vc++ and I have created a mfc single document exe application .Now in the resource I add a dialog box and also in the menu I add a new menu button.On pressing it I want the dialog box.For that I have added a command handler to the toll bar.Now what should I write in the command handler for the dialog box to be executed .
|
|
|
|
|
Basically I completed the steps given in this site:
http://www.justppc.com/evc2.shtml</
|
|
|
|
|
CMyDialog dlg;
dlg.DoModal();
or
CMyDialog *dlg = new CMyDialog();
dlg->Create(ID_DILOG);
DLG->ShowWindow(;)
|
|
|
|
|
It gives the Error that CAboutDialog class doesnot exist.I had added the dialog box and its name was CAboutDialog
|
|
|
|
|
I managed to remove the error however on running the application I get this error on clicking the run menu
TryCalc2:File winocc.cpp Line 238
On ignoring the error I get my calculator and it runs properl.What is this error????
|
|
|
|
|
Nice to know that u work on EVC++
we are plannig to go for a project
in VOIP with WinCE & EVC .
Can u please prvoide guidence for
EVC+ or WinCE.
Any help will be nice
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I am attempting to get my program to run another program. I looked on the FAQ and it said that one of the best ways to do this was using the WinExec command. I am trying to use this like so:
WinExec ("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE", SW_SHOWNORMAL);
I believe this is the correct format, but my compiler says that WinExec is an undeclared indentifier. I'm assuming this means that I need the correct header file. If this is the case, where can I get this header file from?
|
|
|
|
|
|
Sweet Flame wrote:
WinExec ("C:\Program Files\Microsoft Office\OFFICE11\WINWORD.EXE", SW_SHOWNORMAL);
Just a note: You'll need to escape the backslash. The '\' character in a string signifies a special character. You need to use:
WinExec("C:\\Program Files\\Microsoft Office\\OFFICE11\\WINWORD.EXE", SW_SHOWNORMAL);
|
|
|
|
|
hello....not sure why the #pragma disable isn't working....
the app has 14 warning of C4503, I've checked the source file that been complant about, here is the first 4 line of abscommbuffer.h
#if !defined( __ABS_COMMBUFFER_H__ )
#define __ABS_COMMBUFFER_H__
#pragma warning( disable : 4786 )
#pragma warning( disable : 4503 )
it's other's app, I am not sure what exactly is this line doing:
std::map< std::string, std::list< std::string > > mapLists;
and the warning message:
c:\program files\microsoft visual studio\vc98\include\xtree(199) : warning C4503: 'rbegin' : decorated name length exceeded, name was truncated
c:\program files\microsoft visual studio\vc98\include\map(46) : see reference to class template instantiation 'std::_Tree<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,struct std::pair<class std::bas
ic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > const ,class std::list<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct="" std::ch
ar_traits<char="">,class std::allocator<char> > > > >,struct std::map<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::list<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocato
r<char> >,class std::allocator<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > > >,struct std::less<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > >,class std::allocato
r<class std::list<class="" std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > > > > >::_Kfn,struct std::less<cla
ss std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > >,class std::allocator<class std::list<class="" std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::allocator<class std::basic
_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > > > > >' being compiled
c:\dev\c++\billing\taxreport\abscommbuffer.h(113) : see reference to class template instantiation 'std::map<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::list<class std::basic_string<char,
struct="" std::char_traits<char="">,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> > > >,struct std::less<class std::basic_string<char,struct="" std::char_traits<char="">,c
lass std::allocator<char> > >,class std::allocator<class std::list<class="" std::basic_string<char,struct="" std::char_traits<char="">,class std::allocator<char> >,class std::allocator<class std::basic_string<char,struct="" std::char_traits<char="">,class std::all
ocator<char> > > > > >' being compiled
|
|
|
|
|
C++ exception handling was used but /EHsc was not selected.
When the /EHsc option has not been enabled, an object with automatic storage in the frame, between the function doing the throw and the function catching the throw, will not be destroyed. However, an object with automatic storage created in a try or catch block will be destroyed.
|
|
|
|
|
but after I enabled the /EHsc option in project setting, I still get 14 same warnings.......not sure why is that.
Thank you for your time
|
|
|
|
|
beffekt deivsec wrote:
C++ exception handling was used but /EHsc was not selected.
That's C4530, not C4503...
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
Hey all, Lately my VC++ has been playing around and I figured what the problem was and it was that most of the header files were missing. Does anyone know were i could get the header files???
Thanks for any help at all I really need them.
My VC++ Version Is: Visual C++ 2005 Express Edition Beta 2.
|
|
|
|
|
Consider downloading and installing the Platform SDK from Microsoft.
All the Windows headers are part of the Platform SDK.
|
|
|
|
|