Build fix in tap, handling of Windows shutdown signals.

This commit is contained in:
Adam Ierymenko 2013-08-27 16:11:39 -04:00
parent cd907a7662
commit c247a3d991
2 changed files with 19 additions and 1 deletions

View File

@ -107,6 +107,23 @@ static void sighandlerQuit(int sig)
}
#endif
#ifdef __WINDOWS__
static BOOL WINAPI _handlerRoutine(DWORD dwCtrlType)
{
switch(dwCtrlType) {
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
case CTRL_CLOSE_EVENT:
case CTRL_SHUTDOWN_EVENT:
Node *n = node;
if (n)
n->terminate();
return TRUE;
}
return FALSE;
}
#endif
#ifdef __WINDOWS__
int _tmain(int argc, _TCHAR* argv[])
#else
@ -127,6 +144,7 @@ int main(int argc,char **argv)
#ifdef __WINDOWS__
WSADATA wsaData;
WSAStartup(MAKEWORD(2,2),&wsaData);
SetConsoleCtrlHandler(&_handlerRoutine,TRUE);
#endif
_initLibCrypto();

View File

@ -1017,7 +1017,7 @@ void EthernetTap::setDisplayName(const char *dn)
{
HKEY ifp;
if (RegOpenKeyExA(HKEY_LOCAL_MACHINE,(std::string("SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\") + _myDeviceInstanceId).c_str(),0,KEY_READ|KEY_WRITE,&ifp) == ERROR_SUCCESS) {
RegSetKeyValueA(ifp,"Connection","Name",REG_SZ,(LPCVOID)dn,strlen(dn)+1);
RegSetKeyValueA(ifp,"Connection","Name",REG_SZ,(LPCVOID)dn,(DWORD)(strlen(dn)+1));
RegCloseKey(ifp);
}
}