|
See fopen() , fscanf() and fclose() .
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
hello friends
i want to use some functions in my project please tell me from which functions i can get these value in LAN
cpu usage
available network bandwidth
network packets per second
memory usage
thanx
bye
|
|
|
|
|
hiho@ll
a question to all hardcore (windows) C++ hackers
if i have a few thousand (or many many more) objects, how could i have access to each object indivdually and (extremly) very fast?
i thought about using collections but i thinkg that it would be very slow if there are a many 10000 objects which i need to access
and how i have access to all of them without waiting for a thread to finish
i mean how could i synchronize the access to those objects if i'm running many threads, but i don't want a thread to wait for it's information because it would slow down?
thx@ll
|
|
|
|
|
Use hash! It's as short as that. There are many classes available, from Micro$oft, Boost, etc.. Those are fast enough to handle hundreds of thousands entries.
Greetz, pat le hashed :->
|
|
|
|
|
|
hiho@ll
i'm thinking about a project, which would need a few thousands threads running and every thread should be accessible everytime (i think about a vector or something else in the core)
so my question, what is the maximum number of threads/Objects windows/VC can produce/handle?
am i right that, it should be depeding on how much RAM i have and not on somthing different?
thx@ll
|
|
|
|
|
How is the vector related to the multiple threads?
Are you trying to access the same vector from multiple threads?
Top ten member of C++ Expert Exchange.
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/
|
|
|
|
|
hiho
i want to try to use the vector to hold my references to my other objects
but i think i build a core, and every vector who needs something must ask the core and not the other way
but this would be the little difficultier way
and i don't know if i could do this all, because windows only allows a maximum of 18.000 handles for the appz, i read from the KBReport i got in the second answer
my questions are answered
thx@all
|
|
|
|
|
|
To get the unsigned _int64 value between two bits in a LONGLONG,I wrote:
unsigned _int64 CMyBitsDlg::RevealBitsInLL(LONGLONG theNb,unsigned int lowBit,unsigned int highBit)
{
unsigned _int64 valueOfBits=0;
/// Get the string as zero and 1's
CString mystring=ConvertLLtoBin(theNb);
for(unsigned int n=63-highBit; n<=63-lowBit; n++)
{ int theChar=mystring.GetAt(n); //it is either 1 or 0
valueOfBits +=(unsigned _int64)((unsigned int)theChar*pow(2,n));
}
return valueOfBits;
}
/////////////////////////////
Now,if I give a hex of :
FFFFFFFFFFFFFF (16 Fs)
and a low bit =0,a high bit =63,
I am getting:
14,123,288,431,433,875,407
instead of the correct answer which is:
18,446,744,073,709,551,615
What am I doin wrong ?
Thanks for any help.
|
|
|
|
|
If I understand correctly what you're trying to do, there's a much simpler (and faster) method.
Here's what I think you're trying to do. Given a 64 bit unsigned value, and the bit positions for a low bit and a high bit, you want to know the value of the bits in between. The simpler method is this: mask off (set to zero) the bits below the low bit and above the high bit. The remaining bits are the value you are interested in. Here's some code that should do the trick:
unsigned __int64 CMyBitsDlg::RevealBitsInLL(LONGLONG theNb,unsigned int lowBit,unsigned int highBit)
{
unsigned __int64 valueOfBits = theNb;
valueOfBits &= 0xFFFFFFFFFFFFFFFFI64 << lowBit;
valueOfBits &= 0xFFFFFFFFFFFFFFFFI64 >> (63 - highBit);
return valueOfBits;
}
Software Zen: delete this;
|
|
|
|
|
Thank you so much for your time.
Indeed,you perfectly understood what I am trying to do.
I called the function you kindly provided like this:
////////////////////////
unsigned _int64 valueLL=RevealBitsInLL(GivenLongLong,lbit,hbit);//using your function
strResult.Format("%I64u",valueLL);
GetDlgItem(IDC_MYRESULT)->SetWindowText(strResult);
/////////////////////
When I gave FFFFFFFFFFFFFFFF (16F)
lbit=0,hbit=63,
The result I am getting is:
4,294,967,295
(which is the decimal value of FFFFFFFF (8 F) )
The correct answer must be:
18,446,744,073,709,551,295
Is formatting "strResult" wrong ?
|
|
|
|
|
Your formatting is correct. You may need to modify the code I supplied as follows:
unsigned __int64 CMyBitsDlg::RevealBitsInLL(LONGLONG theNb,unsigned int lowBit,unsigned int highBit)
{
unsigned __int64 valueOfBits = theNb;
valueOfBits &= 0xFFFFFFFFFFFFFFFFI64 << (unsigned __int64)lowBit;
valueOfBits &= 0xFFFFFFFFFFFFFFFFI64 >> (unsigned __int64)(63 - highBit);
return valueOfBits;
} You should also check that the value of GivenLongLong is not getting truncated elsewhere in your code.
Software Zen: delete this;
|
|
|
|
|
You are right again,and this is what I did to avoid truncating the input.
unsigned _int64 GivenLongLong;
GetDlgItemText(IDC_MYHEX,hexNb);
//The input is a CString of valid hex chars
//Trying to convert it to an unsigned _int64,
//I wrote
//sscanf("%16X",&hexNb); //my error is here
//The correct conversion is
sscanf("0x"+hexNb, "%I64i", &GivenLongLong);
//////////////////////////////////
The result is now correct.
i.e for a LONGLONG of FFFFFFFFFFFFFFFF(16 F)
and lbit=0,and hbit=63,the result is:
18,446,744,073,709,551,615
Thank you so much for your time and effort.
|
|
|
|
|
I need to fill in an edit box, but in an another application. For example there is an application in which I need to fill in my first name... I want to write a program that will fill in the field of the first name...
Thanks in advance!
Have a nice day!
|
|
|
|
|
one way is to send WM_GETTEXTLENGTH/WM_GETTEXT message to the edit box.
suhredayan There is no spoon.
|
|
|
|
|
But how can I insert some text in an edit box not in my program? How can I know the ID of that edit box?
Have a nice day!
|
|
|
|
|
|
Hi all
My problem in short is, that I call an external console program and this goes wrong:
1. it stops showing its output after a certain point. But only if called by me
2. it asks for "anykey" at the end. yet it does not accept input from my
This only happens if called by me through CreateProcess. I use umeca74's class to redirect the programs output.
When called from the shell, all works well and I can press "anykey" to end the program.
Does anyone have a clue how I can solve Problem 1 + 2? I'm desperate
Thanx a lot in advance, pat le cat
|
|
|
|
|
Problem #1 sounds like an issue within the class you are using to redirect output. You may want to check with the original author of the article to see if he has any suggestions.
For problem #2, it could be the program you are calling is using one of the functions to 'read any key' that reads directly from the console, rather than from the standard input. If that is the case, you may need to use the SendInput() Windows API function to directly 'inject' a keypress into the keyboard input stream.
Software Zen: delete this;
|
|
|
|
|
Sounds interesting, but since I am creating a foreign process via CreateProcess, how I can send any input to this process? SendInput doesn't offer any parameter for that. I just tried it now and it didn't work. My app is a GUI (MFC) app and the one I'm lauching is a console.
Thanx for that quick answer.
To Problem #1, maybe the console app is using printf() for a few outputs, but is then switching over to some other (maybe unbuffered) kind of console output? How can I gather/intercept all console output?
pat le clueless
|
|
|
|
|
SendInput doesn't need to know which process you are intending the input for, since it is injecting keypresses into the keyboard input stream. It's as if you were pressing the keys on the keyboard yourself.
PatLeCat wrote:
To Problem #1, maybe the console app is using printf() for a few outputs, but is then switching over to some other (maybe unbuffered) kind of console output? How can I gather/intercept all console output?
There may be a method for intercepting console output. Try investigating this topic[^] in the MSDN, which discusses console applications.
Software Zen: delete this;
|
|
|
|
|
Thanx again for your answer Gary.
The thing is, I have not enough means to take over control of another process, as it seems. Sending the Input via SendInput might just do the same as if I was pressing any key, if it directly goes to the keyboard buffer. But I want to target this precise process, which I do by taking over the input-stream. But it didn't work anyhow
With std-redirect I do not take over control of the program but it's output stream. Whereas if it doesn't send output there, I cannot do anyting about it. Unless I find another stream I can take over....
Besides I don't have a console where I could read it's content from. I'm calling this program from my GUI app.
Sadly my problem remains unsolved. This is really very annoying. Something so little becomes such a huge nag.
|
|
|
|
|
I am in the process of debugging an SDI (Single Document Interface) program. I have a very big class (Engine Class) that I call from the FormView class, and I have a few values in the Document class. I use CreateFile, then CreateFileMappingObject to read and write data to and from files from the Engine class. When I tried to use Save As or Open from the Menu for a few integers (not related to the date I am using the File Mapping Object for) in the Document class, the program crashes. If I simply run the program without using Save or Open, it runs. Whenever I use Save or Open, after that, the program fails to map into the files. The data I save and retrieve using Save or Open are NOT related in any way to the FMO data.
When I ran the Engine class in Console mode, whenever I clicked on the (x) to close the program, I would get an error and it would crash. I was thinking it could be related to the CStrings I use, but Im not sure...
Can anyone help me??
If you have further specific questions, I will answer ASAP...
Thank you!
Kem
|
|
|
|
|
Is it possible to programmatically find out if the monitor is connected to the computer? I would be very grateful if someone could provide that answer!
|
|
|
|
|