|
LOL, it is not that difficult, you just need to spend a lot of time reading and experimenting.
Martin
--------------------------------------------
C'mon we all know computers are experimental devices and should only be used for playing games.
Using them for alternative stuff like business, is clearly not using them for what they are intended.
Colin Davies
|
|
|
|
|
The best thing about windows security -- is that you don't have to understand it. All those functions that want a SECURITY_ATTRIBUTES pointer happily accept a NULL pointer!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Everyday I think more and more to move on linux
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
and still it works, using NULL indicates that default attributes for the process will be used hence the job is done for you. if you need a different attributes then you can set them up, used to be pretty dull and long code but it is getting better. get hold of books 'Writing Secure Code' and 'Writing Secure Code for Windows Vista', that's good start.
Martin
--------------------------------------------
C'mon we all know computers are experimental devices and should only be used for playing games.
Using them for alternative stuff like business, is clearly not using them for what they are intended.
Colin Davies
|
|
|
|
|
Lord_Draconis wrote: Is there a decent way to check if the user currently logged in is the Administrator??
Use IsUserAnAdmin .
Nibu thomas
Microsoft MVP for VC++
Code must be written to be read, not by the compiler, but by another human being.
Programming Blog: http:\\nibuthomas.wordpress.com
|
|
|
|
|
Lord_Draconis wrote: Is there a decent way to check if the user currently logged in is the Administrator??
char szName[64];
GetUserName(szName, sizeof(szName));
strcmp(szName, "Administrator"); I'm not sure how useful this is going to be, however. I would think you'd want to know if the currently logged on user was a member of the Administrator group or not.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi everybody,
I'm looking for a kind of MFC class that provides text sliding effects. I mean, I need to have an Edit box where the text inside it goas from the right to the left continiously.
Does anyone know where can I find this kind of class?
Thanks a lot!
Mikel
-- modified at 8:17 Wednesday 14th November, 2007
|
|
|
|
|
iam not sure about any class which can do this, but using some CString manipulations,thread concept and sleep, this can very well be acheived.
if you want this logic, then i can share it with you.
--------------------------------------------
Suggestion to the members:
Please prefix your main thread subject with [SOLVED] if it is solved.
thanks.
chandu.
|
|
|
|
|
Just make a search on the articles on Codeproject, I remember having seen such controls.
|
|
|
|
|
Hello,
I am working on some financial data .I am picking up data from the dump file in a byte type variable . I have encountered a statement that is confusing me a lot a simple example or statement might be helpful :
"empsalary are two-byte integers, high order first, and negatives are
signed magnitude. Users may have to swap the bytes and/or convert negatives
to the complement they use. This can be done by putting the low order byte
first, then turning off bit 15 (the high order bit), then multiplying by -1.
For positive numbers, only the bytes are switched."
what does the above statement really means??
|
|
|
|
|
You are about to learn about endian issues. You can read all about it on the wikipedia[^]
This is an long standing issue -- and is based on the processor on your computer. For all of us Windows, we operate as "little endian" -- whereas mac and java folks operate in "big endian" format.
Endianness is just how the processor stores numbers in byte format. There's some handy functions used for socket programming (but also available generally) -- see ntohs()[^]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Peter Weyzen wrote: For all of us Windows, we operate as "little endian" -- whereas mac and java folks operate in "big endian" format.
Endianness is just how the processor stores numbers...
So if the processor ultimately determines how the numbers are stored, what difference does the OS or the programming language make?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
it was just a generalization -- about how windows runs on intel, and intel is little endian
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
IMHO the above statement is clear:
values are stored inside the file as two bytes integers, with most significative byte first, for instance 1000 (that is 03E8h in hexadecimal notation) is stored as follows:
first byte = 3 (03h); second byte = 232 (E8h)
that is:
3 * 256 + 232 = 768 + 232 = 1000</code>.
On the other hand, negative numbers are stored using Sign and magnitude representation (see [^]), hence -1000 will become 83E8h in hexadecimal notation ( 8h=1000binary , i.e. sign bit ON ).
Whenever you need to retrieve values you have to always check the sign bit. I give a C code snippet (error checking is left as an exercise to the reader... ):
unsigned char a,b;
int value;
fread(&a, sizeof(a), 1, fd);
fread(&b, sizeof(b), 1, fd);
value = ((a & 0x7F) << 8 ) | b;
if ( a & 0x80)
{
value = -value;
}
Hope that helps
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Thanks a Lot CPallini , by the way your mentioned code can go in error state ???
|
|
|
|
|
Well, you have always to check the return value of the fread function.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi All,
I am using MFC Activex Control project in VS 2005.
In my project I am doing something like hooking. I have set these hooks from application.In this hooking , I have created some windows procedure(using CALLBACK function) through which I get messages into it contineously(Messages are like when my desktop window changed,cursor position changed,anything something happens on the the screen).For this I have to check contineously for update.
And now my problem is like that when I call this hooking function than it starts executing and it does well and here I get all tese messages perfactly but during these constant message transfering my cpu usage goes upto 50%.So, that is very bad for me I want to reduse this cpu overhead near upto 10%.So, do you have any suggetion what to do for that???
I will Appreciate your Answer.
Thanks in Advance.
Ashish Bhatt
|
|
|
|
|
Here I am using below code to contineously checking for the messages.
<br />
MSG msg;<br />
<br />
while(1)<br />
{<br />
<br />
if(!PeekMessage(&msg,m_hwnd,NULL,NULL,PM_REMOVE))<br />
{<br />
CheckUpdate();<br />
}<br />
else if(msg.message == SCREEN_UPDATE)<br />
{<br />
<br />
RECT rect;<br />
rect.left = (SHORT)LOWORD(msg.wParam);<br />
rect.top = (SHORT)HIWORD(msg.wParam);<br />
rect.right = (SHORT)LOWORD(msg.lParam);<br />
rect.bottom = (SHORT)HIWORD(msg.lParam);<br />
<br />
<br />
<br />
<br />
m_region.AddRect(rect);<br />
<br />
<br />
<br />
<br />
}<br />
else if(msg.message == MOUSE_UPDATE)<br />
{<br />
MessageBox(NULL,CString("Mouse Update Message is Received"),CString("RTMPTest"),0);<br />
}<br />
else<br />
{<br />
MessageBox(NULL,CString("Peek UP Message But Not Update Messsage"),CString("RTMPTest"),0);<br />
}<br />
}<br />
Plz do helpful to me if you have any idea.
Thanks.
Ashish Bhatt
|
|
|
|
|
while (1)
{
// peek...
}
Add a Sleep(100) as a simple start...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Peter Weyzen wrote: Add a Sleep(100) as a simple start...
if any message come between that sleep(100) will be lost or delayed to processed by main application, as hook is working here
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
So, if you have any other suggetion then you can share it.
Ashish Bhatt
|
|
|
|
|
Thanks for reply.
i used sleep() before Peekmessage() and it works.But is there no any other way?.
And also I want to ask one question that is it right way to check current process cpu usage from task manager?? because I have heard that it is not perfact way.
Thanks.
Ashish Bhatt
|
|
|
|
|
Did you see my suggestion ? What about using GetMessage instead of PeekMessage ?
|
|
|
|
|
Use GetMessage instead of PeekMessage. This way, the GetMessage will block until a message is received in the queue. And you won't need to poll for messages (which consumes CPU cycles).
Also, you should check for the WM_QUIT message (and exit your infinite loop) otherwise your application will never terminate.
|
|
|
|