|
System wide hook. Look throu the articles at CP.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Thank you all.
I will try...
|
|
|
|
|
More Accurate :- System Wide Hook of Type WH_CBT ....
"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
|
|
|
|
|
|
IShellFolder * psfDesktop = NULL;
SHGetDesktopFolder (&psfDesktop);
LPITEMIDLIST pidl = NULL;
#ifdef _UNICODE
psfDesktop->ParseDisplayName (NULL, 0, strArray.GetAt (0).GetBuffer(0), NULL, &pidl, NULL);
#else
OLECHAR * olePath = NULL;
olePath = (OLECHAR *) calloc (strArray.GetAt (0).GetLength () + 1, sizeof (OLECHAR));
MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, (char*)strArray.GetAt (0).GetBuffer(0), -1, olePath, strArray.GetAt (0).GetLength () + 1);
psfDesktop->ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL);
free (olePath);
#endif
just be patient to have a look. without unicode configuration,everything is good. But if I compiled with _UNICODE defined, after "ParseDisplayName (NULL, 0, olePath, NULL, &pidl, NULL);" ,pidl is always null.
what's the matter????
Thank u every one here.
|
|
|
|
|
CString::GetBuffer returns LPTSTR , which is either a char* or a wchar_t* , depending on the unicode setting. You are testing for the definition of _UNICODE , while LPTSTR depends on the definition of UNICODE (notice the lack of underscore). When you define _UNICODE, are you defining UNICODE, and removing the definiton of MBCS too?
That being said, I'd suggest writing that piece as follows:
BSTR bstrName = strArray.GetAt(0).AllocSysString();
psfDesktop->ParseDisplayName(NULL, 0, bstrName, NULL, &pidl, NULL);
::SysFreeString(bstrName);
The above should work both for Unicode and MBCS builds.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
I want to typecast a 32-bit float to a 64-bit double.
When I do, the most significant bits of the mantissa are correct (ie. the original 'float' variable), but the additional mantissa bits provided by the double look like they have not been initialised properly (ie. The complier has provided a 'double' that is no more accurate than the original 32-bit float).
I have had same results using Visual C++6.0 and VisualC++2005beta2
I have searched the MSDN for some light on this, and have found little.
Anyone have any suggestions/recommendations/standard practice to deal with this...
//=========================================================
//Here is some code that demonstrates the problem...
//Step through it with a debugger and examine the values stored in fdArray[]
//=========================================================
int main(void)
{
int i;
float fFloat;
float fArray[] = {0.1,0.2,0.3,0.4};
double fdArray[] = {0.0,0.0,0.0,0.0};
for(i=0;i<4;i++)
{
fFloat = fArray[i];
fdArray[i] = (double) fFloat;
}
return 0;
}
|
|
|
|
|
chris_mclean wrote:
(ie. The complier has provided a 'double' that is no more accurate than the original 32-bit float).
I wouldn't expect anything less - it's not like you provided any extra info, is it ? And C++ doesn't initialise anything - declare an int and don't give it a value, see what it's value is.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
What do you mean exactly?
You have an array of floats and you copy/convert them to an array of doubles. If you print both arrays out, they should print the same thing. The array of doubles should only print the values assigned to it, and since those values where copied from floting point values, they can be no more accurate than the souce.
Think of anouther example.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
I wasn't thinking and got 'trapped' by a stupid though process.
I presumed that when the complier typecast from float to double, that it would attempt to represent the floating point value as "accurately as possible" using a double.
eg. if the float value was 1.2345678 then the 'typecast' would magically 'convert' the variable to 1.234567800000000 etc.. (which it doesn't).
Thanks for your comments nevertheless.
|
|
|
|
|
:-DWe all fall into that trap. If it actualy printed all the 0s, then we would spend all day watching 0s scroll on our screen.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
As the others mentioned it doesn't create data.
Just for kicks take a look at exactly what it is doing.
Let's use 0.1 as our test number.
(Hex in raw byte order)
0.1 float is 0x3dcccccd
0.1 double is 0x3fb999999999999a
What happens when you cast from a float to a double:
0x3dcccccd -> 0x3fb99999a0000000 - contrast with ...
0x3fb999999999999a - most accurate representation
As you can see it does zero out the unknown part.
The ieee float format uses a 24 bit mantissa (3 bytes).
The ieee double format uses a 11-bit exponent, plus 1 bit sign (1.5 bytes before start of mantissa).
So if we look at the double the mantissa and sign are in 0x3fb leaving 99999a (3 bytes) for the mantissa, which match the 3 bytes of mantissa in the float (cccccd) - i.e. same precission.
...cmk
Save the whales - collect the whole set
|
|
|
|
|
I want my CEdit box only receive the number 0-9. And if other keys were pushed down, it will not be displayed in the CEdit box.
What can I do?
I looked up in the MSDN, But I didn't find any method.
|
|
|
|
|
set the property of your editbox
Number - True
|
|
|
|
|
|
Hi all
How do we delete say some 50bytes from the begning of the file, and move the remaining contents to the begning
of the file.
my file size is very large so i don't want to use the memcpy or memmove functions to achieve this.
i want to know is ther any function in c/c++/vc++(MFC CFile)
that can help solve this problem
thanks and regards
pradish
|
|
|
|
|
No, I don't believe so. I think you need to read and rewrite the files. I'd be inclined to read a bit at a time and copy to a new file then delete/rename. rather than have it all in memory at once.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I agree with Christian .. best you could do is memory map the file and read it and write it to another file starting from a x byte offset into the file (where x can be your 50) etc .. you can optimise the read/write buffers etc although windows should do a good job for you, especially if you memory map it ..
'G'
|
|
|
|
|
They're both right (accept Christian ment bytes not bits).
Here's a couple of old fashion ways (still apply):
// Slow
1) Read byte 50+i. // where i starts at 0.
2) Copy byte 50+i to byte i.
3) Repeat 1 and 2, util you reach the end of the file.
4) Set file size to the original size - 50.
// Faster
1) Open a temporary file.
2) Copy all the bytes, starting at byte 50, from original file to the temporary file.
3) Delete the original file.
4) Rename the temporary file to the origninal files name.
// THIS FITS BETTER (given enough memory)
1) Read the entire (original) file into memory.
2) Copy the data back to the file starting with byte 50.
(no memcpy or memmove required).
3) Set file size to the original size - 50.
Use your imagination, there are other ways. Even if there was a function call to do this for you, it would still do it the same way.
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
Below is apart of my program:
else
{
SktAddr.sin_family=AF_INET;
SktAddr.sin_port=htons(ReadPortNo("[TCP.FLDATA.SRV.COMMUNICATION]"));
SktAddr.sin_addr.s_addr=htonl(INADDR_ANY)
But it have the error below:
error C2227: left of '.sin_family' must point to class/struct/union
error C2227: left of '.sin_port' must point to class/struct/union
error C2227: left of '.sin_addr' must point to class/struct/union
error C2227: left of '.s_addr' must point to class/struct/union
Can teach me how to solve these problem.....
|
|
|
|
|
1983ttj wrote:
SktAddr.sin_family=AF_INET;
Is SktAddr a class, or an instance of a class ? If it's a class, make an instance, and if it's an instance, include the header to tell this code what it means.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
how to know that SktAddr is a class? how to make an instance?
|
|
|
|
|
1983ttj wrote:
how to know that SktAddr is a class?
Well, if it's not an instance, it's a class.
A class definition looks like this
class MyClass
{
/....
An instance looks like this
MyClass myClass;
The capitalisation is not important, except in that the language is case sensitive. That is, an instance can start with a capital, and a class with lowercase.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I have a dialog and only got one start button. I do some program about ListenThread and got around 4 errors. All of the errors is about undefined identifier.I don't know how and where to declare it. In the Dlg.h file?
Below is apart of my code:
UINT ListenThread(LPVOID lParam)
{
char szMessage[300];
wsprintf(szMessage, "(ListenThread) - Starting TCP/IP Initialisations.");
//WriteSysLog(szMessage);
ServerSkt = socket ( AF_INET, SOCK_STREAM, 0 );
return 0;
}
I have header files as shown below:
Resource.h
StdAfx.h
TCPTest.h
TCPTeseDlg.h
and the errors are below
error C2065: 'ServerSkt' : undeclared identifier
error C2065: 'socket' : undeclared identifier
error C2065: 'AF_INET' : undeclared identifier
error C2065: 'SOCK_STREAM' : undeclared identifier
Error executing cl.exe.
where should I declare ?
-- modified at 0:09 Wednesday 31st August, 2005
|
|
|
|
|
What is SktAddr ? Is it a class ? Is it an instance of a class ? Is it something you copied out of a book and you have no idea what it is ?
Christian Graus - Microsoft MVP - C++
|
|
|
|