Clone of Akilla's acserver @ https://github.com/deregtd/ACServer

ClientLogon.cpp 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. o// ClientLogon.cpp : main source file for ClientLogon.exe
  2. //
  3. #include "stdafx.h"
  4. #include <atlctrls.h>
  5. #include <atldlgs.h>
  6. #include "resource.h"
  7. #include "maindlg.h"
  8. CAppModule _Module;
  9. void SetupRegistry();
  10. int Run(LPTSTR lpstrCmdLine, int nCmdShow = SW_SHOWDEFAULT)
  11. {
  12. CMessageLoop theLoop;
  13. _Module.AddMessageLoop(&theLoop);
  14. CMainDlg dlgMain;
  15. if(dlgMain.Create(NULL) == NULL)
  16. {
  17. ATLTRACE(_T("Main dialog creation failed!\n"));
  18. return 0;
  19. }
  20. dlgMain.ShowWindow(nCmdShow);
  21. if (strstr(lpstrCmdLine, "://"))
  22. {
  23. char newaddy[300];
  24. strcpy(newaddy, strstr(lpstrCmdLine, "://")+3);
  25. newaddy[strlen(newaddy)-1] = 0;
  26. dlgMain.SetDlgItemText ( IDC_SERVER, newaddy );
  27. }
  28. int nRet = theLoop.Run();
  29. _Module.RemoveMessageLoop();
  30. return nRet;
  31. }
  32. void main( int argc, char *argv[ ], char *envp[ ] )
  33. {
  34. MessageBox(NULL, "If you get this dialog please tell akilla exactly what caused it, thanks. :-)", "WTF!?", MB_OK);
  35. }
  36. void SetupRegistry()
  37. {
  38. CRegKey rk;
  39. rk.Create ( HKEY_CLASSES_ROOT, _T( "acserver" ) );
  40. rk.Create ( HKEY_CLASSES_ROOT, _T( "acserver\\shell" ) );
  41. rk.Create ( HKEY_CLASSES_ROOT, _T( "acserver\\shell\\open" ) );
  42. rk.Create ( HKEY_CLASSES_ROOT, _T( "acserver\\shell\\open\\command" ) );
  43. char curdir[500]; GetModuleFileName(NULL, curdir, 500);
  44. char logondir[500];
  45. sprintf(logondir, "%s %%1", curdir);
  46. rk.SetValue (HKEY_CLASSES_ROOT, _T( "acserver\\shell\\open\\command" ), logondir );
  47. rk.SetValue (HKEY_CLASSES_ROOT, _T( "acserver" ), "", "URL Protocol");
  48. rk.Close();
  49. }
  50. int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
  51. {
  52. HRESULT hRes = _Module.Init(NULL, hInstance);
  53. ATLASSERT(SUCCEEDED(hRes));
  54. g_hInst = hInstance;
  55. SetupRegistry();
  56. int nRet = Run(lpstrCmdLine, nCmdShow);
  57. _Module.Term();
  58. return nRet;
  59. }