1. 背景
在程序中通过ShellExecute调用GoogleEarth显示位置点
2. 示例代码
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
wstring par1 = wstring(L"C:\\Learn_src\\Qt_Work_Space\\build-testOpenGooogleEarth-Desktop_Qt_5_6_2_MinGW_32bit-Debug\\gps_1048.txt(Pre).kml");
wstring par2 = wstring(L"C:\\Learn_src\\Qt_Work_Space\\build-testOpenGooogleEarth-Desktop_Qt_5_6_2_MinGW_32bit-Debug\\gps_1045.txt(Post).kml");
wstring par = par1 + wstring(L" ") + par2;
HINSTANCE ret = ShellExecute(NULL, L"open", L"C:/Program Files (x86)/Google/Google Earth/client/googleearth.exe", par.c_str(), NULL, SW_SHOWNORMAL);
if((int)ret < 32)
{
cout << "Error = " << (int)ret << endl;
cout << "Open Google Earth Application Failed !" << endl;
}
else
{
cout << "Open Google Earth Application Successed !" << endl;
}
return 0;
}
说明:(1)本人安装的GoogleEarth的路径如下:
C:/Program Files (x86)/Google/Google Earth/client/googleearth.exe
(2) par1和par2为需要打开的KML文件的路径
(3) par为传入ShellExecute的参数,表示利用googleearth.exe执行par参数