From 5c521d256815161f4af9066bc4bb9fea7fa1accb Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Tue, 16 Sep 2003 13:44:06 +0000 Subject: Initial Import --- Dropper.cpp | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Dropper.cpp (limited to 'Dropper.cpp') diff --git a/Dropper.cpp b/Dropper.cpp new file mode 100644 index 0000000..78f9708 --- /dev/null +++ b/Dropper.cpp @@ -0,0 +1,81 @@ +// Dropper.cpp : Implementation of WinMain + + +// Note: Proxy/Stub Information +// To build a separate proxy/stub DLL, +// run nmake -f Dropperps.mk in the project directory. + +#include "stdafx.h" +#include "resource.h" +#include + +#include "dropdlg.h" + +CComModule _Module; + +BEGIN_OBJECT_MAP(ObjectMap) +END_OBJECT_MAP() + + +LPCTSTR FindOneOf(LPCTSTR p1, LPCTSTR p2) +{ + while (p1 != NULL && *p1 != NULL) + { + LPCTSTR p = p2; + while (p != NULL && *p != NULL) + { + if (*p1 == *p) + return CharNext(p1); + p = CharNext(p); + } + p1 = CharNext(p1); + } + return NULL; +} + +///////////////////////////////////////////////////////////////////////////// +// +extern "C" int WINAPI _tWinMain(HINSTANCE hInstance, + HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int /*nShowCmd*/) +{ + lpCmdLine = GetCommandLine(); //this line necessary for _ATL_MIN_CRT + +#if _WIN32_WINNT >= 0x0400 & defined(_ATL_FREE_THREADED) + HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED); +#else + HRESULT hRes = CoInitialize(NULL); +#endif + _ASSERTE(SUCCEEDED(hRes)); + _Module.Init(ObjectMap, hInstance, NULL); + TCHAR szTokens[] = _T("-/"); + + int nRet = 0; + BOOL bRun = TRUE; + LPCTSTR lpszToken = FindOneOf(lpCmdLine, szTokens); + while (lpszToken != NULL) + { + if (lstrcmpi(lpszToken, _T("UnregServer"))==0) + { + _Module.UpdateRegistryFromResource(IDR_Dropper, FALSE); + bRun = FALSE; + break; + } + if (lstrcmpi(lpszToken, _T("RegServer"))==0) + { + _Module.UpdateRegistryFromResource(IDR_Dropper, TRUE); + bRun = FALSE; + break; + } + lpszToken = FindOneOf(lpszToken, szTokens); + } + + if (bRun) + { + CDropDlg dlg; + dlg.DoModal(); + } + + _Module.Term(); + CoUninitialize(); + return nRet; +} -- cgit v1.2.3