|
Does MFC calls is syncronized by created STA appartement?
CoInitialize(NULL) is called in App:InitInstance.
What if I choose MTA model?
To avoid blocking and reenterance behavior?
I created some threads in MFC app.
I can not create Windowless controls in CDialog than...
Is There any slution?
thanks
|
|
|
|
|
If you choode MTA model, you need to call CoInitializeEx( ).
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
To join the MTA of a process, a given thread must call CoInitializeEx(0, COINIT_MULTITHREADED). Any objects created within this thread must be thread-safe.
I would suggest to use the MTA model. If you implement it properly, then COM will come in and take care of synchronization for us.
After working with "Apartment", "Both", and "Free", I would take MTA anytime over STA model.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
You incorrectly inderstand my question -
I had read article you cited,
but need to esplain not how to create MTA,
but how to define precisely that MFC based on it -
is made safe.
|
|
|
|
|
MFC is not threadsafe!!!
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
there is an opinion where MFC is not safe for MTA,
and how to modify to make thread -safe?
|
|
|
|
|
I have read some articles( yrs back ), where they have mentioned that MFC is not thread-safe, and so cannot be used with MTAs. I remeber someone suggesting to thread-safely implement IUnknown, to over come this problem. But that shudn't be enough. Why MFC cannot become MTA is still unresolved.
I think its better to remove that itching rabbit(MFC) from your code.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Lemme search that article for you.
I'l post the URL as soon as I find it.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
My program is MFC based,
I would glad to eliminate, but what instead?
WTL is not well documented, and not standard in programming.
|
|
|
|
|
Go for ATL without MFC support. If you include MFC support in your ATL project, your COM object has to start choking up around the MFC runtime DLL. But its true that, you will get all the features in MFC, But you will have to pay for it.
So I would say, its actually a design decision, which you have to take. If you have GUIs, then u may use MFC, otherwise dont go for that. Thats my advice.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I have complex mainly GUI application, that was based on MFC,
but threading is also good thing for not to use in any library.
is there method to correctly use GUI libraries in threading environment?
|
|
|
|
|
You can have dialogs ( CAxDialogImpl ) and property sheets in ATL itself. But if you want anything more, use MFC, and choose STA Apartment with 'Apartment' threading model.
Refer msdn for more details
Start here[^]
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
You may not have to worry if MFC is thread safe.
You can use multi-threading with an MFC application as long as you always use the MFC stuff from the main thread. What are you using multi-threading for? If you just need working threads to do some calculations in the background without directly touching the UI, you can do that fine.
|
|
|
|
|
Yes, sometimes this is so. Thanks for your opinion.
It is to be related to all MFC objects is registerd at one thread.
So it is possible to make other thread that interacts "by handle"
with other threads...
But this is complex to check sometimes in complex GUI systems.
And blocking with reenterancy- is a problem still.
|
|
|
|
|
In an application, we have the task to identify users (with a username and a password).
The best for us would be if there is a function, where we can pass the username / password entered by the user and find out, if this is the correct combination.
Is there any possibility doing this ?
Thanks in advance,
Bernhard
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
Is this on a Windows Domain (NT/2K/2003) or just W9x/ME?
If there's a domain controller involved, there is code which allows you to do this, although it's fairly convoluted. If the latter, then I think you'd have to have something application specific.
Steve S
|
|
|
|
|
well there is a domain controller.. all the servers should (at least) have win2k.. there are some nt4 clients, the rest is win2k..
Would be very nice if you sent me the piece of code..
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
I got the original code from Keith "Mr. Security" Brown, on the developmentor website, and made some minor changes; sent off-thread, since it's a large function
Steve S
|
|
|
|
|
sending it off-thread didn't work though.. i have already sent you an e-mail.. could you send it directly to my e-mail adress? (the one i've sent you the e-mail)
would be very nice..
"I'm from the South Bronx, and I don't care what you say: those cows look dangerous." U.S. Secretary of State Colin Powell at George Bush's ranch in Texas
|
|
|
|
|
I have this situation where I have to dynamically set the PATH variable used by the application.
Imagine I have 2 versions of mylib.dll:
c:\version1.0\mylib.dll
c:\version1.1\mylib.dll
My PATH variable is c:\version1.1; c:\version1.0
Now, my application links to mylib.lib, so whenever I startup my application, it is looking for the mylib.dll based on my PATH settings.
What I want to accomplish is to give the user the possibility to specify which version of the dll is going to be used by the application (via a dialog box).
So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used).
Is this possible? How to accomplish this?
Thanks in advance
Wim
|
|
|
|
|
Could you dynamically link to the DLL and use LoadLibrary() to specify the path for the DLL?
Systems AXIS Ltd - Software for Business ...
|
|
|
|
|
Hello,
I'm afraid that is not possible. Well, it might be possible, but the problem is that there are a lot of dll's invloved, and the references change over time.
So I really need to stick to the .lib usage.
|
|
|
|
|
Wim Jans wrote:
So I thought the solution was to overrule the default PATH variable used by the application by my own one (c:\version1.0\mylib.dll needs to be used).
Is this possible? How to accomplish this?
SetEnvironmentVariable() comes to mind.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Look at the "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths" entry in Registry. It's the modern approach now. You may use it for your purpose.
For example,
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\someserver.exe
@="S:\SRV7\Run\Release\bin\someserver.exe"
"Path"="S:\SRV7\Run\Release\bin\;S:\SRV7\Run\Release\dll\"
NOTE There is the separator ";" between pathes.
With best wishes,
Vita
|
|
|
|
|
Dear all
CString aStr="Learning 中文"; //a mixed English and Chinese string
Extracting each Chinese Character from The String and assign it to a UINT data type.
UINT aWord = ????
i use _MBCS not unicode
can someone tell me how?
|
|
|
|