|
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
|
|
|
|
|
George_George wrote: 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.
The below works fine with Visual Studio 2005.
char narrow [] = "abc";
wchar_t wide [] = L"abc";
short a = 1L;
Maxwell Chen
|
|
|
|
|
Thanks Maxwell,
I have verified that it is ok.
regards,
George
|
|
|
|
|
Hello everyone,
I think when UNICODE or _UNICODE is defined, when using _T, it could convert characters to wide character.
And I also think LPCSTR should be defined to pointer to wide character when UNICODE or _UNICODE is defined, and LPCSTR should be defined to pointer to multibyte character when UNICODE and _UNICODE are not defined.
But it seems I am wrong for all points. Could anyone explain to me why I get such warnings in Visual Studio 2003?
<br />
#include "windows.h"<br />
#include "TCHAR.h"<br />
<br />
#define UNICODE<br />
#define _UNICODE<br />
<br />
int main (int argc, char** argv)<br />
{<br />
WCHAR* p = _T("hello");<br />
LPCSTR p1 = p;<br />
LPCWSTR p2 = p;<br />
}<br />
warning messages,
warning C4133: 'initializing' : incompatible types - from 'char [6]' to 'WCHAR *'
warning C4133: 'initializing' : incompatible types - from 'WCHAR *' to 'LPCSTR'
thanks in advance,
George
|
|
|
|
|
The warnings are self-explanatory. With LPCSTR p1 = p , you are trying to assign a WCHAR* (an unsigned short* ) to a LPCSTR (a char* ), which is incompatible.
"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
|
|
|
|