24,860
社区成员




// InstallExe.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "..\common\xinstall.h"
void GetPath(OUT TCHAR *sPath)
{
TCHAR sFilename[MAX_PATH];
TCHAR sDrive[_MAX_DRIVE];
TCHAR sDir[_MAX_DIR];
TCHAR sFname[_MAX_FNAME];
TCHAR sExt[_MAX_EXT];
GetModuleFileName(NULL, sFilename, _MAX_PATH);
_tsplitpath(sFilename, sDrive, sDir, sFname, sExt);
_tcscpy(sPath, sDrive);
_tcscat(sPath, sDir);
if(sPath[_tcslen(sPath) - 1] != _T('\\'))
_tcscat(sPath, _T("\\"));
}
void PrintReturnCode()
{
printf("\n");
printf(" 0 Success.\n");
printf(" -801 The TcpIpDog service provider not installed.\n");
printf(" -802 The TcpIpDog service provider already installed.\n");
printf(" -803 Failed to open registry.\n");
printf(" -804 Failed to save the path of TcpIpDog service provider.\n");
printf(" -805 Failed to read the registry value.\n");
printf(" -806 Failed to create the key in the registry.\n");
printf(" -807 Failed to set the value of the key in the registry.\n");
printf(" -808 Failed to delete the key of registry.\n");
}
int main(int argc, char* argv[])
{
__try
{
if(argc <= 1 || argc >= 3)
{
printf("Install [-install | -remove]\n");
printf(" -install : used to install tcpipdog service provider.\n");
printf(" -remove : used to remove the tcpipdog service provider.\n");
system("cause");
return 0;
}
CXInstall m_Install;
if(_tcscmp(argv[1], _T("-install")) == 0)
{
TCHAR sProvider[MAX_PATH];
GetPath(sProvider);
if(sProvider[0] == '\0')
{
printf("Can't find the application path.\n");
system("cause");
return 0;
}
_tcscat(sProvider, XFILTER_SERVICE_DLL_NAME);
if(_taccess(sProvider, 0) == -1)
{
printf("Can't find %s", sProvider);
system("cause");
return 0;
}
printf("Install The TcpIpDog Service Provider...\n\n");
printf("Return Code: %d\n", m_Install.InstallProvider(sProvider));
PrintReturnCode();
system("cause");
return 0;
}
else if(_tcscmp(argv[1], _T("-remove")) == 0)
{
printf("Remove the TcpIpDog service provider...\n\n");
printf("Return Code: %d\n", m_Install.RemoveProvider());
PrintReturnCode();
system("cause");
return 0;
}
printf("Invaid parameter.\n");
system("cause");
return 0;
}
__finally
{
printf("\nCopyRight (c) 2001 Xstudio Technology.\nAll Right Reserved.\n\n");
}
system("cause");
return 0;
}
// stdafx.cpp : source file that includes just the standard includes
// InstallExe.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#if !defined(AFX_STDAFX_H__B31F9489_22FC_46B2_B768_7A90EEA9BED4__INCLUDED_)
#define AFX_STDAFX_H__B31F9489_22FC_46B2_B768_7A90EEA9BED4__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <afxwin.h>
#include <winsock2.h>
#include <io.h>
#include <stdio.h>
// TODO: reference additional headers your program requires here
#include "..\common\debug.h"
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_STDAFX_H__B31F9489_22FC_46B2_B768_7A90EEA9BED4__INCLUDED_)