|
typedef byte SkNetMAC[6];
bool FkNetGetMacA( CkStr SA, SkNetMAC &MAC )
{
if( SA.IsEmpty() ) return(false);
#if 1 // get local or remote MAC given an IP using ARP (Win2K+)
ulong rc = 0,
ml = sizeof(MAC);
IPAddr ip = inet_addr( SA.PtrSafe(0) );
rc = ::SendARP(ip, 0, (ulong*)&MAC, &ml);
#else // get local MAC associated with IP by querying adapter info (Win*)
ulong rc = 0,
al = 0;
IP_ADAPTER_INFO *ai = NULL,
*ac = NULL;
IP_ADDR_STRING *ip = NULL;
rc = ::GetAdaptersInfo(ai, &al);
if( rc != ERROR_BUFFER_OVERFLOW ) return(false);
ai = (IP_ADAPTER_INFO*)ckMemTemp.Calloc(al);
if( !ai ) return(false);
rc = ::GetAdaptersInfo(ai, &al);
if( rc != ERROR_SUCCESS ) goto e_FkNetGetMacA;
for( ac = ai; ac; ac = ac->Next ) {
for( ip = &ac->IpAddressList; ip; ip = ip->Next ) {
if( SA == ip->IpAddress.String ) {
FkMemCpy(ac->Address, &MAC, sizeof(MAC));
goto e_FkNetGetMacA;
}
}
}
e_FkNetGetMacA:
ckMemTemp.Free(ai);
#endif
return(true);
}
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Am looking for PHP code to get the Mac address of a machine and I think you got the answer.
|
|
|
|
|
hi there,
I am using WaitForMultipleObjects api function . always it works fine. but some times the function could not return. even after the timeout periord elapsed. i think it will be a problem of dead lock . how can i avoid the same.
advance thaks for your help.
thanks and regards
S. Mohamed Hasan.
|
|
|
|
|
hi there,
I am using WaitForMultipleObjects api function . always it works fine. but some times the function could not return. even after the timeout periord elapsed. i think it will be a problem of dead lock . how can i avoid the same.
advance thaks for you help.
thanks and regards
S. Mohamed Hasan.
|
|
|
|
|
Hi,
If you create a thread using ::CreateThread(...) it returns a handle to the thread. Once the thread has completed its job the thread has two options depending on other factors whether it will call ::ExitThread(...) or just return.
The question is, do you have to call ::CloseHandle(...) on each of the handles passed back by ::CreateThread(...)?
cheers,
Rich
"Programming today is a race between software engineers striving to build bigger and
better idiot-proff programs, and the Universe trying to produce bigger and better idiots.
So far the Universe is winning." -- Rich Cook
|
|
|
|
|
Yes you *DO* need to use CloseHandle for each thread you have created.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
Yes, you must close all handles that you're given. Failing to do this causes the kernel's internal thread object to leak (it's reference counted). The only exceptions are the pseudo-handles you get from GetCurrentThread or GetCurrentProcess . The OS will clean up any outstanding handles when your process ends, but you shouldn't rely on this.
Typically if I don't actually need a handle I'll close it straight away.
Stability. What an interesting concept. -- Chris Maunder
|
|
|
|
|
Dear Friends,
I wish to operate a Dialog Based application(Say Server) depending upon the command send by the Client.
Please help me by giving me a simple example to do so.
Thanking you in advance.
Regards,
Billar
|
|
|
|
|
|
Hi,
I am developing Addins for office application n i want to load the Addin when the application launches. Anybody please tell how do i start with.....
Thank You
Vishal More
|
|
|
|
|
I have been having a problem deploying a Visual Studio application. It is quite a simple standalone application, but when deployed nothing happens when it is run.
I did a Viaual Basic 6.0 simple application and using the VB deployment facilities it runs OK.
Another Visual Studio application, much larger than the one that does nothing when run, works OK.
Does anyone know if this is a known Windows problem and if they are a work around.
I did use another project groups InstallShield to deploy the application, but that also did nothing when run.
|
|
|
|
|
You will want to test your app with depends.exe, which you will probably find on your harddisk. You will probably have to install the MFC dll as a part of the deployment, for example.
You will also want to make sure what all the dependencies are, as some are not redistributable and some are standard on all Windows installations. Search for the DLL-name on MSDN.
You will also want to version check DLL:s you install, unless you enjoy creating havoc and being all-round impopular. Your installset creator (which seems to be InstallShield) will have support for this.
If you have never deployed applications before, be very, very careful when doing this.
|
|
|
|
|
I have a Visual C++ application with 2 timers. Each timer implements a piece of code that accesses a resource that may need to be shared.
In other words, there may be some overlap with the timers where the code implemented by each timer may require access to the same resource. Can each timer be thought of as a separate THREAD, where I can use some locking device to share the resource??
Thanks.
Jerry
|
|
|
|
|
No because if one timer access the resource during a lenghty process, and then the second timer fires during this time, your resource will be locked and you wont be able to access it in the function from your second timer. Thus, if you wait till the resource get's unlocked, your program will hang (because there is only ONE thread).
The functions from Timer1 and Timer2 are in the same Thread !!
|
|
|
|
|
No need to use Sync Object if you are sharing resource from your timer driven routines. Because, the application has only one message process que, the WM_TIMER messages receives arbitrary and the resource can only be accessed by one thread (main process) at a time.
If the application have more than one thread and they sharing same resources. You have to use Sync objects like CCriticalSection, CEvent, CMutex, CSemaphore etc if needs.
|
|
|
|
|
Hi All,
I am using the RegisterHotKey() function in a dll.
RegisterHotKey(hWnd,GlobalAddAtom(buff),MOD_ATL|MOD_CONTROL|MOD_SHIFT, vkKey) ;
where vkKey is some virtual key. and buff is some char string generated using system time.
and when I try to capture this event in WM_HOTKEY, none of the combination of vkKey is working , also when i press vkKey without any combination the event is not fired.
My goal is to get notification from when vkkey is key pressed with and without combination.
Thanks in Advance.
Abhishake
|
|
|
|
|
I'm using WinXP SP1, IE 6.0 SP1 etc etc and Visual 6.0 SP5.
I've imported a HTML resource named 1.htm in a dll and the attempt to display in a web browser using
res://thedll.dll/1.htm
fails.
By accident I renamed it, but starting with a letter: a1.htm.
res://thedll.dll/a1.htm
Success.
This is a bug in MSHTML.DLL (this seems to be the dll that implements the res: protocol)?
Or "This behavior is by default."
Just asking...
|
|
|
|
|
Hello dear programmers,
I want to declare a pointer to CUserSock in my CUserTalkDlg, like this:
CUserSock *m_pSocket;
But when I compile, I get this errormessage:
:\appi\usertalk\usertalkdlg.h(21) : error C2143: syntax error : missing ';' before '*'
c:\appi\usertalk\usertalkdlg.h(21) : error C2501: 'CUserSock' : missing storage-class or type specifiers
c:\appi\usertalk\usertalkdlg.h(21) : error C2501: 'm_pSocket' : missing storage-class or type specifiers
UserTalkDlg.cpp
c:\appi\usertalk\usertalkdlg.h(21) : error C2143: syntax error : missing ';' before '*'
c:\appi\usertalk\usertalkdlg.h(21) : error C2501: 'CUserSock' : missing storage-class or type specifiers
c:\appi\usertalk\usertalkdlg.h(21) : error C2501: 'm_pSocket' : missing storage-class or type specifiers
c:\APPI\UserTalk\UserTalkDlg.cpp(66) : error C2065: 'm_pSocket' : undeclared identifier
c:\APPI\UserTalk\UserTalkDlg.cpp(66) : error C2061: syntax error : identifier 'CUserSock'
So I don't know how to declare a pointer to a self derived class like CUserSock. Appearently it won't work right if I just declare in CUserTalkDlg like: CuserSock *m_pSocket
So can anyone help me please?
|
|
|
|
|
Sounds like you have not included the header file for CUserSock.
You'll need to add this to the beginning of your usertalkdlg.h file.
I Dream of Absolute Zero
|
|
|
|
|
Thanx RChin,
But when you add a CSocket-class in ClassWizard, doesn't it include automatically into CUserTalkDlg? Because that's my mainwindow. But I will check it again, I think you are right.
Thank you very very much!
|
|
|
|
|
I needed to create a custom control in toolbar of SDI application.
I creating toolbar as described in http://www.codeproject.com/docking/spnsld.asp.
When I created my control derived from CStatic all ok, but this control ignored all events (internal timer, mouse moves, clicks, etc).
I developed full-function control, derived from CWnd as described in http://www.codeproject.com/useritems/CustomControl.asp. This control reacted on all events, but I can't insert it to the toolbar - operator
if ( !m_indicator.Create ( _T ( "DISPLAY" ), "Title", WS_CHILD|WS_VISIBLE,
rect, this, ID_INDICATOR ) )
return -1;
in toolbar's OnCreate method returns -1 - toolbar doesn't create.
How I can to do this? Thanks.
|
|
|
|
|
My software prints out a calibrated tape. I would like to print it in mirror image so that when printed on film, it is the correct image when viewing it through the mylar. How do I print text in mirror image? Or is there an easy way to flip the CDC so that the rendered image will be reversed automatically?
TIA
Eric
|
|
|
|
|
Sounds like you need to use the SetWorldTransform() function. Take a look at it in the MSDN!
Roger Allen - Sonork 100.10016
Strong Sad: I am sad I am flying
Who is your favorite Strong?
|
|
|
|
|
Thanks Roger,
This is what I was looking for! However, there appears to be some kind of bug in that, although the image is properly mirrored on the display, (text and lines), when I perform a print preview, the graphics are flipped properly, but the text is no longer mirrored. Text is only rotated 180 degrees instead of mirrored. I created a SDI test app and have the code listed below in OnDraw(). It just draws a triangle with a word at the left side. When mirrored, the word is properly printed backwards on the right side of the screen. In print preview, the triangle is still correct, but the text is no longer mirrored. Any ideas?
TIA
Eric
<br />
pDC->SetMapMode(MM_TWIPS);<br />
SetGraphicsMode(pDC->m_hDC, GM_ADVANCED);<br />
XFORM XForm;<br />
::ZeroMemory(&XForm, sizeof(XFORM));<br />
XForm.eM21 = 0;
XForm.eM12 = 0;
<br />
XForm.eM11 = -1;<br />
XForm.eM22 = 1;<br />
XForm.eDx = 3000;<br />
XForm.eDy = 0;
SetWorldTransform(pDC->m_hDC, &XForm);<br />
<br />
pDC->MoveTo(500, -300);<br />
pDC->LineTo(1600, -100);<br />
pDC->LineTo(1600, -1200);<br />
pDC->LineTo(500, -300);<br />
pDC->SetTextColor(RGB(0,0,0));<br />
<br />
CFont num_font_upper;<br />
num_font_upper.CreateFont(.4 * 1440 , 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0,<br />
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS | CLIP_LH_ANGLES,<br />
DRAFT_QUALITY, VARIABLE_PITCH |FF_SWISS, "Arial"); <br />
CFont *pFont = pDC->SelectObject(&num_font_upper);<br />
pDC->TextOut(500,-300, CString("test"));<br />
pDC->SelectObject(pFont);<br />
|
|
|
|
|
::CryptGetHashParam(hHash,HP_HASHSIZE,NULL,ssize,0);
it does not return the size of hash to ssize =((
|
|
|
|
|