每次打開計算機都要鼠標啪啪啪點開好幾個程序,沒事就嘗試寫個一次性打開所有常用程序的代碼......
#include "stdafx.h"
#include <windows.h>
#include <WinInet.h>
#include <Shellapi.h>
#include <iostream>
#pragma comment(lib,"wininet.lib")
#pragma comment(lib,"shell32.lib")
using namespace System;
using namespace std;
void openPro()
{
cout<<"START Netease Mail..."<<endl;
ShellExecute(NULL,L"open",L"\"F:\\Program Files (x86)\\Netease\\網易閃電郵\\Start.exe\"",NULL,NULL,SW_SHOWMAXIMIZED); Sleep(3*1000);
cout<<"START QQ..."<<endl;
ShellExecute(NULL,L"open",L"\"E:\\Program Files (x86)\\Tencent\\QQ\\Bin\\QQ.exe\"",NULL,NULL,SW_MINIMIZE);
Sleep(3*1000);
cout<<"START Sina Weibo..."<<endl;
ShellExecute(NULL,L"open",L"http://weibo.com",NULL,NULL,SW_SHOWMAXIMIZED);
Sleep(3*1000);
cout<<"START MSN..."<<endl;
ShellExecute(NULL,L"open",L"\"C:\\Program Files (x86)\\Windows Live\\Messenger\\msnmsgr.exe\"",NULL,NULL,SW_MINIMIZE);
Sleep(3*1000);
}
int pingNet()
{
if(InternetCheckConnection(L"http://weibo.com", FLAG_ICC_FORCE_CONNECTION ,0))
return 1;
else
return 0;
}
int main(array<System::String ^> ^args)
{
Sleep(2*60*1000);
cout<<"Check internet......"<<endl;
int sign,temp=1;
do
{
sign=pingNet();
if(sign==0)
{
cout<<"Failure...try again after "<<2*temp-1<<" minutes"<<endl;
Sleep((2*temp-1)*60*1000);
temp++;
}
else
break;
}while(temp<4);
if(sign==0)
{
cout<<"Connect failure...program will exit now......"<<endl;
Sleep(2*1000);
exit(0);
}
else
{
cout<<"Connect success..."<<endl;
openPro();
}
cout<<"SUCCESS...EXIT NOW..."<<endl;
Sleep(2*1000);
return 0;
}
從這麼點代碼領悟出,想成爲一個程序員任重道遠啊......耗費了一下午,爲搞明白碰到的問題,連晚飯都沒喫,餓死了......