|
i support you
|
|
|
|
|
Critical sections won't work, as you can't operate on the same one across process boundaries.
Using the Name part of CreateMutex looks like what you need. Saying that, its going to be very upsetting for program B if it suddenly freezes because program A is doing something. Back to the bad old days of Win 3.x... You may have legitimate need for this, but I would think *very* carefully about which functions you block...
Iain.
|
|
|
|
|
if you're going to sync threads in the same process than work with critical section, they are the most efficient
to share objects in multiple process, it is best to work with a mutex
btw, mutex are global object system objects so if you sync on that you will be ok....if you need share data you can work with shared memory, but make sure that the DLL has APIs to both allcate and free the shared memory and the applications calls these API to allocate/free the memory otherwise you're going to have issues with memory leaks.
read up on DLLs in MSDN and understand the limitation of passing object across DLL boundaries.
Yours Truly, The One and Only!
|
|
|
|
|
_NightOwl_ wrote: to share objects in multiple process, it is best to work with a mutex
It needs to be a named mutex. An un-named mutex is only good for multiple threads in the same process.
Judy
|
|
|
|
|
You are right Judy
One should never use a mutex to sync threads in the same process. As I mentioned, critical sections are the best way to go for a multi-threaded process.
Yours Truly, The One and Only!
|
|
|
|
|
I'm in need to detect whether a network connection is established using a WLAN or a LAN. I don't know in what way the detection is different ..
Thanks for any help ..
HStrix
|
|
|
|
|
HStrix wrote: I'm in need to detect whether a network connection is established using a WLAN or a LAN.
Have you considered something like IsNetworkAlive() ?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks DavidCrow,
I did not yet consider IsNetworkAlive().
But I checked it now in the internet
and found that it can only decide between LAN and WAN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/syncmgr/syncmgr/isnetworkalive.asp
|
|
|
|
|
HStrix wrote: ...and found that it can only decide between LAN and WAN
And yet those were your exact requirements.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Sorry, perhaps there is some misunderstanding ..
I want to decide between WLAN und LAN
and not between WAN and LAN ..
|
|
|
|
|
HStrix wrote: Sorry, perhaps there is some misunderstanding ..
Yes, I failed to realize W was for Wireless not Wide.
You can use GetAdaptersInfo() for this. With the adapter name from that, call CreateFile() to get a handle, and call DeviceIOControl(..., IOCTL_NDISUIO_QUERY_OID_VALUE, ...) . I've not fully tried this, however.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thank you,
this looks good.
I'll give it a try.
Maybe it takes some time ..
|
|
|
|
|
Hello everyone,
I am using Visual Studio 2003 and Windows Console project, I find when using L macro to convert character to wide character, the compiler will report an error that L macro is not defined.
I find it is not defined in either <windows.h> or <tchar.h> -- when adding the two header files, the compile error is the same.
Could anyone explain how to use L macro in Visual Studio 2003 and Windows Console project? Which header file is needed?
thanks in advance,
George
|
|
|
|
|
George_George wrote: ...I find when using L macro to convert...
Technically speaking, I do not believe L is a macro.
George_George wrote: the compiler will report an error that L macro is not defined.
What does the offending statement look like?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David,
The statement is simple, something like, L"hello". Why do you think it is not a macro? Who to use L in Visual Studio 2003 Windows Console project?
regards,
George
|
|
|
|
|
If it were a macro (i.e. preprocessor directive), it would resolve to something.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David,
If it is not a macro, what is it?
regards,
George
|
|
|
|
|
George_George wrote: If it is not a macro, what is it?
It's simply a prefix to denote wide-string literals.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks David,
I can understand your point. I mean there should be a technical terminology to call it -- besides the term "prefix". So, if it is not macro, what is it? There is not a technical terminology called "prefix".
regards,
George
|
|
|
|
|
George_George wrote: If it is not a macro, what is it?
it's an extended keyword of the language
|
|
|
|
|
Thanks toxcct,
I want to confirm that keyword L could only be used in C++ and not in C. Right?
regards,
George
|
|
|
|
|
George_George wrote: want to confirm that keyword L could only be used in C++ and not in C
then why didn't you asked clearly ?
and why do you bother that much ? why is it that important ?
can't you just search the WEB for that easy info ?
BTW, what is it that you vote everybody to '4' ???
|
|
|
|
|
Thanks toxcct,
I can not find answer from MSDN so I come here. We could only use L in C++? Can not use in C?
regards,
George
|
|
|
|
|
As has been said, L is not a macro...
char narrow [] = "abc";
TCHAR either [] = _T("abc");
wchar_t wide [0] = L"abc";
short a = 1L;
The last example shows that L is also useful for non-chars, etc.
Iain.
|
|
|
|
|
Thanks Iain,
You code can not compile in my VS 2003 environment,
This statement
wchar_t* wide [] = L"abc";
error C2075: 'wide' : array initialization needs curly braces
When I change to L("hello"), there is an error from compiler that L is undefined.
regards,
George
|
|
|
|