|
That service has been around for years, and that site I posted is actually one of their recommend methods for getting the ip for client programs. The way it works is simple, since the webserver only sees your external IP on the packet, so that's what it shows. I can give you anything super specific, but that's the gist.
modified 12-Jul-20 21:01pm.
|
|
|
|
|
In a multithreaded VC++ program, how can I find %of CPU/ thread from within the program and report it? Also how can I find the memory footprint of the process from within the program? Is it possible? (Not using any external tools like perfmon, just using C++ code from the program itself)
|
|
|
|
|
|
Thanks. How to find the %CPU/thread?
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS pmc;
DWORD processID = GetCurrentProcessId ();
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
if (NULL == hProcess)
return;
if ( GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc)) )
{
printf( "\tPeakWorkingSetSize: 0x%08X\n",
pmc.PeakWorkingSetSize );
}
|
|
|
|
|
I found that using PDH these can be done. Was wondering if this can be done for individual processes, from within the program.
HQUERY m_hQuery; // the query to the PDH
PdhOpenQuery(NULL, 1, &m_hQuery);
PdhAddCounter(....)
How to use above function for individual processes?
|
|
|
|
|
I have a Date Time Picker in a toolbar, and I have a derived class of CDateTimeCtrl managing the UI object.
What I want to know is how do I specify which days in the month are bold when the user clicks the dropdown button to select the date?
Any help would be greatly appreciated.
Thanks
|
|
|
|
|
You can call CMonthCalCtrl::SetDayState() (MESSAGE: MCM_SETDAYSTATE) to set them or better yet respond to the MCN_GETDAYSTATE message that the control sends when it needs new information. This usually occurs when the month changes.
From my memory, there is an array of 32 bit values where each value represents a month and each bit represents a day. The on BITS cause the day to be bolded in the calendar if it has the MCS_DAYSTATE style set. There is all sorts of documentation on MSDN.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Hi, I created a class that uses the NtNative APIs found in the ntdll.dll. Everything works except the "Hive File" functions. Below is the "LoadKey" function:
<br />
BOOL CKey::LoadKey(CString csHiveFilePathName, ULONG ulFlags )<br />
{<br />
<br />
ASSERT(csHiveFilePathName != _T(""));<br />
ASSERT((m_csRootPath == _T("\\Registry\\User") || <br />
m_csRootPath == _T("\\Registry\\Machine")));<br />
<br />
BOOL bSuccess = TRUE;<br />
<br />
HANDLE hRootKey = NULL, hHiveFile = NULL;<br />
<br />
NT::UNICODE_STRING usRootKeyName, usHiveFileName, usHiveFile;<br />
NT::OBJECT_ATTRIBUTES DestinationKeyName, RegHiveFileName, RegHiveFile;<br />
<br />
int n=0;<br />
<br />
<br />
if (csHiveFilePathName.Left(4) != _T("\\??\\"))<br />
csHiveFilePathName.Insert(0,_T("\\??\\"));<br />
<br />
m_NtStatus = EnablePrivilege(SE_RESTORE_NAME, TRUE);<br />
if(!NT_SUCCESS(m_NtStatus))<br />
{<br />
bSuccess = FALSE;<br />
goto end_it;<br />
}<br />
<br />
WCHAR wszHiveFile[1024];<br />
for (n=0; n<csHiveFilePathName.GetLength(); n++)<br />
wszHiveFile[n] = (WCHAR)csHiveFilePathName[n];<br />
<br />
wszHiveFile[n++] = L'\0';<br />
<br />
usHiveFileName.Buffer = wszHiveFile;<br />
usHiveFileName.Length = wcslen(wszHiveFile) * sizeof(WCHAR);<br />
<br />
InitializeObjectAttributes(&RegHiveFileName, &usHiveFileName, <br />
OBJ_CASE_INSENSITIVE, NULL, NULL );<br />
<br />
WCHAR wszRootKey[2048];<br />
for (n=0; n<m_csRootPath.GetLength(); n++)<br />
wszRootKey[n] = (WCHAR)m_csRootPath[n];<br />
<br />
wszRootKey[n++] = L'\0';<br />
<br />
usRootKeyName.Buffer = wszRootKey;<br />
usRootKeyName.Length = wcslen(wszRootKey) * sizeof(WCHAR);<br />
<br />
InitializeObjectAttributes(&DestinationKeyName, &usRootKeyName, <br />
OBJ_CASE_INSENSITIVE, NULL, NULL );<br />
<br />
if (ulFlags == 0x0000)<br />
{<br />
if (m_ntModeType == 0)
m_NtStatus = NT::ZwLoadKey(&DestinationKeyName, &RegHiveFileName);<br />
else<br />
}<br />
else<br />
m_NtStatus = NT::ZwLoadKey2(&DestinationKeyName, &RegHiveFileName, ulFlags);<br />
<br />
if (!NT_SUCCESS(m_NtStatus)) <br />
{<br />
bSuccess = FALSE;<br />
}<br />
<br />
end_it:<br />
<br />
m_csFunction = _T("LoadKey()");<br />
if (ulFlags == 0x0004)<br />
m_csFunction = _T("LoadKey(2)");<br />
<br />
if (!bSuccess) <br />
Output(DisplayError(m_NtStatus), MB_OK|MB_ICONERROR);<br />
<br />
m_NtStatus = EnablePrivilege(SE_RESTORE_NAME, FALSE);<br />
<br />
<br />
if (!NT_SUCCESS(m_NtStatus)) <br />
{<br />
Output(DisplayError(m_NtStatus), MB_OK|MB_ICONERROR);<br />
m_csFunction = _T("");<br />
return FALSE;<br />
}<br />
else if (!bSuccess) <br />
{<br />
m_csFunction = _T("");<br />
return FALSE;<br />
}<br />
<br />
return TRUE;<br />
}<br />
Appreciate any help you can give me!!!
Regards,
Dan
|
|
|
|
|
to check if the mouse is outside a CWnd, have a look at TRACKMOUSEEVENT ( with TME_LEAVE ) and _TrackMouseEvent .
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
hmm.. i'm using mfc, that's some winapi stuff.. i never merged both things, tough i know that mfc is over winapi. How could i manage those messages if i can't see them in classwizard?
|
|
|
|
|
you can use it with MFC with no problem; the _TrackMouseEvent will generate a WM_MOUSELEAVE event/notification
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
void CView::OnMouseMove( UINT nFlags, CPoint point )
{
if ( ! ( nFlags & MK_LBUTTON ) )
{
if (!m_bTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE;
m_bTracking = (_TrackMouseEvent(&tme) == 1 )? true: false;
}
}
}
LRESULT CView::OnMouseLeave(WPARAM wparam, LPARAM lparam)
{
m_bTracking = false;
return 0;
}
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi, your code seems like it's going to work, but i don't quite understand it. I added the message and the OnMouseLeave function. That's ok. What i can't understand is what's inside your OMouseMove function.
what i basically want to do is this:
void CAreaPizarra::OnMouseMove(UINT nFlags, CPoint point)
{
if ((nFlags == MK_LBUTTON) && (mouse is inside))
{
do_one_thing();
}
else
if ((nFlags == MK_LBUTTON) && (mouse is outside))
{
do_another_thing();
}
would you mind explaining me what you did in your function so i can add it in this code?
thanks!
|
|
|
|
|
|
have a look at this[^], it can be very interesting for you...
TOXCCT >>> GEII power
|
|
|
|
|
i've solved it with:
ClientToScreen(&this->m_RectArea);
ClipCursor(this->m_RectArea);
Now, how do i unclip the cursor?
Those lines are in OMouseMove, while the lbutton is clicked.
I want to unclip it in OnLButtonUp
how could i do it?
thanks!
|
|
|
|
|
set a flag (a bool) into your class for example.
otherwise, i don't really understand... sorry...
TOXCCT >>> GEII power
|
|
|
|
|
With ClipCursor(Rect); , the mouse is trapped in that rect.
what should i call if i want the mouse to be free!.. so that i can move it over all the screen of my monitor?
something like ClipCursor(desktop) or something like that?
|
|
|
|
|
ClipCursor(NULL) did the job
thanks for reading the question!
|
|
|
|
|
|
Hi, i'm drawing in a 'CWnd derived' custom control. I want to know which message handles the following event:
When i'm moving the mouse over the control i click the button to insert points over a list. How do i know, when i'm still clicking the left mouse button, that the mouse has 'left' the area. I'm still clicking, but outside the area.
I want to know that, because when you stop clicking the mouse button, a cpoint -1,-1 is sent to the list, so a lineTo isn't drawn to that point.
I get the rect with Getclientrect, but i can't validate with that.
any ideas?
thanks!!
|
|
|
|
|
Hello everyone
I am using CreateCompatibleBitmap to create bitmaps of my list of worksheets. The problem is, when I hit around 20 bitmaps in a loop, the CreateCompatibleBitmap call begins to fail. I have traced into the MFC function calls and I discovered that the memory allocation on the HEAP has reached its limit for creating more resources.
Has anybody ever seen this before??
If not, does anybody have any suggestions??
Thank you for you help
IGeorgeI
George W
Software Developer
www.zsystems.ca
|
|
|
|
|
I've seen it when the bitmaps are very large, or leaked. I would try to structure the code so that I didn't need more than one bitmap at any given time, making sure to properly deselect them from any CDC , if appropriate. And, of course, calling DeleteObject , either directly or by having the dtor of the CBitmap invoked.
|
|
|
|
|
How big are the bitmap sizes?
I used CreateCompatibleBitmap often in code I work with, and have not come across this issue. I very interested in what the bitmap sizes are, that cause the heap to fill up.
thanx
|
|
|
|
|
Hello.
I'm doing a small drawing application, which is multi-client.
I've implemented a pen. When you press the button and keep the mouse pressed you insert CPoints in a list, and i create a string with the points and send it with the socket.
The problem is, that i'm sending many points a second (i send in OnMouseMove) and the other user receives them, but sometimes not in order.
For example i send a,b,c,d,e,f and the user receives a,b,d,c,e,f.
How could i solve that? i tought of a buffer of ten points, so when ten points are written, a string with points is sent, to avoid the order problem.
i am sure somebody has had this problem before (or something similar).. what could i do?
thanks!!!
|
|
|
|
|
I suggest sending the array of points when the user releases the mouse.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|