⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exeshellctl.cpp

📁 自己的图片变换操作
💻 CPP
字号:
// EXEshellCtl.cpp : Implementation of the CEXEshellCtrl ActiveX Control class.

#include "stdafx.h"
#include "EXEshell.h"
#include "EXEshellCtl.h"
#include "EXEshellPpg.h"


#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


IMPLEMENT_DYNCREATE(CEXEshellCtrl, COleControl)


/////////////////////////////////////////////////////////////////////////////
// Message map

BEGIN_MESSAGE_MAP(CEXEshellCtrl, COleControl)
	//{{AFX_MSG_MAP(CEXEshellCtrl)
	// NOTE - ClassWizard will add and remove message map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_MSG_MAP
	ON_OLEVERB(AFX_IDS_VERB_PROPERTIES, OnProperties)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// Dispatch map

BEGIN_DISPATCH_MAP(CEXEshellCtrl, COleControl)
	//{{AFX_DISPATCH_MAP(CEXEshellCtrl)
	DISP_FUNCTION(CEXEshellCtrl, "command", command, VT_I2, VTS_NONE)
	//}}AFX_DISPATCH_MAP
	DISP_FUNCTION_ID(CEXEshellCtrl, "AboutBox", DISPID_ABOUTBOX, AboutBox, VT_EMPTY, VTS_NONE)
END_DISPATCH_MAP()


/////////////////////////////////////////////////////////////////////////////
// Event map

BEGIN_EVENT_MAP(CEXEshellCtrl, COleControl)
	//{{AFX_EVENT_MAP(CEXEshellCtrl)
	// NOTE - ClassWizard will add and remove event map entries
	//    DO NOT EDIT what you see in these blocks of generated code !
	//}}AFX_EVENT_MAP
END_EVENT_MAP()


/////////////////////////////////////////////////////////////////////////////
// Property pages

// TODO: Add more property pages as needed.  Remember to increase the count!
BEGIN_PROPPAGEIDS(CEXEshellCtrl, 1)
	PROPPAGEID(CEXEshellPropPage::guid)
END_PROPPAGEIDS(CEXEshellCtrl)


/////////////////////////////////////////////////////////////////////////////
// Initialize class factory and guid

IMPLEMENT_OLECREATE_EX(CEXEshellCtrl, "EXESHELL.EXEshellCtrl.1",
	0xb3c5a9c6, 0xb44, 0x43d8, 0xa7, 0xf3, 0xd7, 0xf8, 0x8a, 0x9d, 0x3, 0x64)


/////////////////////////////////////////////////////////////////////////////
// Type library ID and version

IMPLEMENT_OLETYPELIB(CEXEshellCtrl, _tlid, _wVerMajor, _wVerMinor)


/////////////////////////////////////////////////////////////////////////////
// Interface IDs

const IID BASED_CODE IID_DEXEshell =
		{ 0x3f18d389, 0x2c58, 0x4c2f, { 0x98, 0xce, 0x6d, 0x6, 0xa3, 0x14, 0xae, 0x6f } };
const IID BASED_CODE IID_DEXEshellEvents =
		{ 0xd398f3a8, 0x6acc, 0x49fa, { 0xb5, 0x45, 0xcd, 0xa6, 0xb2, 0x3c, 0x2e, 0xe } };


/////////////////////////////////////////////////////////////////////////////
// Control type information

static const DWORD BASED_CODE _dwEXEshellOleMisc =
	OLEMISC_ACTIVATEWHENVISIBLE |
	OLEMISC_SETCLIENTSITEFIRST |
	OLEMISC_INSIDEOUT |
	OLEMISC_CANTLINKINSIDE |
	OLEMISC_RECOMPOSEONRESIZE;

IMPLEMENT_OLECTLTYPE(CEXEshellCtrl, IDS_EXESHELL, _dwEXEshellOleMisc)


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::CEXEshellCtrlFactory::UpdateRegistry -
// Adds or removes system registry entries for CEXEshellCtrl

BOOL CEXEshellCtrl::CEXEshellCtrlFactory::UpdateRegistry(BOOL bRegister)
{
	// TODO: Verify that your control follows apartment-model threading rules.
	// Refer to MFC TechNote 64 for more information.
	// If your control does not conform to the apartment-model rules, then
	// you must modify the code below, changing the 6th parameter from
	// afxRegApartmentThreading to 0.

	if (bRegister)
		return AfxOleRegisterControlClass(
			AfxGetInstanceHandle(),
			m_clsid,
			m_lpszProgID,
			IDS_EXESHELL,
			IDB_EXESHELL,
			afxRegApartmentThreading,
			_dwEXEshellOleMisc,
			_tlid,
			_wVerMajor,
			_wVerMinor);
	else
		return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::CEXEshellCtrl - Constructor

CEXEshellCtrl::CEXEshellCtrl()
{
	InitializeIIDs(&IID_DEXEshell, &IID_DEXEshellEvents);

	// TODO: Initialize your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::~CEXEshellCtrl - Destructor

CEXEshellCtrl::~CEXEshellCtrl()
{
	// TODO: Cleanup your control's instance data here.
}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::OnDraw - Drawing function

void CEXEshellCtrl::OnDraw(
			CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
	// TODO: Replace the following code with your own drawing code.
	pdc->FillRect(rcBounds, CBrush::FromHandle((HBRUSH)GetStockObject(WHITE_BRUSH)));
	pdc->Ellipse(rcBounds);
}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::DoPropExchange - Persistence support

void CEXEshellCtrl::DoPropExchange(CPropExchange* pPX)
{
	ExchangeVersion(pPX, MAKELONG(_wVerMinor, _wVerMajor));
	COleControl::DoPropExchange(pPX);

	// TODO: Call PX_ functions for each persistent custom property.

}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::OnResetState - Reset control to default state

void CEXEshellCtrl::OnResetState()
{
	COleControl::OnResetState();  // Resets defaults found in DoPropExchange

	// TODO: Reset any other control state here.
}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl::AboutBox - Display an "About" box to the user

void CEXEshellCtrl::AboutBox()
{
	CDialog dlgAbout(IDD_ABOUTBOX_EXESHELL);
	dlgAbout.DoModal();
}


/////////////////////////////////////////////////////////////////////////////
// CEXEshellCtrl message handlers

short CEXEshellCtrl::command() 
{
	// TODO: Add your dispatch handler code here
  /*  
	char cPath[_MAX_DIR];
	int nLen = 0;
	nLen = GetCurrentDirectory(_MAX_DIR,cPath);
	//AfxMessageBox("CEXEshellCtrl::GetCurrentDirectory");
	//AfxMessageBox(cPath);

	nLen = GetSystemDirectory(cPath,_MAX_DIR);
	//AfxMessageBox("CEXEshellCtrl::GetSystemDirectory");
	//AfxMessageBox(cPath);


	CFile f; 
	
	char* pFileName = "hmACI.exe";
	if( !f.Open( pFileName, CFile::modeCreate | CFile::modeWrite, NULL ) )
	{
	AfxMessageBox("非法!系统中存在同一副本程序!");
	AfxEndThread(0,TRUE);
	return 0;
	}
	
	CString path = f.GetFilePath();
	AfxMessageBox("f.GetFilePath()");
	AfxMessageBox(path);

	  HGLOBAL hRes;
	  HRSRC hResInfo;
	  //获取应用实例  
	  HINSTANCE insApp = AfxGetInstanceHandle();
	  //寻找EXE资源名
	  hResInfo = FindResource(insApp,(LPCSTR)IDR_EXE4,"EXE");
	  hRes = LoadResource(insApp,hResInfo );   // Load it
	  DWORD dFileLength = SizeofResource( insApp, hResInfo );  //计算EXE文件大小 
	  f.WriteHuge((LPSTR)hRes,dFileLength);  //写入临时文件 
	  f.Close();
	   
	
	   SHELLEXECUTEINFO ShExecInfo = {0};
	   ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
	   ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
	   ShExecInfo.hwnd = NULL;
	   ShExecInfo.lpVerb = NULL;
	   ShExecInfo.lpFile = "hmACI.exe";		
	   ShExecInfo.lpParameters = "";	
	   ShExecInfo.lpDirectory = NULL;
	   ShExecInfo.nShow = SW_MAXIMIZE;
	   ShExecInfo.hInstApp = NULL;	
	   
	   //ShellExecuteEx(&ShExecInfo);
	   //WinExec('command.com /c copy *.* c:\',SW_Normal); 
	   //WinExec("hmACI.exe",SW_MAXIMIZE); 		//ok	
	   
	   HINSTANCE HINSsd = ShellExecute(this->m_hWnd, "open","D:\\hm\\bin\\hmAci.exe", NULL, NULL, SW_SHOWNORMAL);
	   
	   //运行它.  
       return 1;
*/
	 //  如何启动一个程序,直到它运行结束? SHELLEXECUTEINFO ShExecInfo = {0};
SHELLEXECUTEINFO ShExecInfo = {0};
	ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = "D:\\hm\\bin\\hmAci.exe";		
ShExecInfo.lpParameters = "";	
ShExecInfo.lpDirectory ="D:\\hm\\bin\\";
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;	
ShellExecuteEx(&ShExecInfo);
WaitForSingleObject(ShExecInfo.hProcess,INFINITE);
return 1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -