CSDN博客

img awzzz

调用Shell接口(系统运行窗口)的代码

发表于2004/6/2 19:34:00  837人阅读

//--调用Shell接口(系统运行窗口)的代码

#include "stdafx.h"

//--interface
#include <Exdisp.h>

#include <iostream>
using namespace std;

void FileRun()
{
 //--COM
 CoInitialize(NULL);
 
 do {
  
  cout << "---Invoke ShellRun---" << endl;
  
  IShellDispatch *shell = NULL;
  HRESULT hr = CoCreateInstance(CLSID_Shell
   , NULL
   , CLSCTX_SERVER
   , IID_IDispatch,
   (void**)&shell);
  if (FAILED(hr) || !shell)
  {
   cout << "interface FAILED." << endl;
   break;
  }
  
  shell->FileRun();
  //shell->FindFiles();
  /*
  Shell object methods
  The Shell object has the following methods:
  BrowseForFolder
  CascadeWindows
  ControlPanelItem
  EjectPC
  Explore
  FileRun
  FindComputer
  FindFiles
  Help
  MinimizeAll
  NameSpace
  Open
  RefreshMenu
  SetTime
  ShutdownWindows
  Suspend
  TileHorizontally
  TileVertically
  TrayProperties
  UndoMinimizeALL
  Windows
  */
  
  shell->Release();
  
  cout << "---ShellRun OK.---" << endl;
  break;
 } while (false);
 
 //--COM
 CoUninitialize();
}

int main(int argc, char* argv[])
{
 FileRun();
 return 0;
}

0 0

相关博文

我的热门文章

img
取 消
img