|
You are getting the picture.
Processes have differnet address space, meaning a pointer cannot go out current process space. Even if you obtain an address of an object from a diffrent process, trying to access it will give you an access violation.
Threads share the same address space, but have different "stack space". This means that a global object can be accessed/modified by two threads at the same time so you must protect it with semaphores, critical sections etc. However if two threads are executing the same function at the same time the local variables declared in that function will be "different".
Best regards,
Alexandru Savescu
|
|
|
|
|
hello 2 of you!!!
i want to learn more.
what is the meaning of 'stack space'? what will it affect?
and, how about 'static'? why all thread function can only access static member of its own class? (but, if i used PostMessage() posting a pointer of a local variable inside the thread function, outside can still access these local variable)
what is the use of 'static' in this case?
|
|
|
|
|
thanks thanks...!!!
chaze
|
|
|
|
|
zecodela wrote:
what is the meaning of 'stack space'? what will it affect?
Suppose you have a function like this
int f (int y)
{
int x = y;
return x;
}
And then you create two threads that call function f at the same time but with different values: (i.e the first one calls f(1) and the second calls f (2)). In this case the local x will have different values accross the different threads. This is what I meant with 'stack space'.
zecodela wrote:
why all thread function can only access static member of its own class?
I am not sure what you mean. Do you refere to thread created by AfxBeginThread or with threads derived from CWinThread?
Also you can use PostMessage to send pointers to different objects across threds.
Best regards,
Alexandru Savescu
|
|
|
|
|
yes, i refer to AfxBeginThread. why does the thread create by it can only access static member of the class create it? any special reason? i feel it make multi-thread not so elegant in MFC.
pls give some idea!
thanks,
chaze
|
|
|
|
|
Hi everyone. In a program I am writing, I need to check which version of some system dlls are installed, for example. mfc42.dll, comctrl.dll, and a few others. I know there is a few ways of doing this, but what would be the "best" way to do this so that it will be compatible with future versions of Windows, and requires the least amount of overhead? Thanks in advance for any help!
|
|
|
|
|
See April 98 C++ Q&A in MSDN
Q How can I tell which version of a particular module (DLL) is installed on my system? I am trying to figure out which version of comctl32.dll is installed. I have seen code that calls GetProcAddress to try getting various functions like InitCommonControlsEx to determine the version based on which functions are present. This seems kludgy to me. What is the right way to get the version?
A Well, there are two ways: the easy way and the hard way. The easy way is to call a special new entry DllGetVersion. The only problem is, while comctl32.dll supports this function, not all DLLs have it. If there's no DllGetVersion, you have to use the hard way—namely, the FileVersion API, which is perhaps one of the most confusing APIs you will ever come across.............. (see MSDN)
|
|
|
|
|
this is my dilemma I have never done C++ before and I have a class assignment due in one week, can you help me with the code. If you email me I will give you my problem. Please help me
|
|
|
|
|
What do you need to know ? Do you know how to use cin/cout ? Do you expect people to email you instead of answering through the site ? Why did you remove the problem ?
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
No cin or cin out... problem was so long... if you email me i can give you problem...
C++ Virgin
|
|
|
|
|
You don't know how to use cin and cout ?
You know, if we discuss it here, other people might offer advice also. It will all be in the form 'look this up/try this', but I'm sure we're all happy to help you to help yourself.
Christian
The tragedy of cyberspace - that so much can travel so far, and yet mean so little.
And you don't spend much time with the opposite sex working day and night, unless the pizza delivery person happens to be young, cute, single and female. I can assure you, I've consumed more than a programmer's allotment of pizza, and these conditions have never aligned. - Christopher Duncan - 18/04/2002
|
|
|
|
|
Christian,
not sure how to get started. I know a wee bit of UNIX from a 3 week class and no C++. The assignment seems so hard for a first assignment.
C++ Virgin
|
|
|
|
|
C++ Virgin wrote:
The assignment seems so hard for a first assignment.
Could you reduce the suspense a little bit by telling us what it's about?
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Nish - Native CPian wrote:
Could you reduce the suspense a little bit by telling us what it's about?
LOL. Nice line Nish.
Michael
|
|
|
|
|
Michael P Butler wrote:
Nice line Nish.
That's what I thought too. But I didn't anticipate what happened later
Nish
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
Please reduce the suspense. What happened later?
|
|
|
|
|
Ed Gadziemski wrote:
Please reduce the suspense. What happened later?
He emailed me his assignment question docs
Regards,
Nish
Native CPian.
Born and brought up on CP.
With the CP blood in him.
|
|
|
|
|
I'm trying to save the current file i'm working on in a visual studio file from an Addin.
I can not get the save command to work. How do you use the command?
Examples, Suggestions?
Here is the code
STDMETHODIMP CCommands::FileFavoritesCommandMethod()
{
AFX_MANAGE_STATE(AfxGetStaticModuleState())
//Get the current file working on
CString csCurrentFile;
CComPtr<idispatch> pActiveDocument;
m_pApplication->get_ActiveDocument(&pActiveDocument);
if(pActiveDocument)
{
CComQIPtr<itextdocument,&iid_itextdocument> spActDoc(pActiveDocument);
if(spActDoc)
{
spActDoc->Save();
BSTR bstrName;
spActDoc->get_FullName( &bstrName );
}
}
}
|
|
|
|
|
how do you know that it is not working?
|
|
|
|
|
It's not compiling.
I'm not sure On what to pass in on the parameters, It wants
::Save(THIS_ VARIANT vFilename, VARIANT vBoolPrompt, DsSaveStatus FAR* pSaved)
I've tried
DsSaveStatus saved;
Save(NULL, TRUE, &saved);
return
--cannot convert parameter 1 from 'const int' to 'struct tagVARIANT
Pluss plenty more and they all say they cannot convert parameter 1 to struct tagVARIANT
Scott
|
|
|
|
|
Use the following code
VARIANT vtErr;
vtErr.vt = VT_ERROR;
vtErr.scode = DISP_E_PARAMNOTFOUND;
VARIANT vtPrompt;
vtPrompt.vt = VT_BOOL;
vtPrompt.boolVal = VARIANT_TRUE;
spDoc->Save(vtErr, vtPrompt, &saved);
This would work but life would be much cool if you use CComVariant or _variant_t.
|
|
|
|
|
that worked, thanks.
I tried using _variant_t but it gave an error when compiling. How do you use CComVariant and _variant_t.
thanks
Scott
|
|
|
|
|
#include <comdef.h>
.
.
.
spDoc->Save(vtMissing, _variant_t(true), &status);
|
|
|
|
|
That gave me the linking errors
Commands.obj : error LNK2001: unresolved external symbol "class _variant_t vtMissing" (?vtMissing@@3V_variant_t@@A)
Commands.obj : error LNK2001: unresolved external symbol "void __stdcall _com_issue_error(long)" (?_com_issue_error@@YGXJ@Z)
|
|
|
|
|
You need to have comsupp.lib linked
|
|
|
|