ShellExecute,第一次使用纪念

#include "Windows.h"
#include <iostream>
#include <cstring>
#include <shellapi.h>

using namespace std;

int main()
{
 long ret=-1;//ERROR_SUCCESS if succeed
 HKEY key;

 ret=RegOpenKeyEx(HKEY_LOCAL_MACHINE,L"SOFTWARE//subkey//subkey......",0,KEY_READ,&key);
 if(ret==ERROR_SUCCESS)
 {
  cout<<"succeed"<<endl;
 }
 else
 {
  cout<<"now will install the execute.Please complete it!"<<endl;
  HINSTANCE result=ShellExecute(NULL,L"open",L"Name of the .exe",NULL,NULL,SW_HIDE);
  
  if((int)result>32)
  {
   cout<<"succeed"<<endl;
  }
  else
  {
   cout<<"unsucceed"<<endl;
  }
 }

 system("pause");
}

你可能感兴趣的:(null,System,include)