[VC(Visual C++) ]- 68_啟動控制台
本篇分享68_啟動控制台程式範例,有興趣的(C/P)同好,歡迎來http://yfdisk.com/file/jashliao/0446e80b/索取,因為我不會上傳檔案分享哈哈 ^ ^。
主要程式碼 |
001 // Call Control_RunDLLDlg.cpp : implementation file 002 // 003 004 #include "stdafx.h" 005 #include "Call Control_RunDLL.h" 006 #include "Call Control_RunDLLDlg.h" 007 008 #ifdef _DEBUG 009 #definenew DEBUG_NEW 010 #undef THIS_FILE 011 staticchar THIS_FILE[] = __FILE__; 012 #endif 013 014 ///////////////////////////////////////////////////////////////////////////// 015 // CAboutDlg dialog used for App About 016 017 class CAboutDlg : public CDialog 018 { 019 public: 020 CAboutDlg(); 021 022 // Dialog Data 023 //{{AFX_DATA(CAboutDlg) 024 enum { IDD = IDD_ABOUTBOX }; 025 //}}AFX_DATA 026 027 // ClassWizard generated virtual function overrides 028 //{{AFX_VIRTUAL(CAboutDlg) 029 protected: 030 virtualvoid DoDataExchange(CDataExchange* pDX); // DDX/DDV support 031 //}}AFX_VIRTUAL 032 033 // Implementation 034 protected: 035 //{{AFX_MSG(CAboutDlg) 036 //}}AFX_MSG 037 DECLARE_MESSAGE_MAP() 038 }; 039 040 CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD) 041 { 042 //{{AFX_DATA_INIT(CAboutDlg) 043 //}}AFX_DATA_INIT 044 } 045 046 void CAboutDlg::DoDataExchange(CDataExchange* pDX) 047 { 048 CDialog::DoDataExchange(pDX); 049 //{{AFX_DATA_MAP(CAboutDlg) 050 //}}AFX_DATA_MAP 051 } 052 053 BEGIN_MESSAGE_MAP(CAboutDlg, CDialog) 054 //{{AFX_MSG_MAP(CAboutDlg) 055 // No message handlers 056 //}}AFX_MSG_MAP 057 END_MESSAGE_MAP() 058 059 ///////////////////////////////////////////////////////////////////////////// 060 // CCallControl_RunDLLDlg dialog 061 062 CCallControl_RunDLLDlg::CCallControl_RunDLLDlg(CWnd* pParent /*=NULL*/) 063 : CDialog(CCallControl_RunDLLDlg::IDD, pParent) 064 { 065 //{{AFX_DATA_INIT(CCallControl_RunDLLDlg) 066 // NOTE: the ClassWizard will add member initialization here 067 //}}AFX_DATA_INIT 068 // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 069 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); 070 } 071 072 void CCallControl_RunDLLDlg::DoDataExchange(CDataExchange* pDX) 073 { 074 CDialog::DoDataExchange(pDX); 075 //{{AFX_DATA_MAP(CCallControl_RunDLLDlg) 076 // NOTE: the ClassWizard will add DDX and DDV calls here 077 //}}AFX_DATA_MAP 078 } 079 080 BEGIN_MESSAGE_MAP(CCallControl_RunDLLDlg, CDialog) 081 //{{AFX_MSG_MAP(CCallControl_RunDLLDlg) 082 ON_WM_SYSCOMMAND() 083 ON_WM_PAINT() 084 ON_WM_QUERYDRAGICON() 085 ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 086 //}}AFX_MSG_MAP 087 END_MESSAGE_MAP() 088 089 ///////////////////////////////////////////////////////////////////////////// 090 // CCallControl_RunDLLDlg message handlers 091 092 BOOL CCallControl_RunDLLDlg::OnInitDialog() 093 { 094 CDialog::OnInitDialog(); 095 096 // Add "About..." menu item to system menu. 097 098 // IDM_ABOUTBOX must be in the system command range. 099 ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX); 100 ASSERT(IDM_ABOUTBOX < 0xF000); 101 102 CMenu* pSysMenu = GetSystemMenu(FALSE); 103 if (pSysMenu != NULL) 104 { 105 CString strAboutMenu; 106 strAboutMenu.LoadString(IDS_ABOUTBOX); 107 if (!strAboutMenu.IsEmpty()) 108 { 109 pSysMenu->AppendMenu(MF_SEPARATOR); 110 pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu); 111 } 112 } 113 114 // Set the icon for this dialog. The framework does this automatically 115 // when the application's main window is not a dialog 116 SetIcon(m_hIcon, TRUE); // Set big icon 117 SetIcon(m_hIcon, FALSE); // Set small icon 118 119 // TODO: Add extra initialization here 120 121 return TRUE; // return TRUE unless you set the focus to a control 122 } 123 124 void CCallControl_RunDLLDlg::OnSysCommand(UINT nID, LPARAM lParam) 125 { 126 if ((nID & 0xFFF0) == IDM_ABOUTBOX) 127 { 128 CAboutDlg dlgAbout; 129 dlgAbout.DoModal(); 130 } 131 else 132 { 133 CDialog::OnSysCommand(nID, lParam); 134 } 135 } 136 137 // If you add a minimize button to your dialog, you will need the code below 138 // to draw the icon. For MFC applications using the document/view model, 139 // this is automatically done for you by the framework. 140 141 void CCallControl_RunDLLDlg::OnPaint() 142 { 143 if (IsIconic()) 144 { 145 CPaintDC dc(this); // device context for painting 146 147 SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); 148 149 // Center icon in client rectangle 150 int cxIcon = GetSystemMetrics(SM_CXICON); 151 int cyIcon = GetSystemMetrics(SM_CYICON); 152 CRect rect; 153 GetClientRect(&rect); 154 int x = (rect.Width() - cxIcon + 1) / 2; 155 int y = (rect.Height() - cyIcon + 1) / 2; 156 157 // Draw the icon 158 dc.DrawIcon(x, y, m_hIcon); 159 } 160 else 161 { 162 CDialog::OnPaint(); 163 } 164 } 165 166 // The system calls this to obtain the cursor to display while the user drags 167 // the minimized window. 168 HCURSOR CCallControl_RunDLLDlg::OnQueryDragIcon() 169 { 170 return (HCURSOR) m_hIcon; 171 } 172 173 void CCallControl_RunDLLDlg::OnButton1() 174 { 175 // TODO: Add your control notification handler code here 176 /* 177 rundll32.exe shell32.dll,Control_RunDLL timedate.cpl 設定時間 178 rundll32.exe shell32.dll,Control_RunDLL access.cpl 179 rundll32.exe shell32.dll,Control_RunDLL appwiz.cpl 新增移除程式 180 rundll32.exe shell32.dll,Control_RunDLL desk.cpl 顯示器 181 rundll32.exe shell32.dll,Control_RunDLL firewall.cpl 防火牆 182 rundll32.exe shell32.dll,Control_RunDLL hdwwiz.cpl 新增硬體 183 rundll32.exe shell32.dll,Control_RunDLL inetcpl.cpl IE設定 184 rundll32.exe shell32.dll,Control_RunDLL intl.cpl 地區 185 rundll32.exe shell32.dll,Control_RunDLL joy.cpl 搖桿 186 rundll32.exe shell32.dll,Control_RunDLL main.cpl 滑鼠 187 rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl 音量 188 rundll32.exe shell32.dll,Control_RunDLL ncpa.cpl 網卡/撥接 189 rundll32.exe shell32.dll,Control_RunDLL netsetup.cpl 網路設定 190 rundll32.exe shell32.dll,Control_RunDLL nusrmgr.cpl 使用者 191 rundll32.exe shell32.dll,Control_RunDLL odbccp32.cpl ODBC 192 rundll32.exe shell32.dll,Control_RunDLL powercfg.cpl 電源管理 193 rundll32.exe shell32.dll,Control_RunDLL sysdm.cpl 系統內容 194 rundll32.exe shell32.dll,Control_RunDLL telephon.cpl 195 rundll32.exe shell32.dll,Control_RunDLL sapi.cpl 196 */ 197 ShellExecute(NULL,"open","C:\\WINDOWS\\system32\\rundll32.exe","shell32.dll,Control_RunDLL",NULL,SW_SHOWNORMAL); 198 }
|
沒有留言:
張貼留言