|
"_$h@nky_" wrote: how can i get details of CPU and Memory usage that is used by my application.
See GetProcessTimes()[^]
What memory usage? The working set? If yes, then see GetProcessWorkingSetSize()[^].
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
I have a SDI type application in MFC.
I want to get information same like Window Task Manager display.
like My exe name is Test.exe
so in Processes Tab of Window Task Manager display the information like this.
Image Name="Test.exe"
User Name="";
CPU="07";
Memory="4,564K";
Description="Test";
Please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
|
Rajesh R Subramanian wrote: "_$h@nky_" wrote:
CPU="07";
Memory="4,564K";
Description="Test";
See Getting hardware information[^]
I m using this but i dont have information like i mention above.
please help me for this.
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
read(fd,buf,1) is so common that I do not need to explain its arguments.
Where can I find the source code for it?
|
|
|
|
|
read is a really common function you are correct so common we cant really determine what platform your on?!?!
i am guessing linux from unistd.h ??? if this is the case then you should have it on the machine already, in one of those ddep dark corners of the system.
|
|
|
|
|
Yes, Linux, C applications. I'm not looking for the header, I'm looking for the source code of the function.
Thanks.
-- frank
|
|
|
|
|
im saying that the .c file is on your PC...
i think that read just passes params down to syscall() if that helps
modified on Saturday, July 25, 2009 4:11 AM
|
|
|
|
|
342 asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
343 {
344 struct file *file;
345 ssize_t ret = -EBADF;
346 int fput_needed;
347
348 file = fget_light(fd, &fput_needed);
349 if (file) {
350 loff_t pos = file_pos_read(file);
351 ret = vfs_read(file, buf, count, &pos);
352 file_pos_write(file, pos);
353 fput_light(file, fput_needed);
354 }
355
356 return ret;
357 }
358 EXPORT_SYMBOL_GPL(sys_read);
found this snippet on interwebbs also http://www.gelato.unsw.edu.au/lxr/source/fs/read_write.c[^]
|
|
|
|
|
My MFC application needs to monitor a directory on a network disk (mapped as Z , and I'm using FindFirstChangeNotification() to do this. However, I am getting an INVALID_HANDLE_VALUE returned, and GetLastError() return 56 (which appears to be "The network BIOS command limit has been reached."
If I change the path of the monitored folder to a local drive, it works fine. How do I get over this problem ? (MSVC 6.0 - Win2000) (All the results from a Google search only seem to refer to a server situation)
Doug
|
|
|
|
|
can you post a code snippet or something to work with?
|
|
|
|
|
Here is the code in my worker thread, as requested:-
UINT WaitNewScheduleThread(LPVOID Param) //20090723
{
CWinThread* pThread = AfxGetThread();
int iID = pThread->m_nThreadID;
CString szLogMsg;
szLogMsg.Format("\n>>> Worker thread ID = 0x%X\n",iID);
OutputDebugString(szLogMsg);
CMCManagerBEDlg* pDlg = (CMCManagerBEDlg*)Param;
CMCManagerBEApp* pApp;
pApp = (CMCManagerBEApp*)AfxGetApp();
HANDLE hCN;
CString szPathName;
szPathName.Format("Z:\\WinDVR");
//szPathName.Format("C:\\Dell");
// Set up array of two handles
HANDLE hExitEvent;
hExitEvent = pApp->m_hExitEvent;
HANDLE handles[2];
int iRetCode;
DWORD dwRC;
DWORD err;
do
{
hCN = FindFirstChangeNotification(szPathName,FALSE,FILE_NOTIFY_CHANGE_FILE_NAME);
if(hCN == INVALID_HANDLE_VALUE)
err = GetLastError();
handles[0] = hCN;
handles[1] = pApp->m_hExitEvent;
dwRC = WaitForMultipleObjects(2,handles,FALSE,INFINITE);
if(dwRC == WAIT_OBJECT_0)
{
szLogMsg.Format("Found new file on %s",szPathName);
g_pLogFile->Add(szLogMsg);
OutputDebugString(szLogMsg);
if(g_pDlg->m_bPermitSchedUpdate)
g_pDlg->ProcessNewSchedule();
else
g_pDlg->m_bNewSchedAvailable = TRUE;
iRetCode = 0;
}
if(dwRC == WAIT_OBJECT_0 + 1)
{
szLogMsg.Format(">>> New recording schedule thread terminated\n");
OutputDebugString(szLogMsg);
g_pLogFile->Add(szLogMsg);
iRetCode = 9;
break;
}
if(dwRC == WAIT_FAILED)
{
szLogMsg.Format(">>> Wait failed");
OutputDebugString(szLogMsg);
}
}
while(TRUE);
return iRetCode;
}
Doug
|
|
|
|
|
so i think because your polling the call FindFirstChangeNotification() in an infinite loop it cries
might try adding a lil timer to the thread and put the contents of the do{}while(1) in the thread OnTimer event setting the polling interval to be something sensible
|
|
|
|
|
But the loop gets suspended at WaitOnMultipleObjects() after the very FIRST invocation of FindFirstChangeNotification(). (The whole reason for using this approach is to get away from a polling mechanism which introduces a delay) As I said originally, the code works fine when the target is a local disk - something to do with network, and I don't know how to fix it !!)
Doug
|
|
|
|
|
i am thinking that WaitOnMultipleObjects()doesnt "wait" that long (assumption about to make an ass of me) try printing out a gettickcount() or something in the do loop and see if that is the case.
[edit]
and yes assupmtion has made an ass of me once again
http://support.microsoft.com/kb/810886[^]
[edit]
|
|
|
|
|
Hi Killabyte, Actually, I'm getting the problem single-stepping in the debugger, so the loop isn't executing as such. Also the WaitOnMultipleObjects() has an INFINITE timeout. I don't quite know how FindFirstChangeNotification() is implemented, but presumably the problem resides in the firmware of the network disk controller - have logged on to it, but can't see any parameters in the SMB server that I can tweak. Or am I missing something here ?
Doug
|
|
|
|
|
see my edit above =) think that is your issue... i was barking up the wrong tree
|
|
|
|
|
Hi again, I had seen <a href="http://support.microsoft.com/kb/810886[^]">http://support.microsoft.com/kb/810886[^]</a>[<a href="http://support.microsoft.com/kb/810886[^]" target="_blank" title="New Window">^</a>] already - it only seems (unless I have missed something) to address the situation where the FindFirstChangeNotification() is aimed at a SERVER and then you can edit it's registry accordingly. In this case, the target is a network disk and that is why I logged on to it to see what parameters were available for tweaking - basically none !) I'd be surprised if I'm the first person to hit such a problem !
P.S. I clearly don't know how to insert a link (copied from a previous posting) in a new posting !!
Doug
|
|
|
|
|
oh crap. so your saying that there is no registry edit applicable on your target network disk?
i would have thought that if there is no "server" so to speak of then the client side registry would be altered? but then again who said logic plays a part in software development haha
|
|
|
|
|
Hi Killabyte, Yes !! When you logon to 192.168.1.9 using a browser, the facilities provided are minimal. Don't forget that the whole thing is implemented in firmware !! Basically, I'm beginning to think that I'm at it's mercy, and I'm stuffed !!! (Will have to stick with my old polling mechanism after all ... unless someone knows different ...... !
Doug
|
|
|
|
|
Hi,
a quick look at the code shows that the handle will not be closed.
From MSDN:
When the handle is no longer needed, it can be closed by using the FindCloseChangeNotification function.
So I guess the error will show up after the loop has been executed a few times?
Regards
Frank
|
|
|
|
|
Hi Frank, Getting the problem whilst single-stepping in the debugger !
Doug
|
|
|
|
|
I got the same problem as you have, but never found a solution. Thaught then that it was because i use Linux with Samba as the networkserver.
Rozis
|
|
|
|
|
I think I am missing out something but dont know exactly where I am wrong ...
I am getting followinf Error in MS Visual Studio8 (Error C2106 : '=': left operand must be |-value..... (I am not getting wht this error iss for..........? )
My Src Code --
# define MAX_TP_DATA_BYTES 60
typedef struct
{
sHeader Header;
unsigned char Data[MAX_TP_DATA_BYTES];
} sPacket;
I have pointer to packet *psPAcket
Than I have an array called
unsigned char ArrayData[MAX_TP_DATA_BYTES];
No what I am trying to do here is I am assigning the "Data" information in struct "sPacket.Data" to "ArrayData".
ArrayData = psPacket->Data; --- and this where its giving me error.... am I dng somehtign wrong...
Plz can anyone help me....
THanks!!!!!
|
|
|
|
|
You can't just assign arrays like that. You need to copy the contents of the source array to the destination array.
memcpy(ArrayData, ps->Data, MAX_TP_DATA_BYTES);
If you are using VS2005 or later you really should use the safer memcpy_s method instead because the memcpy method has been deprecated. The difference is that the memcpy_s method takes an extra parameter stating the size of the destination buffer and the method also now returns an error_t .
memcpy_s(ArrayData, MAX_TP_DATA_BYTES, ps->Data, MAX_TP_DATA_BYTES);
Kelly Herald
Software Developer
|
|
|
|