📄 testmsg_atldlg.cpp
字号:
// TestMsg_ATLDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TestMsg_ATL.h"
#include "TestMsg_ATLDlg.h"
#include "..\Msg_ATL\Msg_ATL.h"
const IID IID_IProcess = {0x7E9C8D77,0x2271,0x47AC,{0x8D,0x30,0xA4,0xE7,0xA8,0xEB,0xAE,0x3E}};
const CLSID CLSID_Process = {0x8FB98E70,0x926E,0x4C99,{0x99,0xD3,0x93,0x4C,0x78,0x37,0x0F,0xB7}};
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CTestMsg_ATLDlg dialog
CTestMsg_ATLDlg::CTestMsg_ATLDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTestMsg_ATLDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CTestMsg_ATLDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CTestMsg_ATLDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CTestMsg_ATLDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CTestMsg_ATLDlg, CDialog)
//{{AFX_MSG_MAP(CTestMsg_ATLDlg)
ON_BN_CLICKED(IDC_TEST, OnTest)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CTestMsg_ATLDlg message handlers
BOOL CTestMsg_ATLDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
CenterWindow(GetDesktopWindow()); // center to the hpc screen
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CTestMsg_ATLDlg::OnTest()
{
// 声明HRESULT和Simple_ATL接口指针
HRESULT hr;
IProcess *IProcess = NULL;
// 初始化COM
hr = CoInitializeEx(NULL, COINIT_MULTITHREADED);
// 使用 SUCCEEDED 宏并检查我们是否能得到一个接口指针
if(SUCCEEDED(hr))
{
hr = CoCreateInstance( CLSID_Process, NULL, CLSCTX_INPROC_SERVER,
IID_IProcess, (void**) &IProcess);
// 如果成功,则调用Show方法,否则显示相应的出错信息
if(SUCCEEDED(hr))
{
IProcess->Show();
IProcess->Release();
}
else
{
AfxMessageBox(L"CoCreateInstance Failed.");
}
}
// 释放 COM
CoUninitialize();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -