|
|
I can also suggest to use FTPClientSession class in Poco C++ library. (it does not depend on MFC).
|
|
|
|
|
Also I can advise you to find in Ultimate TCP/IP package (no dependance on MFC). (it is availbe here in CP)
Good luck.
|
|
|
|
|
|
Is it possible to measure the total duration of a certain thread that is spent on its "running" state ? Of ourse between two given absolute time values.
In the past I thought that QueryPerformanceCounter achieves this by querying a counter that is incremented each time that a particular thread spends an addtional CPU cycle.
I found this wrong after a simple test where I measured the time using QPC between a simple ::Sleep operation and found it equal to the exact value passed as parameter to ::Sleep.
Hence the idea is then to take the difference between the absolute time difference and the QPC derived period then deduce the amount of time that the thread has spent on its bloocking state ie eg when it has delagated work to another thread, (WaitForEvent,etc).
Is there any help of any kind ?
Thank you in adavnace.
Ahmed.
|
|
|
|
|
hINTModuleState wrote: I found this wrong after a simple test where I measured the time using QPC between a simple ::Sleep operation and found it equal to the exact value passed as parameter to ::Sleep.
Well, it's wrong but not for the reasons you think since your test doesn't do what you seem to think it does.
::Sleep() is a busy-wait, which means that it's continuously asking "are we there yet" consuming CPU time, or in other words "burning MIPS".
Thus your measurement would be correct; i.e. you thread has in fact been running for the same amount of time as you've instructed it to in the call to ::Sleep() .
To make a thread "sleep" in the sense that it doesn't use any CPU time, or rather as little as possible, you should wait on a waitable timer with a call to e.g. ::WaitForSingleObject() .
What you should use to measure the execution time for a thread is ::GetThreadTimes() , read more here[^].
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Thank you for this knowledgeable response indeed.
My expectation was that <code>::Sleep</code> triggers a timer before blocking until the thread is again awaiked by an asynchronous call from the system which checks for the clock and the timer values.
::GetThreadTimes has evrything : the blocking-time it provides is much accurate than what the difference I was going to do between the absolute clock period and the one I would have deduced from the two calls to QPC..what it wooud have given to me.
It is exactly becuase of the same scenario that mades akirilov's statement that Sleep is accurate than WM_TIMER a false statement : that of (the scenario [I'm beginning to notice that my langage is not so often understood]) the effect of multithreading. [I expect that running a chess engine on the background affects the observable period that the thread running ::Sleep code is perceiving..]
|
|
|
|
|
hINTModuleState wrote: Thank you for this knowledgeable response indeed.
You are most welcome.
I strongly recommend that you read the two articles I linked to in my response to akirilov if you haven't done so already.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
|
hINTModuleState wrote: Joseph NewComer again !
So?
Would you rather have I provided a link to Charles Petzold, Mark Russinovich or Matt Petriek instead where they state the same fact?
I think Newcomer's site is a fantastic gold mine of information regarding development for Win32. The information is accessible, pedagogic and easy to understand. It clearly states what to do and what not to do, and usually why which is quite rare.
I've been developing for windows platforms for about 15 years and I've found that following the advices on Newcomer's site, helps a lot of people to stay out of trouble.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Roger Stoltz wrote: I think Newcomer's site is a fantastic gold mine of information
That is exactly the point !
|
|
|
|
|
hINTModuleState wrote: That is exactly the point !
Enjoy!
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
In the past I thought that QueryPerformanceCounter achieves this by querying a counter that is incremented each time that a particular thread spends an addtional CPU cycle. It measure the CPU cycles from the turning on the PC, not "a particular thread" (this include all other threads).
You received the same result as Sleep, because ... well, Sleep is very accurate, that is why people use it instead of WM_TIMER.
Now to your question ... QueryPerformanceCounter will not do the job.
P.S. I doubt it cost a CPU time, as previously somebody stated, at least not more than WaitForSingleObject.
modified on Monday, November 24, 2008 10:39 AM
|
|
|
|
|
akirilov wrote: Sleep is very accurate, that is why people use it instead of WM_TIMER.
I'm sorry, but you are so incredibly wrong.
Using ::Sleep() is a common mistake and is almost always wrong.
Read more here[^] and here[^] before advising someone on this matter.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hello,
I used the following procedure to find if the app is running under administrator account on XP:
IsUserAdmin()
{
BOOL b;
SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
PSID AdministratorsGroup;
b = AllocateAndInitializeSid(
&NtAuthority,
2,
SECURITY_BUILTIN_DOMAIN_RID,
DOMAIN_ALIAS_RID_ADMINS,
0, 0, 0, 0, 0, 0,
&AdministratorsGroup);
if(b)
{
if (!CheckTokenMembership(NULL, AdministratorsGroup, &b))
{
b = FALSE;
}
FreeSid(AdministratorsGroup);
}
return(b);
}
The problem is that it will always return FALSE when running on Vista even if the account is with administrator's rights. That's because of the UAC, I guess. But how to check the real account type?
Thank you.
|
|
|
|
|
mkoroudjiev wrote: The problem is that it will always return FALSE when running on Vista
It will return TRUE if the process is running on Vista AS an administrator.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
OK, this is obvious. But how to find whether an account is standard or administrator's if the user is running the app with non elevated privileges?
Martin
|
|
|
|
|
mkoroudjiev wrote: this is obvious
Not when your topic is "How to check if running under administrator account on Vista".
From the context of your app, it doesn't matter - if the app isn't running
elevated then even if an administrator is the invoker of the app, there's still
no administrative privileges for the app.
Checking if a user is a member of an administrator group is a different thing.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I understand your point. Any suggestions on how to check if a user is a member of an administrator group?
Thanks.
|
|
|
|
|
|
Hi All
How can i get installation path of application?
|
|
|
|
|
Well it all depends on the approach a developer takes.
Do you want to acquire the installation path of your application itself?
If yes, than you should have the source code and you must be writing it somewhere in the registry (ideally) or to some text file during the installation. You can read it from either of the places.
If it's the installation path of a third party application, that you need than you need to know before hand where they are writing it.
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
You can use GetModuleFileName to get the full path to your application.
Good luck.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Do you want to get the path of an installed application which is listed in the Add/Remove programs?
If yes, then,
Windows keep the un-installation information under this registry key - HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall . Under this key for each item there will be DisplayName subkey, which holds the name of application and InstallLocation subkey, which holds the path of the installed application.
Refer this article[^] about how to iterate through the registry uninstall information and get those values.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
I am using the listview in record view mode . Now I have selected the Listview row and it becomes blue . Now I want to remove the selection of this row without clicking on the list view . I want to write code on button click . is there any message to send to listview to diselect the row .
Ashish
|
|
|
|