|
//
// Link with ws2_32.lib and iphlpapi.lib
//
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include <iphlpapi.h>
int __cdecl main()
{
HRESULT hr;
IPAddr ipAddr;
ULONG pulMac[2];
ULONG ulLen;
ipAddr = inet_addr ("216.145.25.31");
memset (pulMac, 0xff, sizeof (pulMac));
ulLen = 6;
hr = SendARP (ipAddr, 0, pulMac, &ulLen);
printf ("Return %08x, length %8d\n", hr, ulLen);
size_t i, j;
char * szMac = new char[ulLen*3];
PBYTE pbHexMac = (PBYTE) pulMac;
//
// Convert the binary MAC address into human-readable
//
for (i = 0, j = 0; i < ulLen - 1; ++i) {
j += sprintf (szMac + j, "%02X:", pbHexMac[i]);
}
sprintf (szMac + j, "%02X", pbHexMac[i]);
printf ("MAC address %s\n", szMac);
delete [] szMac;
return 0;
}
|
|
|
|
|
Hello,
How can I enumerate all handles used by a process?
(I mean files, sockets, mutexes, etc. and also GDI handles)
Which function API do this???
Thanks.
|
|
|
|
|
There is no publicly documented Win32 API to do this.
However there are some functions which will do this in the api for ntdll.dll. The book Windows NT/2000 Native API Reference documents these functions and gives examples of how to use them.
Search for NtQuerySystemInformation() on the web.
You want to query for class SystemHandleInformation, this has a value of 16.
Then to determine the handle type, call NtQueryObject()
Note that these APIs or the data input/returned may change between NT/2000/XP/etc.
There are some classes on CodeGuru that do examples of this work, but they are broken, as the data structures used to query the APIs are incomplete and incorrect - compare with the book and you'll see what I mean.
Cheers
Stephen Kellett
--
C++/Java/Win NT/Unix variants
Memory leaks/corruptions/performance/system problems. UK based.
Problems with RSI/WRULD? Contact me for advice.
|
|
|
|
|
With psapi functions like EnumProcessModules
Best Regards....
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Hi Carlos,
I look closely to EnumProcessModules,
also try to found some samples on the web,
but it seems this function can help only to
enumerate processes, not handles used by them.
Regards.
|
|
|
|
|
Hello Xperts,
I need to remove application icon from alt+tab list, please post the solution, if you know.
Thanks in advance..
KGS
|
|
|
|
|
|
Great Tomasz Sowinski..
Thanks for quick reply, I have to try..
KGS
|
|
|
|
|
How to realize moving picture using hand-like cursor. just like Imaging For Windows at windows accessory.
|
|
|
|
|
Hi,
can someone give me some information about using Stingray Objective Grid 97 Control? I had read the documentation but it´s very bad! Or has someone a tutorial about it??
thanks
Simon
|
|
|
|
|
|
Hi out there,
I'm working an instrument based on the Windows CE operating system. The applications is now to be translated into Japanese.
I have found a true type font "MS Gothic.ttf" that supports Japanese charactes. That works fine except for titles in dialogs that use the sysytem font.
I don't want to link the font into the OS image but instead load a system font dynamically.
I have tried to modify the registry:
[HKEY_LOCAL_MACHINE\SYSTEM\GDI\SYSFNT\Nm] from Tahoma to MS Gothic
[HKEY_LOCAL_MACHINE\SYSTEM\GWE\Menu\BarFnt\Nm] from Tahoma to MS Gothic
[HKEY_LOCAL_MACHINE\SYSTEM\GWE\Menu\PopFnt\Nm] from Tahoma to MS Gothic
[HKEY_LOCAL_MACHINE\SYSTEM\GWE\OOMFnt\Nm] from Tahoma to MS Gothic
But it doesn't work.
Any ideas??
Jørgen Belfalas
|
|
|
|
|
Hello,
I have a problem with text selection. I want to get the highlighted text that users double click on it (not only in my own application). Do I have to use COleDataObject to implement this? Is this about clipboard?
I'm a beginner. Guide me, please.
|
|
|
|
|
Yes, it's about clipboard. This code places the contents of strClipboardText variable in clipboad. You'll probably use CEdit::GetSel and CEdit::GetSel and CEdit::GetWindowText to get this string.
CString strClipboardText = ...;
if (!OpenClipboard() || !EmptyClipboard())
{
AfxMessageBox("Error: can't open the clipboard.");
return;
}
HGLOBAL hglbText = GlobalAlloc(GMEM_MOVEABLE, 1 + strClipboardText.GetLength());
char *pData = (char *)GlobalLock(hglbText);
lstrcpy(pData, strClipboardText);
GlobalUnlock(hglbText);
SetClipboardData(CF_TEXT, hglbText);
CloseClipboard();
Assuming that you're using CEdit control, there will be a problem with double-clicking - this action highlights the *word* you're clicking on. Previous selection is lost. You may try to override WM_LBUTTONDBLCLK to change this behavior.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thank you very much.
But there's a problem. I didn't get highlighted text from edit box but i want to get highlighted text from anywhere on screen (ex. in browser, spreadsheet, notepad, etc.). How can I get it? Guide me, please.
|
|
|
|
|
When a string which contains more than 260 characters is inserted in a CListCtrl only the first 260 characters are visible. The string is not truncated cause GetItemText returns the hole string. Any ideas how to show the hole string in the CListCtrl?
Ha dé
Lloyd Cole
|
|
|
|
|
Try to custom-draw the control. There should be some articles about that in the listctrl section of CP.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
hi,
I’m trying to write a plugin or anything else that will do the job to allow me to put an icon onto Internet Explorer and add some functionality to this icon.
Does anybody know how this can be done?
Cheers
Dor
|
|
|
|
|
Line for line I can't help you, but there are examples of what I think you are looking for here at CP, the greatest place on earth (virtual anyways).
Do a search for IE Toolbar.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I am making a multithreaded app that connects to a serial port and already lots of people here have been a great help!
At the moment I have several threads, two in particular (which coincidentally I have put in a seperate dll) are called RxThread and TxThread, obviously controlling the transmission and receiving of data from the serial port.
What I am trying to do is have a CEvent that I can signal with the RxThread when I have received a reply from a message sent using TxThread (to serial). I know in TxThread I want to WaitForSingleObject for a little while, and if timedout check for messages to TxThread (ie WM_QUIT, not serial messages) and Retry sending (to Serial)!
The trouble is I'm not sure how to create the CEvent object so that I can set it with the RxThread each time I get a reply, and wait for it in TxThread so I can block the thread for a little while!
Thanks for any help
-Mark
|
|
|
|
|
Option 1. The RxThread and TxThread belongs to the same process:
- create unnamed CEvent object;
- create RxThread object and pass the reference to the unnamed CEvent object;
- create TxThread object and pass the reference to the unnamed CEvent object;
Option 2: The RxThread and TxThread belongs to different processes:
Both threads must create named CEvent class object with the same name.
|
|
|
|
|
How would you create and implement styles into your own custom class? Thanks for you replies in advance.
-CDuddley
|
|
|
|
|
CDuddley wrote:
styles
Styles ???
Max.
|
|
|
|
|
I'll assume you mean styles like WS_VSCROLL and such...?
Umm...well I dunno if windows reserves all 32 bits of the DWORD nStyle paramter, but you could find out pretty easy and use bit locations that weren't used or use a DOWRD StyleEx and set your own bits using bitwise OR's.
Like this overloaded version of Create
Create(CWnd* pParent, DWORD nStyle)
{
CWnd::Create(nSytle...blah);
}
For instance if bit 17 wasn't already used by CreateWindow() you could use it to specifiy SHOW/HIDE 3D borders around custom button control.
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
How do you handle them I guess is what I was wondering. Say you have an enumeration.
enum { ID_STYLE1 = 0, ID_STYLE2 = 1, ID_STYLE3 = 2 };
How do you handle the those styles in a function with the bitwize OR and AND ops? Thanks for the inputs in advance.
-CDuddley
|
|
|
|